2000-02-15 21:49:31 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* variable.c
|
|
|
|
* Routines for handling of 'SET var TO',
|
|
|
|
* 'SHOW var' and 'RESET var' statements.
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1997-04-17 15:50:57 +02:00
|
|
|
*
|
2000-02-15 21:49:31 +01:00
|
|
|
* IDENTIFICATION
|
2000-02-19 23:10:47 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.30 2000/02/19 22:10:44 tgl Exp $
|
1997-04-17 15:50:57 +02:00
|
|
|
*
|
2000-02-15 21:49:31 +01:00
|
|
|
*-------------------------------------------------------------------------
|
1997-04-17 15:50:57 +02:00
|
|
|
*/
|
|
|
|
|
1997-06-20 19:17:03 +02:00
|
|
|
#include <ctype.h>
|
1997-11-21 19:12:58 +01:00
|
|
|
#include <time.h>
|
1999-07-16 07:00:38 +02:00
|
|
|
|
1997-03-25 10:44:00 +01:00
|
|
|
#include "postgres.h"
|
2000-02-15 21:49:31 +01:00
|
|
|
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "access/xact.h"
|
1999-09-27 22:27:32 +02:00
|
|
|
#include "catalog/pg_shadow.h"
|
1998-01-05 19:43:18 +01:00
|
|
|
#include "commands/variable.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "miscadmin.h"
|
2000-01-23 00:50:30 +01:00
|
|
|
#include "optimizer/cost.h"
|
|
|
|
#include "optimizer/paths.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "utils/builtins.h"
|
1999-06-17 17:16:09 +02:00
|
|
|
#include "utils/tqual.h"
|
1999-09-27 22:27:32 +02:00
|
|
|
#include "utils/trace.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
|
1998-07-18 20:34:34 +02:00
|
|
|
#ifdef MULTIBYTE
|
1998-07-26 06:31:41 +02:00
|
|
|
#include "mb/pg_wchar.h"
|
1998-06-16 09:29:54 +02:00
|
|
|
#endif
|
1999-07-16 07:00:38 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
|
|
|
|
/* XXX should be in a header file */
|
|
|
|
extern bool _use_keyset_query_optimizer;
|
|
|
|
|
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool show_date(void);
|
|
|
|
static bool reset_date(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_date(char *);
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool show_timezone(void);
|
|
|
|
static bool reset_timezone(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_timezone(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool show_effective_cache_size(void);
|
|
|
|
static bool reset_effective_cache_size(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_effective_cache_size(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool show_random_page_cost(void);
|
|
|
|
static bool reset_random_page_cost(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_random_page_cost(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool show_cpu_tuple_cost(void);
|
|
|
|
static bool reset_cpu_tuple_cost(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_cpu_tuple_cost(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool show_cpu_index_tuple_cost(void);
|
|
|
|
static bool reset_cpu_index_tuple_cost(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_cpu_index_tuple_cost(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool show_cpu_operator_cost(void);
|
|
|
|
static bool reset_cpu_operator_cost(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_cpu_operator_cost(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_seqscan(void);
|
|
|
|
static bool show_enable_seqscan(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_seqscan(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_indexscan(void);
|
|
|
|
static bool show_enable_indexscan(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_indexscan(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_tidscan(void);
|
|
|
|
static bool show_enable_tidscan(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_tidscan(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_sort(void);
|
|
|
|
static bool show_enable_sort(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_sort(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_nestloop(void);
|
|
|
|
static bool show_enable_nestloop(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_nestloop(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_mergejoin(void);
|
|
|
|
static bool show_enable_mergejoin(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_mergejoin(char *);
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool reset_enable_hashjoin(void);
|
|
|
|
static bool show_enable_hashjoin(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_enable_hashjoin(char *);
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool reset_geqo(void);
|
|
|
|
static bool show_geqo(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_geqo(char *);
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool show_ksqo(void);
|
|
|
|
static bool reset_ksqo(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_ksqo(char *);
|
1998-12-18 10:10:39 +01:00
|
|
|
static bool show_XactIsoLevel(void);
|
|
|
|
static bool reset_XactIsoLevel(void);
|
2000-02-19 23:10:47 +01:00
|
|
|
static bool parse_XactIsoLevel(char *);
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
2000-02-19 23:10:47 +01:00
|
|
|
* get_token
|
|
|
|
* Obtain the next item in a comma-separated list of items,
|
|
|
|
* where each item can be either "word" or "word=word".
|
|
|
|
* The "word=word" form is only accepted if 'val' is not NULL.
|
|
|
|
* Words are any sequences not containing whitespace, ',', or '='.
|
|
|
|
* Whitespace can appear between the words and punctuation.
|
1998-10-14 07:10:12 +02:00
|
|
|
*
|
2000-02-19 23:10:47 +01:00
|
|
|
* 'tok': receives a pointer to first word of item, or NULL if none.
|
|
|
|
* 'val': if not NULL, receives a pointer to second word, or NULL if none.
|
|
|
|
* 'str': start of input string.
|
1998-10-14 07:10:12 +02:00
|
|
|
*
|
2000-02-19 23:10:47 +01:00
|
|
|
* Returns NULL if input string contained no more words, else pointer
|
|
|
|
* to just past this item, which can be used as 'str' for next call.
|
|
|
|
* (If this is the last item, returned pointer will point at a null char,
|
|
|
|
* so caller can alternatively check for that instead of calling again.)
|
|
|
|
*
|
|
|
|
* NB: input string is destructively modified by placing null characters
|
|
|
|
* at ends of words!
|
|
|
|
*
|
|
|
|
* A former version of this code avoided modifying the input string by
|
|
|
|
* returning palloc'd copies of the words. However, we want to use this
|
|
|
|
* code early in backend startup to parse the PGDATESTYLE environment var,
|
|
|
|
* and palloc/pfree aren't initialized at that point. Cleanest answer
|
|
|
|
* seems to be to palloc in SetPGVariable() so that we can treat the string
|
|
|
|
* as modifiable here.
|
1998-10-14 07:10:12 +02:00
|
|
|
*/
|
2000-02-19 23:10:47 +01:00
|
|
|
static char *
|
|
|
|
get_token(char **tok, char **val, char *str)
|
1997-06-02 13:00:57 +02:00
|
|
|
{
|
2000-02-19 23:10:47 +01:00
|
|
|
char ch;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
*tok = NULL;
|
|
|
|
if (val != NULL)
|
|
|
|
*val = NULL;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
if (!str || *str == '\0')
|
1997-09-07 07:04:48 +02:00
|
|
|
return NULL;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* skip leading white space */
|
1997-09-07 07:04:48 +02:00
|
|
|
while (isspace(*str))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
/* end of string? then return NULL */
|
2000-02-19 23:10:47 +01:00
|
|
|
if (*str == '\0')
|
1997-09-07 07:04:48 +02:00
|
|
|
return NULL;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
if (*str == ',' || *str == '=')
|
|
|
|
elog(ERROR, "Syntax error near \"%s\": empty setting", str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* OK, at beginning of non-empty item */
|
|
|
|
*tok = str;
|
|
|
|
|
|
|
|
/* Advance to end of word */
|
|
|
|
while (*str && !isspace(*str) && *str != ',' && *str != '=')
|
1997-09-07 07:04:48 +02:00
|
|
|
str++;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Terminate word string for caller */
|
|
|
|
ch = *str;
|
|
|
|
*str = '\0';
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Skip any whitespace */
|
|
|
|
while (isspace(ch))
|
|
|
|
ch = *(++str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/* end of string? */
|
2000-02-19 23:10:47 +01:00
|
|
|
if (ch == '\0')
|
1998-09-01 05:29:17 +02:00
|
|
|
return str;
|
2000-02-19 23:10:47 +01:00
|
|
|
/* delimiter? */
|
|
|
|
if (ch == ',')
|
1998-09-01 05:29:17 +02:00
|
|
|
return ++str;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Had better be '=', and caller must be expecting it */
|
|
|
|
if (val == NULL || ch != '=')
|
|
|
|
elog(ERROR, "Syntax error near \"%s\"", str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* '=': get the value */
|
|
|
|
str++;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* skip whitespace after '=' */
|
1997-09-07 07:04:48 +02:00
|
|
|
while (isspace(*str))
|
|
|
|
str++;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
if (*str == ',' || *str == '\0')
|
|
|
|
elog(ERROR, "Syntax error near \"=%s\"", str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* OK, at beginning of non-empty value */
|
|
|
|
*val = str;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Advance to end of word */
|
|
|
|
while (*str && !isspace(*str) && *str != ',')
|
1997-09-07 07:04:48 +02:00
|
|
|
str++;
|
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Terminate word string for caller */
|
|
|
|
ch = *str;
|
|
|
|
*str = '\0';
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* Skip any whitespace */
|
|
|
|
while (isspace(ch))
|
|
|
|
ch = *(++str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
/* end of string? */
|
|
|
|
if (ch == '\0')
|
|
|
|
return str;
|
|
|
|
/* delimiter? */
|
|
|
|
if (ch == ',')
|
1998-09-01 05:29:17 +02:00
|
|
|
return ++str;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
elog(ERROR, "Syntax error near \"%s\"", str);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
return str;
|
1997-06-02 13:00:57 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
/*
|
|
|
|
* Generic parse routine for boolean ON/OFF variables
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_boolean_var(char *value,
|
2000-02-15 21:49:31 +01:00
|
|
|
bool *variable, const char *varname, bool defaultval)
|
|
|
|
{
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
*variable = defaultval;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(value, "on") == 0)
|
|
|
|
*variable = true;
|
|
|
|
else if (strcasecmp(value, "off") == 0)
|
|
|
|
*variable = false;
|
|
|
|
else
|
|
|
|
elog(ERROR, "Bad value for %s (%s)", varname, value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_SEQSCAN
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_seqscan(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_seqscan,
|
|
|
|
"ENABLE_SEQSCAN", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_seqscan()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_SEQSCAN is %s",
|
|
|
|
enable_seqscan ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_seqscan()
|
|
|
|
{
|
|
|
|
enable_seqscan = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_INDEXSCAN
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_indexscan(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_indexscan,
|
|
|
|
"ENABLE_INDEXSCAN", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_indexscan()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_INDEXSCAN is %s",
|
|
|
|
enable_indexscan ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_indexscan()
|
|
|
|
{
|
|
|
|
enable_indexscan = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_TIDSCAN
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_tidscan(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_tidscan,
|
|
|
|
"ENABLE_TIDSCAN", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_tidscan()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_TIDSCAN is %s",
|
|
|
|
enable_tidscan ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_tidscan()
|
|
|
|
{
|
|
|
|
enable_tidscan = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_SORT
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_sort(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_sort,
|
|
|
|
"ENABLE_SORT", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_sort()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_SORT is %s",
|
|
|
|
enable_sort ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_sort()
|
|
|
|
{
|
|
|
|
enable_sort = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_NESTLOOP
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_nestloop(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_nestloop,
|
|
|
|
"ENABLE_NESTLOOP", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_nestloop()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_NESTLOOP is %s",
|
|
|
|
enable_nestloop ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_nestloop()
|
|
|
|
{
|
|
|
|
enable_nestloop = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_MERGEJOIN
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_mergejoin(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_mergejoin,
|
|
|
|
"ENABLE_MERGEJOIN", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_mergejoin()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_MERGEJOIN is %s",
|
|
|
|
enable_mergejoin ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_mergejoin()
|
|
|
|
{
|
|
|
|
enable_mergejoin = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ENABLE_HASHJOIN
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_enable_hashjoin(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &enable_hashjoin,
|
|
|
|
"ENABLE_HASHJOIN", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_enable_hashjoin()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "ENABLE_HASHJOIN is %s",
|
|
|
|
enable_hashjoin ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_enable_hashjoin()
|
|
|
|
{
|
|
|
|
enable_hashjoin = true;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* GEQO
|
|
|
|
*
|
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_geqo(char *value)
|
1997-04-29 06:38:58 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *tok,
|
2000-02-19 23:10:47 +01:00
|
|
|
*val,
|
|
|
|
*rest;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-11-07 07:43:16 +01:00
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_geqo();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
rest = get_token(&tok, &val, value);
|
2000-02-19 23:10:47 +01:00
|
|
|
|
|
|
|
/* expect one and only one item */
|
1997-09-07 07:04:48 +02:00
|
|
|
if (tok == NULL)
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Value undefined");
|
2000-02-19 23:10:47 +01:00
|
|
|
if (rest && *rest != '\0')
|
|
|
|
elog(ERROR, "Unable to parse '%s'", rest);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (strcasecmp(tok, "on") == 0)
|
|
|
|
{
|
2000-01-23 00:50:30 +01:00
|
|
|
int new_geqo_rels = GEQO_RELS;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (val != NULL)
|
|
|
|
{
|
2000-01-23 00:50:30 +01:00
|
|
|
new_geqo_rels = pg_atoi(val, sizeof(int), '\0');
|
|
|
|
if (new_geqo_rels <= 1)
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Bad value for # of relations (%s)", val);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-01-23 00:50:30 +01:00
|
|
|
enable_geqo = true;
|
|
|
|
geqo_rels = new_geqo_rels;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
else if (strcasecmp(tok, "off") == 0)
|
|
|
|
{
|
2000-02-19 23:10:47 +01:00
|
|
|
if (val != NULL)
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "%s does not allow a parameter", tok);
|
2000-01-23 00:50:30 +01:00
|
|
|
enable_geqo = false;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
else
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Bad value for GEQO (%s)", value);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1997-04-29 06:38:58 +02:00
|
|
|
}
|
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
1997-09-07 07:04:48 +02:00
|
|
|
show_geqo()
|
1997-04-29 06:38:58 +02:00
|
|
|
{
|
2000-01-23 00:50:30 +01:00
|
|
|
if (enable_geqo)
|
|
|
|
elog(NOTICE, "GEQO is ON beginning with %d relations", geqo_rels);
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
|
|
|
elog(NOTICE, "GEQO is OFF");
|
|
|
|
return TRUE;
|
1997-04-29 06:38:58 +02:00
|
|
|
}
|
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
1997-11-07 07:43:16 +01:00
|
|
|
reset_geqo(void)
|
1997-04-29 06:38:58 +02:00
|
|
|
{
|
|
|
|
#ifdef GEQO
|
2000-01-23 00:50:30 +01:00
|
|
|
enable_geqo = true;
|
1997-04-29 06:38:58 +02:00
|
|
|
#else
|
2000-01-23 00:50:30 +01:00
|
|
|
enable_geqo = false;
|
1997-04-29 06:38:58 +02:00
|
|
|
#endif
|
2000-01-23 00:50:30 +01:00
|
|
|
geqo_rels = GEQO_RELS;
|
1997-09-07 07:04:48 +02:00
|
|
|
return TRUE;
|
1997-04-29 06:38:58 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
2000-02-15 21:49:31 +01:00
|
|
|
* EFFECTIVE_CACHE_SIZE
|
1998-10-14 07:10:12 +02:00
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_effective_cache_size(char *value)
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-01-23 00:50:30 +01:00
|
|
|
float64 res;
|
1997-11-07 07:43:16 +01:00
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
reset_effective_cache_size();
|
1997-11-07 07:43:16 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-01-23 00:50:30 +01:00
|
|
|
res = float8in((char *) value);
|
2000-02-15 21:49:31 +01:00
|
|
|
effective_cache_size = *res;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
1998-10-26 02:00:13 +01:00
|
|
|
static bool
|
2000-02-15 21:49:31 +01:00
|
|
|
show_effective_cache_size()
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
elog(NOTICE, "EFFECTIVE_CACHE_SIZE is %g (%dK pages)",
|
|
|
|
effective_cache_size, BLCKSZ/1024);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1997-04-24 17:41:37 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool
|
|
|
|
reset_effective_cache_size()
|
|
|
|
{
|
|
|
|
effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;
|
1997-09-07 07:04:48 +02:00
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
/*
|
|
|
|
* RANDOM_PAGE_COST
|
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_random_page_cost(char *value)
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
float64 res;
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_random_page_cost();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = float8in((char *) value);
|
|
|
|
random_page_cost = *res;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_random_page_cost()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "RANDOM_PAGE_COST is %g", random_page_cost);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_random_page_cost()
|
|
|
|
{
|
|
|
|
random_page_cost = DEFAULT_RANDOM_PAGE_COST;
|
1997-09-07 07:04:48 +02:00
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
2000-02-15 21:49:31 +01:00
|
|
|
* CPU_TUPLE_COST
|
1998-10-14 07:10:12 +02:00
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_cpu_tuple_cost(char *value)
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-01-23 00:50:30 +01:00
|
|
|
float64 res;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-11-07 07:43:16 +01:00
|
|
|
if (value == NULL)
|
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
reset_cpu_tuple_cost();
|
1997-11-07 07:43:16 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-01-23 00:50:30 +01:00
|
|
|
res = float8in((char *) value);
|
2000-02-15 21:49:31 +01:00
|
|
|
cpu_tuple_cost = *res;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
1998-10-26 02:00:13 +01:00
|
|
|
static bool
|
2000-02-15 21:49:31 +01:00
|
|
|
show_cpu_tuple_cost()
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
elog(NOTICE, "CPU_TUPLE_COST is %g", cpu_tuple_cost);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1997-04-24 17:41:37 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
static bool
|
|
|
|
reset_cpu_tuple_cost()
|
|
|
|
{
|
|
|
|
cpu_tuple_cost = DEFAULT_CPU_TUPLE_COST;
|
1997-09-07 07:04:48 +02:00
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
/*
|
|
|
|
* CPU_INDEX_TUPLE_COST
|
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_cpu_index_tuple_cost(char *value)
|
1997-04-24 17:41:37 +02:00
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
float64 res;
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_cpu_index_tuple_cost();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = float8in((char *) value);
|
|
|
|
cpu_index_tuple_cost = *res;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_cpu_index_tuple_cost()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "CPU_INDEX_TUPLE_COST is %g", cpu_index_tuple_cost);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_cpu_index_tuple_cost()
|
|
|
|
{
|
|
|
|
cpu_index_tuple_cost = DEFAULT_CPU_INDEX_TUPLE_COST;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU_OPERATOR_COST
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_cpu_operator_cost(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
float64 res;
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_cpu_operator_cost();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = float8in((char *) value);
|
|
|
|
cpu_operator_cost = *res;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_cpu_operator_cost()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "CPU_OPERATOR_COST is %g", cpu_operator_cost);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_cpu_operator_cost()
|
|
|
|
{
|
|
|
|
cpu_operator_cost = DEFAULT_CPU_OPERATOR_COST;
|
1997-09-07 07:04:48 +02:00
|
|
|
return TRUE;
|
1997-04-24 17:41:37 +02:00
|
|
|
}
|
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
|
|
|
* DATE_STYLE
|
|
|
|
*
|
2000-02-19 23:10:47 +01:00
|
|
|
* NOTE: set_default_datestyle() is called during backend startup to check
|
|
|
|
* if the PGDATESTYLE environment variable is set. We want the env var
|
|
|
|
* to determine the value that "RESET DateStyle" will reset to!
|
1998-10-14 07:10:12 +02:00
|
|
|
*/
|
2000-02-19 23:10:47 +01:00
|
|
|
|
|
|
|
/* These get initialized from the "master" values in init/globals.c */
|
|
|
|
static int DefaultDateStyle;
|
|
|
|
static bool DefaultEuroDates;
|
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_date(char *value)
|
1997-06-02 13:00:57 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *tok;
|
|
|
|
int dcnt = 0,
|
|
|
|
ecnt = 0;
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-11-07 07:43:16 +01:00
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_date();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
while ((value = get_token(&tok, NULL, value)) != 0)
|
1997-06-02 13:00:57 +02:00
|
|
|
{
|
1997-04-17 15:50:57 +02:00
|
|
|
/* Ugh. Somebody ought to write a table driven version -- mjl */
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-12-05 00:17:13 +01:00
|
|
|
if (!strcasecmp(tok, "ISO"))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
DateStyle = USE_ISO_DATES;
|
1997-04-17 15:50:57 +02:00
|
|
|
dcnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-12-05 00:17:13 +01:00
|
|
|
else if (!strcasecmp(tok, "SQL"))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
DateStyle = USE_SQL_DATES;
|
1997-04-17 15:50:57 +02:00
|
|
|
dcnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-12-05 00:17:13 +01:00
|
|
|
else if (!strcasecmp(tok, "POSTGRES"))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
DateStyle = USE_POSTGRES_DATES;
|
1997-04-17 15:50:57 +02:00
|
|
|
dcnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-12-05 00:17:13 +01:00
|
|
|
else if (!strcasecmp(tok, "GERMAN"))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1997-12-05 00:17:13 +01:00
|
|
|
DateStyle = USE_GERMAN_DATES;
|
|
|
|
dcnt++;
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
EuroDates = TRUE;
|
1998-02-26 05:46:47 +01:00
|
|
|
if ((ecnt > 0) && (!EuroDates))
|
|
|
|
ecnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-12-05 00:17:13 +01:00
|
|
|
else if (!strncasecmp(tok, "EURO", 4))
|
|
|
|
{
|
|
|
|
EuroDates = TRUE;
|
1998-02-26 05:46:47 +01:00
|
|
|
if ((dcnt <= 0) || (DateStyle != USE_GERMAN_DATES))
|
|
|
|
ecnt++;
|
1997-12-05 00:17:13 +01:00
|
|
|
}
|
|
|
|
else if ((!strcasecmp(tok, "US"))
|
|
|
|
|| (!strncasecmp(tok, "NONEURO", 7)))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
EuroDates = FALSE;
|
1998-02-26 05:46:47 +01:00
|
|
|
if ((dcnt <= 0) || (DateStyle == USE_GERMAN_DATES))
|
|
|
|
ecnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-12-05 00:17:13 +01:00
|
|
|
else if (!strcasecmp(tok, "DEFAULT"))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2000-02-19 23:10:47 +01:00
|
|
|
DateStyle = DefaultDateStyle;
|
|
|
|
EuroDates = DefaultEuroDates;
|
1997-04-17 15:50:57 +02:00
|
|
|
ecnt++;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-04-17 15:50:57 +02:00
|
|
|
else
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Bad value for date style (%s)", tok);
|
1997-06-02 13:00:57 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (dcnt > 1 || ecnt > 1)
|
1997-04-17 15:50:57 +02:00
|
|
|
elog(NOTICE, "Conflicting settings for date");
|
1997-06-02 13:00:57 +02:00
|
|
|
|
1997-04-17 15:50:57 +02:00
|
|
|
return TRUE;
|
1997-06-02 13:00:57 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
1997-09-07 07:04:48 +02:00
|
|
|
show_date()
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char buf[64];
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
strcpy(buf, "DateStyle is ");
|
|
|
|
switch (DateStyle)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
case USE_ISO_DATES:
|
|
|
|
strcat(buf, "ISO");
|
|
|
|
break;
|
|
|
|
case USE_SQL_DATES:
|
|
|
|
strcat(buf, "SQL");
|
|
|
|
break;
|
1997-12-05 00:17:13 +01:00
|
|
|
case USE_GERMAN_DATES:
|
|
|
|
strcat(buf, "German");
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
|
|
|
strcat(buf, "Postgres");
|
|
|
|
break;
|
1997-05-16 09:24:13 +02:00
|
|
|
};
|
1997-09-07 07:04:48 +02:00
|
|
|
strcat(buf, " with ");
|
|
|
|
strcat(buf, ((EuroDates) ? "European" : "US (NonEuropean)"));
|
|
|
|
strcat(buf, " conventions");
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
|
|
|
|
elog(NOTICE, buf, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1998-10-26 02:00:13 +01:00
|
|
|
static bool
|
1997-09-07 07:04:48 +02:00
|
|
|
reset_date()
|
|
|
|
{
|
2000-02-19 23:10:47 +01:00
|
|
|
DateStyle = DefaultDateStyle;
|
|
|
|
EuroDates = DefaultEuroDates;
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
void
|
|
|
|
set_default_datestyle(void)
|
|
|
|
{
|
|
|
|
char *DBDate;
|
|
|
|
|
|
|
|
/* Initialize from compile-time defaults in init/globals.c.
|
|
|
|
* NB: this is a necessary step; consider PGDATESTYLE="DEFAULT".
|
|
|
|
*/
|
|
|
|
DefaultDateStyle = DateStyle;
|
|
|
|
DefaultEuroDates = EuroDates;
|
|
|
|
|
|
|
|
/* If the environment var is set, override compiled-in values */
|
|
|
|
DBDate = getenv("PGDATESTYLE");
|
|
|
|
if (DBDate == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Make a modifiable copy --- overwriting the env var doesn't seem
|
|
|
|
* like a good idea, even though we currently won't look at it again.
|
|
|
|
* Note that we cannot use palloc at this early stage of initialization.
|
|
|
|
*/
|
|
|
|
DBDate = strdup(DBDate);
|
|
|
|
|
|
|
|
/* Parse desired setting into DateStyle/EuroDates */
|
|
|
|
parse_date(DBDate);
|
|
|
|
|
|
|
|
free(DBDate);
|
|
|
|
|
|
|
|
/* And make it the default for future RESETs */
|
|
|
|
DefaultDateStyle = DateStyle;
|
|
|
|
DefaultEuroDates = EuroDates;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-10 16:24:56 +01:00
|
|
|
/* Timezone support
|
|
|
|
* Working storage for strings is allocated with an arbitrary size of 64 bytes.
|
|
|
|
*/
|
|
|
|
|
1997-11-07 07:43:16 +01:00
|
|
|
static char *defaultTZ = NULL;
|
1997-11-10 16:24:56 +01:00
|
|
|
static char TZvalue[64];
|
|
|
|
static char tzbuf[64];
|
1997-11-07 07:43:16 +01:00
|
|
|
|
1998-10-14 07:10:12 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* TIMEZONE
|
|
|
|
*
|
|
|
|
*/
|
1997-11-10 16:37:15 +01:00
|
|
|
/* parse_timezone()
|
|
|
|
* Handle SET TIME ZONE...
|
|
|
|
* Try to save existing TZ environment variable for later use in RESET TIME ZONE.
|
|
|
|
* - thomas 1997-11-10
|
|
|
|
*/
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_timezone(char *value)
|
1997-10-30 17:52:11 +01:00
|
|
|
{
|
|
|
|
char *tok;
|
|
|
|
|
1997-11-07 07:43:16 +01:00
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_timezone();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-10-30 17:52:11 +01:00
|
|
|
while ((value = get_token(&tok, NULL, value)) != 0)
|
|
|
|
{
|
1997-11-10 16:24:56 +01:00
|
|
|
/* Not yet tried to save original value from environment? */
|
|
|
|
if (defaultTZ == NULL)
|
There's a patch attached to fix gcc 2.8.x warnings, except for the
yyerror ones from bison. It also includes a few 'enhancements' to
the C programming style (which are, of course, personal).
The other patch removes the compilation of backend/lib/qsort.c, as
qsort() is a standard function in stdlib.h and can be used any
where else (and it is). It was only used in
backend/optimizer/geqo/geqo_pool.c, backend/optimizer/path/predmig.c,
and backend/storage/page/bufpage.c
> > Some or all of these changes might not be appropriate for v6.3,
since we > > are in beta testing and since they do not affect the
current functionality. > > For those cases, how about submitting
patches based on the final v6.3 > > release?
There's more to come. Please review these patches. I ran the
regression tests and they only failed where this was expected
(random, geo, etc).
Cheers,
Jeroen
1998-03-30 18:47:35 +02:00
|
|
|
{
|
1997-11-10 16:24:56 +01:00
|
|
|
/* found something? then save it for later */
|
1998-02-03 17:06:49 +01:00
|
|
|
if ((defaultTZ = getenv("TZ")) != NULL)
|
|
|
|
strcpy(TZvalue, defaultTZ);
|
|
|
|
|
There's a patch attached to fix gcc 2.8.x warnings, except for the
yyerror ones from bison. It also includes a few 'enhancements' to
the C programming style (which are, of course, personal).
The other patch removes the compilation of backend/lib/qsort.c, as
qsort() is a standard function in stdlib.h and can be used any
where else (and it is). It was only used in
backend/optimizer/geqo/geqo_pool.c, backend/optimizer/path/predmig.c,
and backend/storage/page/bufpage.c
> > Some or all of these changes might not be appropriate for v6.3,
since we > > are in beta testing and since they do not affect the
current functionality. > > For those cases, how about submitting
patches based on the final v6.3 > > release?
There's more to come. Please review these patches. I ran the
regression tests and they only failed where this was expected
(random, geo, etc).
Cheers,
Jeroen
1998-03-30 18:47:35 +02:00
|
|
|
/* found nothing so mark with an invalid pointer */
|
1997-11-07 07:43:16 +01:00
|
|
|
else
|
1997-11-10 16:24:56 +01:00
|
|
|
defaultTZ = (char *) -1;
|
There's a patch attached to fix gcc 2.8.x warnings, except for the
yyerror ones from bison. It also includes a few 'enhancements' to
the C programming style (which are, of course, personal).
The other patch removes the compilation of backend/lib/qsort.c, as
qsort() is a standard function in stdlib.h and can be used any
where else (and it is). It was only used in
backend/optimizer/geqo/geqo_pool.c, backend/optimizer/path/predmig.c,
and backend/storage/page/bufpage.c
> > Some or all of these changes might not be appropriate for v6.3,
since we > > are in beta testing and since they do not affect the
current functionality. > > For those cases, how about submitting
patches based on the final v6.3 > > release?
There's more to come. Please review these patches. I ran the
regression tests and they only failed where this was expected
(random, geo, etc).
Cheers,
Jeroen
1998-03-30 18:47:35 +02:00
|
|
|
}
|
1997-11-07 07:43:16 +01:00
|
|
|
|
1997-11-10 16:24:56 +01:00
|
|
|
strcpy(tzbuf, "TZ=");
|
|
|
|
strcat(tzbuf, tok);
|
|
|
|
if (putenv(tzbuf) != 0)
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Unable to set TZ environment variable to %s", tok);
|
1997-11-10 16:24:56 +01:00
|
|
|
|
1997-10-30 17:52:11 +01:00
|
|
|
tzset();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1998-02-26 05:46:47 +01:00
|
|
|
} /* parse_timezone() */
|
1997-10-30 17:52:11 +01:00
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
static bool
|
1997-10-30 17:52:11 +01:00
|
|
|
show_timezone()
|
|
|
|
{
|
|
|
|
char *tz;
|
|
|
|
|
|
|
|
tz = getenv("TZ");
|
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
elog(NOTICE, "Time zone is %s", ((tz != NULL) ? tz : "unknown"));
|
1997-10-30 17:52:11 +01:00
|
|
|
|
|
|
|
return TRUE;
|
1998-02-26 05:46:47 +01:00
|
|
|
} /* show_timezone() */
|
1997-10-30 17:52:11 +01:00
|
|
|
|
1997-11-10 16:24:56 +01:00
|
|
|
/* reset_timezone()
|
|
|
|
* Set TZ environment variable to original value.
|
|
|
|
* Note that if TZ was originally not set, TZ should be cleared.
|
|
|
|
* unsetenv() works fine, but is BSD, not POSIX, and is not available
|
|
|
|
* under Solaris, among others. Apparently putenv() called as below
|
|
|
|
* clears the process-specific environment variables.
|
|
|
|
* Other reasonable arguments to putenv() (e.g. "TZ=", "TZ", "") result
|
|
|
|
* in a core dump (under Linux anyway).
|
1998-02-03 17:06:49 +01:00
|
|
|
* - thomas 1998-01-26
|
1997-11-10 16:24:56 +01:00
|
|
|
*/
|
1998-10-26 02:00:13 +01:00
|
|
|
static bool
|
1997-10-30 17:52:11 +01:00
|
|
|
reset_timezone()
|
|
|
|
{
|
1998-02-03 17:06:49 +01:00
|
|
|
/* no time zone has been set in this session? */
|
|
|
|
if (defaultTZ == NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* time zone was set and original explicit time zone available? */
|
|
|
|
else if (defaultTZ != (char *) -1)
|
1997-11-07 07:43:16 +01:00
|
|
|
{
|
1997-11-10 16:24:56 +01:00
|
|
|
strcpy(tzbuf, "TZ=");
|
|
|
|
strcat(tzbuf, TZvalue);
|
|
|
|
if (putenv(tzbuf) != 0)
|
1998-01-05 17:40:20 +01:00
|
|
|
elog(ERROR, "Unable to set TZ environment variable to %s", TZvalue);
|
1998-02-03 17:06:49 +01:00
|
|
|
tzset();
|
1997-11-07 07:43:16 +01:00
|
|
|
}
|
1998-02-03 17:06:49 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
/*
|
|
|
|
* otherwise, time zone was set but no original explicit time zone
|
|
|
|
* available
|
|
|
|
*/
|
1997-11-07 07:43:16 +01:00
|
|
|
else
|
|
|
|
{
|
1997-11-10 16:24:56 +01:00
|
|
|
strcpy(tzbuf, "=");
|
|
|
|
if (putenv(tzbuf) != 0)
|
2000-01-15 03:59:43 +01:00
|
|
|
elog(ERROR, "Unable to clear TZ environment variable");
|
1998-02-03 17:06:49 +01:00
|
|
|
tzset();
|
1997-11-07 07:43:16 +01:00
|
|
|
}
|
1997-10-30 17:52:11 +01:00
|
|
|
|
|
|
|
return TRUE;
|
1998-02-26 05:46:47 +01:00
|
|
|
} /* reset_timezone() */
|
1997-10-30 17:52:11 +01:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
/*-----------------------------------------------------------------------
|
|
|
|
KSQO code will one day be unnecessary when the optimizer makes use of
|
|
|
|
indexes when multiple ORs are specified in the where clause.
|
|
|
|
See optimizer/prep/prepkeyset.c for more on this.
|
|
|
|
daveh@insightdist.com 6/16/98
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_ksqo(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
return parse_boolean_var(value, &_use_keyset_query_optimizer,
|
|
|
|
"KSQO", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_ksqo()
|
|
|
|
{
|
|
|
|
elog(NOTICE, "KSQO is %s",
|
|
|
|
_use_keyset_query_optimizer ? "ON" : "OFF");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_ksqo()
|
|
|
|
{
|
|
|
|
_use_keyset_query_optimizer = false;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SET TRANSACTION */
|
|
|
|
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_XactIsoLevel(char *value)
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
{
|
|
|
|
reset_XactIsoLevel();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SerializableSnapshot != NULL)
|
|
|
|
{
|
|
|
|
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strcasecmp(value, "SERIALIZABLE") == 0)
|
|
|
|
XactIsoLevel = XACT_SERIALIZABLE;
|
|
|
|
else if (strcasecmp(value, "COMMITTED") == 0)
|
|
|
|
XactIsoLevel = XACT_READ_COMMITTED;
|
|
|
|
else
|
|
|
|
elog(ERROR, "Bad TRANSACTION ISOLATION LEVEL (%s)", value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_XactIsoLevel()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (XactIsoLevel == XACT_SERIALIZABLE)
|
|
|
|
elog(NOTICE, "TRANSACTION ISOLATION LEVEL is SERIALIZABLE");
|
|
|
|
else
|
|
|
|
elog(NOTICE, "TRANSACTION ISOLATION LEVEL is READ COMMITTED");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_XactIsoLevel()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (SerializableSnapshot != NULL)
|
|
|
|
{
|
|
|
|
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
XactIsoLevel = DefaultXactIsoLevel;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-09-27 22:27:32 +02:00
|
|
|
/*
|
|
|
|
* Pg_options
|
|
|
|
*/
|
|
|
|
static bool
|
2000-02-19 23:10:47 +01:00
|
|
|
parse_pg_options(char *value)
|
1999-09-27 22:27:32 +02:00
|
|
|
{
|
|
|
|
if (!superuser()) {
|
|
|
|
elog(ERROR, "Only users with superuser privilege can set pg_options");
|
|
|
|
}
|
|
|
|
parse_options((char *) value, TRUE);
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
show_pg_options(void)
|
|
|
|
{
|
|
|
|
show_options();
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
reset_pg_options(void)
|
|
|
|
{
|
|
|
|
if (!superuser()) {
|
|
|
|
elog(ERROR, "Only users with superuser privilege can set pg_options");
|
|
|
|
}
|
|
|
|
read_pg_options(0);
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
|
1997-04-17 15:50:57 +02:00
|
|
|
/*-----------------------------------------------------------------------*/
|
1998-10-14 07:10:12 +02:00
|
|
|
|
2000-02-19 23:10:47 +01:00
|
|
|
static struct VariableParsers
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
const char *name;
|
2000-02-19 23:10:47 +01:00
|
|
|
bool (*parser) (char *);
|
1997-09-08 23:56:23 +02:00
|
|
|
bool (*show) ();
|
|
|
|
bool (*reset) ();
|
1997-09-08 04:41:22 +02:00
|
|
|
} VariableParsers[] =
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
{
|
|
|
|
"datestyle", parse_date, show_date, reset_date
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"timezone", parse_timezone, show_timezone, reset_timezone
|
|
|
|
},
|
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
"effective_cache_size", parse_effective_cache_size,
|
|
|
|
show_effective_cache_size, reset_effective_cache_size
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"random_page_cost", parse_random_page_cost,
|
|
|
|
show_random_page_cost, reset_random_page_cost
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cpu_tuple_cost", parse_cpu_tuple_cost,
|
|
|
|
show_cpu_tuple_cost, reset_cpu_tuple_cost
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cpu_index_tuple_cost", parse_cpu_index_tuple_cost,
|
|
|
|
show_cpu_index_tuple_cost, reset_cpu_index_tuple_cost
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cpu_operator_cost", parse_cpu_operator_cost,
|
|
|
|
show_cpu_operator_cost, reset_cpu_operator_cost
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_seqscan", parse_enable_seqscan,
|
|
|
|
show_enable_seqscan, reset_enable_seqscan
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_indexscan", parse_enable_indexscan,
|
|
|
|
show_enable_indexscan, reset_enable_indexscan
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_tidscan", parse_enable_tidscan,
|
|
|
|
show_enable_tidscan, reset_enable_tidscan
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_sort", parse_enable_sort,
|
|
|
|
show_enable_sort, reset_enable_sort
|
1998-02-26 05:46:47 +01:00
|
|
|
},
|
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
"enable_nestloop", parse_enable_nestloop,
|
|
|
|
show_enable_nestloop, reset_enable_nestloop
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_mergejoin", parse_enable_mergejoin,
|
|
|
|
show_enable_mergejoin, reset_enable_mergejoin
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enable_hashjoin", parse_enable_hashjoin,
|
|
|
|
show_enable_hashjoin, reset_enable_hashjoin
|
1998-02-26 05:46:47 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"geqo", parse_geqo, show_geqo, reset_geqo
|
|
|
|
},
|
1998-07-18 20:34:34 +02:00
|
|
|
#ifdef MULTIBYTE
|
1998-06-16 09:29:54 +02:00
|
|
|
{
|
|
|
|
"client_encoding", parse_client_encoding, show_client_encoding, reset_client_encoding
|
|
|
|
},
|
1998-09-01 06:40:42 +02:00
|
|
|
{
|
1998-07-24 05:32:46 +02:00
|
|
|
"server_encoding", parse_server_encoding, show_server_encoding, reset_server_encoding
|
|
|
|
},
|
1998-06-16 09:29:54 +02:00
|
|
|
#endif
|
1998-09-03 04:34:35 +02:00
|
|
|
{
|
|
|
|
"ksqo", parse_ksqo, show_ksqo, reset_ksqo
|
|
|
|
},
|
1998-12-18 10:10:39 +01:00
|
|
|
{
|
|
|
|
"XactIsoLevel", parse_XactIsoLevel, show_XactIsoLevel, reset_XactIsoLevel
|
|
|
|
},
|
1999-09-27 22:27:32 +02:00
|
|
|
{
|
|
|
|
"pg_options", parse_pg_options, show_pg_options, reset_pg_options
|
|
|
|
},
|
1998-02-26 05:46:47 +01:00
|
|
|
{
|
|
|
|
NULL, NULL, NULL, NULL
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
};
|
1997-04-17 15:50:57 +02:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
1997-09-07 07:04:48 +02:00
|
|
|
bool
|
|
|
|
SetPGVariable(const char *name, const char *value)
|
|
|
|
{
|
1997-04-17 15:50:57 +02:00
|
|
|
struct VariableParsers *vp;
|
2000-02-19 23:10:47 +01:00
|
|
|
char *val;
|
|
|
|
|
|
|
|
/* Make a modifiable copy for convenience of get_token */
|
|
|
|
val = pstrdup(value);
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
for (vp = VariableParsers; vp->name; vp++)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(vp->name, name))
|
2000-02-19 23:10:47 +01:00
|
|
|
return (vp->parser) (val);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
elog(NOTICE, "Unrecognized variable %s", name);
|
1997-04-02 20:24:52 +02:00
|
|
|
|
1997-03-25 10:44:00 +01:00
|
|
|
return TRUE;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-03-25 10:44:00 +01:00
|
|
|
|
1997-04-17 15:50:57 +02:00
|
|
|
/*-----------------------------------------------------------------------*/
|
1997-09-07 07:04:48 +02:00
|
|
|
bool
|
|
|
|
GetPGVariable(const char *name)
|
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
struct VariableParsers *vp;
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
for (vp = VariableParsers; vp->name; vp++)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(vp->name, name))
|
|
|
|
return (vp->show) ();
|
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
elog(NOTICE, "Unrecognized variable %s", name);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
|
1997-04-17 15:50:57 +02:00
|
|
|
/*-----------------------------------------------------------------------*/
|
1997-09-07 07:04:48 +02:00
|
|
|
bool
|
|
|
|
ResetPGVariable(const char *name)
|
|
|
|
{
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
struct VariableParsers *vp;
|
1997-06-20 19:17:03 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
for (vp = VariableParsers; vp->name; vp++)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(vp->name, name))
|
|
|
|
return (vp->reset) ();
|
|
|
|
}
|
1997-06-20 19:17:03 +02:00
|
|
|
|
To: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: Re: [PATCHES] SET DateStyle patches
On Tue, 22 Apr 1997, Thomas Lockhart wrote:
> Some more patches! These (try to) finish implementing SET variable TO value
> for "DateStyle" (changed the name from simply "date" to be more descriptive).
> This is based on code from Martin and Bruce (?), which was easy to modify.
> The syntax is
>
> SET DateStyle TO 'iso'
> SET DateStyle TO 'postgres'
> SET DateStyle TO 'sql'
> SET DateStyle TO 'european'
> SET DateStyle TO 'noneuropean'
> SET DateStyle TO 'us' (same as "noneuropean")
> SET DateStyle TO 'default' (current same as "postgres,us")
>
> ("european" is just compared for the first 4 characters, and "noneuropean"
> is compared for the first 7 to allow less typing).
>
> Multiple arguments are allowed, so SET datestyle TO 'sql,euro' is valid.
>
> My mods also try to implement "SHOW variable" and "RESET variable", but
> that part just core dumps at the moment. I would guess that my errors
> are obvious to someone who knows what they are doing with the parser stuff,
> so if someone (Bruce and/or Martin??) could have it do the right thing
> we will have a more complete set of what we need.
>
> Also, I would like to have a floating point precision global variable to
> implement "SET precision TO 10" and perhaps "SET precision TO 10,2" for
> float8 and float4, but I don't know how to do that for integer types rather
> than strings. If someone is fixing the SHOW and RESET code, perhaps they can
> add some hooks for me to do the floats while they are at it.
>
> I've left some remnants of variable structures in the source code which
> I did not use in the interests of getting something working for v6.1.
> We'll have time to clean things up for the next release...
1997-04-23 05:18:27 +02:00
|
|
|
elog(NOTICE, "Unrecognized variable %s", name);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|