Repair problem identified by Olivier Prenant: ALTER DATABASE SET search_path

should not be too eager to reject paths involving unknown schemas, since
it can't really tell whether the schemas exist in the target database.
(Also, when reading pg_dumpall output, it could be that the schemas
don't exist yet, but eventually will.)  ALTER USER SET has a similar issue.
So, reduce the normal ERROR to a NOTICE when checking search_path values
for these commands.  Supporting this requires changing the API for GUC
assign_hook functions, which causes the patch to touch a lot of places,
but the changes are conceptually trivial.
This commit is contained in:
Tom Lane 2004-01-19 19:04:40 +00:00
parent 239760209b
commit 9bd681a522
17 changed files with 183 additions and 144 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.131 2004/01/06 22:22:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.132 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3523,7 +3523,7 @@ xlog_outrec(char *buf, XLogRecord *record)
* GUC support * GUC support
*/ */
const char * const char *
assign_xlog_sync_method(const char *method, bool doit, bool interactive) assign_xlog_sync_method(const char *method, bool doit, GucSource source)
{ {
int new_sync_method; int new_sync_method;
int new_sync_bit; int new_sync_bit;

View File

@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.61 2003/12/29 21:33:09 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.62 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -39,6 +39,7 @@
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/catcache.h" #include "utils/catcache.h"
#include "utils/guc.h"
#include "utils/inval.h" #include "utils/inval.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/memutils.h" #include "utils/memutils.h"
@ -1773,7 +1774,7 @@ RemoveTempRelationsCallback(int code, Datum arg)
/* assign_hook: validate new search_path, do extra actions as needed */ /* assign_hook: validate new search_path, do extra actions as needed */
const char * const char *
assign_search_path(const char *newval, bool doit, bool interactive) assign_search_path(const char *newval, bool doit, GucSource source)
{ {
char *rawname; char *rawname;
List *namelist; List *namelist;
@ -1795,13 +1796,19 @@ assign_search_path(const char *newval, bool doit, bool interactive)
* If we aren't inside a transaction, we cannot do database access so * If we aren't inside a transaction, we cannot do database access so
* cannot verify the individual names. Must accept the list on faith. * cannot verify the individual names. Must accept the list on faith.
*/ */
if (interactive && IsTransactionState()) if (source >= PGC_S_INTERACTIVE && IsTransactionState())
{ {
/* /*
* Verify that all the names are either valid namespace names or * Verify that all the names are either valid namespace names or
* "$user". We do not require $user to correspond to a valid * "$user". We do not require $user to correspond to a valid
* namespace. We do not check for USAGE rights, either; should * namespace. We do not check for USAGE rights, either; should
* we? * we?
*
* When source == PGC_S_TEST, we are checking the argument of an
* ALTER DATABASE SET or ALTER USER SET command. It could be that
* the intended use of the search path is for some other database,
* so we should not error out if it mentions schemas not present
* in the current database. We reduce the message to NOTICE instead.
*/ */
foreach(l, namelist) foreach(l, namelist)
{ {
@ -1812,7 +1819,7 @@ assign_search_path(const char *newval, bool doit, bool interactive)
if (!SearchSysCacheExists(NAMESPACENAME, if (!SearchSysCacheExists(NAMESPACENAME,
CStringGetDatum(curname), CStringGetDatum(curname),
0, 0, 0)) 0, 0, 0))
ereport(ERROR, ereport((source == PGC_S_TEST) ? NOTICE : ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA), (errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", curname))); errmsg("schema \"%s\" does not exist", curname)));
} }

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.92 2003/12/21 04:34:35 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.93 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -48,7 +48,7 @@ extern char *tzname[];
* assign_datestyle: GUC assign_hook for datestyle * assign_datestyle: GUC assign_hook for datestyle
*/ */
const char * const char *
assign_datestyle(const char *value, bool doit, bool interactive) assign_datestyle(const char *value, bool doit, GucSource source)
{ {
int newDateStyle = DateStyle; int newDateStyle = DateStyle;
int newDateOrder = DateOrder; int newDateOrder = DateOrder;
@ -69,7 +69,7 @@ assign_datestyle(const char *value, bool doit, bool interactive)
/* syntax error in list */ /* syntax error in list */
pfree(rawstring); pfree(rawstring);
freeList(elemlist); freeList(elemlist);
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid list syntax for parameter \"datestyle\""))); errmsg("invalid list syntax for parameter \"datestyle\"")));
@ -137,7 +137,7 @@ assign_datestyle(const char *value, bool doit, bool interactive)
const char *subval; const char *subval;
subval = assign_datestyle(GetConfigOptionResetString("datestyle"), subval = assign_datestyle(GetConfigOptionResetString("datestyle"),
true, interactive); true, source);
if (scnt == 0) if (scnt == 0)
newDateStyle = DateStyle; newDateStyle = DateStyle;
if (ocnt == 0) if (ocnt == 0)
@ -155,7 +155,7 @@ assign_datestyle(const char *value, bool doit, bool interactive)
} }
else else
{ {
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized \"datestyle\" key word: \"%s\"", errmsg("unrecognized \"datestyle\" key word: \"%s\"",
@ -173,7 +173,7 @@ assign_datestyle(const char *value, bool doit, bool interactive)
if (!ok) if (!ok)
{ {
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("conflicting \"datestyle\" specifications"))); errmsg("conflicting \"datestyle\" specifications")));
@ -386,7 +386,7 @@ tz_acceptable(void)
* assign_timezone: GUC assign_hook for timezone * assign_timezone: GUC assign_hook for timezone
*/ */
const char * const char *
assign_timezone(const char *value, bool doit, bool interactive) assign_timezone(const char *value, bool doit, GucSource source)
{ {
char *result; char *result;
char *endptr; char *endptr;
@ -444,7 +444,7 @@ assign_timezone(const char *value, bool doit, bool interactive)
pfree(val); pfree(val);
if (interval->month != 0) if (interval->month != 0)
{ {
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid interval value for time zone: month not allowed"))); errmsg("invalid interval value for time zone: month not allowed")));
@ -552,7 +552,7 @@ assign_timezone(const char *value, bool doit, bool interactive)
/* Complain if it was bad */ /* Complain if it was bad */
if (!known) if (!known)
{ {
ereport(interactive ? ERROR : LOG, ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized time zone name: \"%s\"", errmsg("unrecognized time zone name: \"%s\"",
value))); value)));
@ -560,7 +560,7 @@ assign_timezone(const char *value, bool doit, bool interactive)
} }
if (!acceptable) if (!acceptable)
{ {
ereport(interactive ? ERROR : LOG, ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("time zone \"%s\" appears to use leap seconds", errmsg("time zone \"%s\" appears to use leap seconds",
value), value),
@ -628,9 +628,9 @@ show_timezone(void)
*/ */
const char * const char *
assign_XactIsoLevel(const char *value, bool doit, bool interactive) assign_XactIsoLevel(const char *value, bool doit, GucSource source)
{ {
if (doit && interactive && SerializableSnapshot != NULL) if (doit && source >= PGC_S_INTERACTIVE && SerializableSnapshot != NULL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query"))); errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
@ -690,10 +690,10 @@ show_XactIsoLevel(void)
*/ */
bool bool
assign_random_seed(double value, bool doit, bool interactive) assign_random_seed(double value, bool doit, GucSource source)
{ {
/* Can't really roll back on error, so ignore non-interactive setting */ /* Can't really roll back on error, so ignore non-interactive setting */
if (doit && interactive) if (doit && source >= PGC_S_INTERACTIVE)
DirectFunctionCall1(setseed, Float8GetDatum(value)); DirectFunctionCall1(setseed, Float8GetDatum(value));
return true; return true;
} }
@ -710,7 +710,7 @@ show_random_seed(void)
*/ */
const char * const char *
assign_client_encoding(const char *value, bool doit, bool interactive) assign_client_encoding(const char *value, bool doit, GucSource source)
{ {
int encoding; int encoding;
@ -726,7 +726,7 @@ assign_client_encoding(const char *value, bool doit, bool interactive)
*/ */
if (SetClientEncoding(encoding, doit) < 0) if (SetClientEncoding(encoding, doit) < 0)
{ {
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conversion between %s and %s is not supported", errmsg("conversion between %s and %s is not supported",
@ -748,7 +748,7 @@ assign_client_encoding(const char *value, bool doit, bool interactive)
* because of the NAMEDATALEN limit on names. * because of the NAMEDATALEN limit on names.
*/ */
const char * const char *
assign_session_authorization(const char *value, bool doit, bool interactive) assign_session_authorization(const char *value, bool doit, GucSource source)
{ {
AclId usesysid = 0; AclId usesysid = 0;
bool is_superuser = false; bool is_superuser = false;
@ -791,7 +791,7 @@ assign_session_authorization(const char *value, bool doit, bool interactive)
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(userTup)) if (!HeapTupleIsValid(userTup))
{ {
if (interactive) if (source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("user \"%s\" does not exist", value))); errmsg("user \"%s\" does not exist", value)));

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.123 2003/12/21 04:34:35 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.124 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3919,7 +3919,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
/* GUC assign_hook for australian_timezones */ /* GUC assign_hook for australian_timezones */
bool bool
ClearDateCache(bool newval, bool doit, bool interactive) ClearDateCache(bool newval, bool doit, GucSource source)
{ {
int i; int i;

View File

@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group * Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.24 2003/11/29 19:51:59 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.25 2004/01/19 19:04:40 tgl Exp $
* *
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
*/ */
@ -73,7 +73,7 @@ char *locale_time;
* valid. (See explanation at the top of this file.) * valid. (See explanation at the top of this file.)
*/ */
static const char * static const char *
locale_xxx_assign(int category, const char *value, bool doit, bool interactive) locale_xxx_assign(int category, const char *value, bool doit, GucSource source)
{ {
char *save; char *save;
@ -99,21 +99,21 @@ locale_xxx_assign(int category, const char *value, bool doit, bool interactive)
const char * const char *
locale_monetary_assign(const char *value, bool doit, bool interactive) locale_monetary_assign(const char *value, bool doit, GucSource source)
{ {
return locale_xxx_assign(LC_MONETARY, value, doit, interactive); return locale_xxx_assign(LC_MONETARY, value, doit, source);
} }
const char * const char *
locale_numeric_assign(const char *value, bool doit, bool interactive) locale_numeric_assign(const char *value, bool doit, GucSource source)
{ {
return locale_xxx_assign(LC_NUMERIC, value, doit, interactive); return locale_xxx_assign(LC_NUMERIC, value, doit, source);
} }
const char * const char *
locale_time_assign(const char *value, bool doit, bool interactive) locale_time_assign(const char *value, bool doit, GucSource source)
{ {
return locale_xxx_assign(LC_TIME, value, doit, interactive); return locale_xxx_assign(LC_TIME, value, doit, source);
} }
@ -121,7 +121,7 @@ locale_time_assign(const char *value, bool doit, bool interactive)
* We allow LC_MESSAGES to actually be set globally. * We allow LC_MESSAGES to actually be set globally.
*/ */
const char * const char *
locale_messages_assign(const char *value, bool doit, bool interactive) locale_messages_assign(const char *value, bool doit, GucSource source)
{ {
/* /*
* LC_MESSAGES category does not exist everywhere, but accept it * LC_MESSAGES category does not exist everywhere, but accept it
@ -134,7 +134,7 @@ locale_messages_assign(const char *value, bool doit, bool interactive)
return NULL; return NULL;
} }
else else
value = locale_xxx_assign(LC_MESSAGES, value, false, interactive); value = locale_xxx_assign(LC_MESSAGES, value, false, source);
#endif #endif
return value; return value;
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.50 2003/11/29 19:51:59 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.51 2004/01/19 19:04:40 tgl Exp $
* *
* Alistair Crooks added the code for the regex caching * Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance * agc - cached the regular expressions used - there's a good chance
@ -32,6 +32,7 @@
#include "regex/regex.h" #include "regex/regex.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/guc.h"
/* GUC-settable flavor parameter */ /* GUC-settable flavor parameter */
@ -229,7 +230,7 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
*/ */
const char * const char *
assign_regex_flavor(const char *value, assign_regex_flavor(const char *value,
bool doit, bool interactive) bool doit, GucSource source)
{ {
if (strcasecmp(value, "advanced") == 0) if (strcasecmp(value, "advanced") == 0)
{ {

View File

@ -1,4 +1,4 @@
$PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.3 2003/11/29 19:52:03 pgsql Exp $ $PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.4 2004/01/19 19:04:40 tgl Exp $
GUC IMPLEMENTATION NOTES GUC IMPLEMENTATION NOTES
@ -19,29 +19,30 @@ to change when a GUC variable is set. Show hooks are used to modify
the default SHOW display for a variable. the default SHOW display for a variable.
If an assign_hook is provided, it points to a function of the signature If an assign_hook is provided, it points to a function of the signature
bool assign_hook(newvalue, bool doit, bool interactive) bool assign_hook(newvalue, bool doit, GucSource source)
where the type of 'newvalue' matches the kind of variable. This function where the type of "newvalue" matches the kind of variable. This function
is called immediately before actually setting the variable's value (so it is called immediately before actually setting the variable's value (so it
can look at the actual variable to determine the old value). If the can look at the actual variable to determine the old value). If the
function returns "true" then the assignment is completed; if it returns function returns "true" then the assignment is completed; if it returns
"false" then newvalue is considered invalid and the assignment is not "false" then newvalue is considered invalid and the assignment is not
performed. If "doit" is false then the function should simply check performed. If "doit" is false then the function should simply check
validity of newvalue and not change any derived state. "interactive" is validity of newvalue and not change any derived state. The "source" parameter
true when we are performing a SET command; in this case it is okay for the indicates where the new value came from. If it is >= PGC_S_INTERACTIVE,
assign_hook to raise an error via elog(). If the function returns false then we are performing an interactive assignment (e.g., a SET command).
for an interactive assignment then guc.c will report a generic "invalid In such cases it is okay for the assign_hook to raise an error via ereport().
value" error message. (An internal elog() in an assign_hook is only If the function returns false for an interactive assignment then guc.c will
needed if you want to generate a specialized error message.) But when report a generic "invalid value" error message. (An internal ereport() in
"interactive" is false we are reading a non-interactive option source, an assign_hook is only needed if you want to generate a specialized error
such as postgresql.conf. In this case the assign_hook should *not* elog message.) But when source < PGC_S_INTERACTIVE, we are reading a
but should just return false if it doesn't like the newvalue. (An non-interactive option source, such as postgresql.conf. In this case the
elog(LOG) call would be acceptable if you feel a need for a custom assign_hook should *not* ereport but should just return false if it doesn't
complaint in this situation.) like the newvalue. (An ereport(LOG) call would be acceptable if you feel a
need for a custom complaint in this situation.)
For string variables, the signature for assign hooks is a bit different: For string variables, the signature for assign hooks is a bit different:
const char *assign_hook(const char *newvalue, const char *assign_hook(const char *newvalue,
bool doit, bool doit,
bool interactive) GucSource source)
The meanings of the parameters are the same as for the other types of GUC The meanings of the parameters are the same as for the other types of GUC
variables, but the return value is handled differently: variables, but the return value is handled differently:
NULL --- assignment fails (like returning false for other datatypes) NULL --- assignment fails (like returning false for other datatypes)

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.176 2004/01/06 17:26:23 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.177 2004/01/19 19:04:40 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -24,7 +24,6 @@
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/guc_tables.h" #include "utils/guc_tables.h"
#include "access/xlog.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/async.h" #include "commands/async.h"
@ -52,7 +51,6 @@
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/pg_locale.h" #include "utils/pg_locale.h"
#include "pgstat.h" #include "pgstat.h"
@ -81,22 +79,22 @@ extern char *Syslog_facility;
extern char *Syslog_ident; extern char *Syslog_ident;
static const char *assign_facility(const char *facility, static const char *assign_facility(const char *facility,
bool doit, bool interactive); bool doit, GucSource source);
#endif #endif
static const char *assign_defaultxactisolevel(const char *newval, static const char *assign_defaultxactisolevel(const char *newval,
bool doit, bool interactive); bool doit, GucSource source);
static const char *assign_log_min_messages(const char *newval, static const char *assign_log_min_messages(const char *newval,
bool doit, bool interactive); bool doit, GucSource source);
static const char *assign_client_min_messages(const char *newval, static const char *assign_client_min_messages(const char *newval,
bool doit, bool interactive); bool doit, GucSource source);
static const char *assign_min_error_statement(const char *newval, bool doit, static const char *assign_min_error_statement(const char *newval, bool doit,
bool interactive); GucSource source);
static const char *assign_msglvl(int *var, const char *newval, static const char *assign_msglvl(int *var, const char *newval,
bool doit, bool interactive); bool doit, GucSource source);
static const char *assign_log_error_verbosity(const char *newval, bool doit, static const char *assign_log_error_verbosity(const char *newval, bool doit,
bool interactive); GucSource source);
static bool assign_phony_autocommit(bool newval, bool doit, bool interactive); static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
/* /*
@ -227,16 +225,18 @@ const char *const GucContext_Names[] =
*/ */
const char *const GucSource_Names[] = const char *const GucSource_Names[] =
{ {
/* PGC_S_DEFAULT */ "default", /* PGC_S_DEFAULT */ "default",
/* PGC_S_ENV_VAR */ "environment variable", /* PGC_S_ENV_VAR */ "environment variable",
/* PGC_S_FILE */ "configuration file", /* PGC_S_FILE */ "configuration file",
/* PGC_S_ARGV */ "command line", /* PGC_S_ARGV */ "command line",
/* PGC_S_UNPRIVILEGED */ "unprivileged", /* PGC_S_UNPRIVILEGED */ "unprivileged",
/* PGC_S_DATABASE */ "database", /* PGC_S_DATABASE */ "database",
/* PGC_S_USER */ "user", /* PGC_S_USER */ "user",
/* PGC_S_CLIENT */ "client", /* PGC_S_CLIENT */ "client",
/* PGC_S_OVERRIDE */ "override", /* PGC_S_OVERRIDE */ "override",
/* PGC_S_SESSION */ "session" /* PGC_S_INTERACTIVE */ "interactive",
/* PGC_S_TEST */ "test",
/* PGC_S_SESSION */ "session"
}; };
/* /*
@ -1893,7 +1893,8 @@ InitializeGUCOptions(void)
struct config_bool *conf = (struct config_bool *) gconf; struct config_bool *conf = (struct config_bool *) gconf;
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_DEFAULT))
elog(FATAL, "failed to initialize %s to %d", elog(FATAL, "failed to initialize %s to %d",
conf->gen.name, (int) conf->reset_val); conf->gen.name, (int) conf->reset_val);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
@ -1914,7 +1915,8 @@ InitializeGUCOptions(void)
Assert(conf->gen.context != PGC_USERLIMIT || Assert(conf->gen.context != PGC_USERLIMIT ||
strcmp(conf->gen.name, "log_min_duration_statement") == 0); strcmp(conf->gen.name, "log_min_duration_statement") == 0);
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_DEFAULT))
elog(FATAL, "failed to initialize %s to %d", elog(FATAL, "failed to initialize %s to %d",
conf->gen.name, conf->reset_val); conf->gen.name, conf->reset_val);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
@ -1929,7 +1931,8 @@ InitializeGUCOptions(void)
Assert(conf->reset_val <= conf->max); Assert(conf->reset_val <= conf->max);
Assert(conf->gen.context != PGC_USERLIMIT); Assert(conf->gen.context != PGC_USERLIMIT);
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, false)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_DEFAULT))
elog(FATAL, "failed to initialize %s to %g", elog(FATAL, "failed to initialize %s to %g",
conf->gen.name, conf->reset_val); conf->gen.name, conf->reset_val);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
@ -1971,7 +1974,8 @@ InitializeGUCOptions(void)
{ {
const char *newstr; const char *newstr;
newstr = (*conf->assign_hook) (str, true, false); newstr = (*conf->assign_hook) (str, true,
PGC_S_DEFAULT);
if (newstr == NULL) if (newstr == NULL)
{ {
elog(FATAL, "failed to initialize %s to \"%s\"", elog(FATAL, "failed to initialize %s to \"%s\"",
@ -2065,7 +2069,8 @@ ResetAllOptions(void)
struct config_bool *conf = (struct config_bool *) gconf; struct config_bool *conf = (struct config_bool *) gconf;
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name); elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val; conf->tentative_val = conf->reset_val;
@ -2080,7 +2085,8 @@ ResetAllOptions(void)
struct config_int *conf = (struct config_int *) gconf; struct config_int *conf = (struct config_int *) gconf;
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name); elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val; conf->tentative_val = conf->reset_val;
@ -2095,7 +2101,8 @@ ResetAllOptions(void)
struct config_real *conf = (struct config_real *) gconf; struct config_real *conf = (struct config_real *) gconf;
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->reset_val, true, true)) if (!(*conf->assign_hook) (conf->reset_val, true,
PGC_S_SESSION))
elog(ERROR, "failed to reset %s", conf->gen.name); elog(ERROR, "failed to reset %s", conf->gen.name);
*conf->variable = conf->reset_val; *conf->variable = conf->reset_val;
conf->tentative_val = conf->reset_val; conf->tentative_val = conf->reset_val;
@ -2123,7 +2130,8 @@ ResetAllOptions(void)
{ {
const char *newstr; const char *newstr;
newstr = (*conf->assign_hook) (str, true, true); newstr = (*conf->assign_hook) (str, true,
PGC_S_SESSION);
if (newstr == NULL) if (newstr == NULL)
elog(ERROR, "failed to reset %s", conf->gen.name); elog(ERROR, "failed to reset %s", conf->gen.name);
else if (newstr != str) else if (newstr != str)
@ -2198,7 +2206,7 @@ AtEOXact_GUC(bool isCommit)
{ {
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val, if (!(*conf->assign_hook) (conf->session_val,
true, false)) true, PGC_S_OVERRIDE))
elog(LOG, "failed to commit %s", elog(LOG, "failed to commit %s",
conf->gen.name); conf->gen.name);
*conf->variable = conf->session_val; *conf->variable = conf->session_val;
@ -2222,7 +2230,7 @@ AtEOXact_GUC(bool isCommit)
{ {
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val, if (!(*conf->assign_hook) (conf->session_val,
true, false)) true, PGC_S_OVERRIDE))
elog(LOG, "failed to commit %s", elog(LOG, "failed to commit %s",
conf->gen.name); conf->gen.name);
*conf->variable = conf->session_val; *conf->variable = conf->session_val;
@ -2246,7 +2254,7 @@ AtEOXact_GUC(bool isCommit)
{ {
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (conf->session_val, if (!(*conf->assign_hook) (conf->session_val,
true, false)) true, PGC_S_OVERRIDE))
elog(LOG, "failed to commit %s", elog(LOG, "failed to commit %s",
conf->gen.name); conf->gen.name);
*conf->variable = conf->session_val; *conf->variable = conf->session_val;
@ -2277,7 +2285,8 @@ AtEOXact_GUC(bool isCommit)
{ {
const char *newstr; const char *newstr;
newstr = (*conf->assign_hook) (str, true, false); newstr = (*conf->assign_hook) (str, true,
PGC_S_OVERRIDE);
if (newstr == NULL) if (newstr == NULL)
elog(LOG, "failed to commit %s", elog(LOG, "failed to commit %s",
conf->gen.name); conf->gen.name);
@ -2500,7 +2509,6 @@ set_config_option(const char *name, const char *value,
{ {
struct config_generic *record; struct config_generic *record;
int elevel; int elevel;
bool interactive;
bool makeDefault; bool makeDefault;
bool changeVal_orig; bool changeVal_orig;
@ -2610,9 +2618,6 @@ set_config_option(const char *name, const char *value,
break; break;
} }
/* Should we report errors interactively? */
interactive = (source >= PGC_S_SESSION);
/* /*
* Should we set reset/session values? (If so, the behavior is not * Should we set reset/session values? (If so, the behavior is not
* transactional.) * transactional.)
@ -2687,7 +2692,7 @@ set_config_option(const char *name, const char *value,
} }
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, changeVal, interactive)) if (!(*conf->assign_hook) (newval, changeVal, source))
{ {
ereport(elevel, ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -2784,7 +2789,7 @@ set_config_option(const char *name, const char *value,
} }
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, changeVal, interactive)) if (!(*conf->assign_hook) (newval, changeVal, source))
{ {
ereport(elevel, ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -2880,7 +2885,7 @@ set_config_option(const char *name, const char *value,
} }
if (conf->assign_hook) if (conf->assign_hook)
if (!(*conf->assign_hook) (newval, changeVal, interactive)) if (!(*conf->assign_hook) (newval, changeVal, source))
{ {
ereport(elevel, ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -2949,9 +2954,9 @@ set_config_option(const char *name, const char *value,
/* all USERLIMIT strings are message levels */ /* all USERLIMIT strings are message levels */
assign_msglvl(&old_int_value, conf->reset_val, assign_msglvl(&old_int_value, conf->reset_val,
true, interactive); true, source);
assign_msglvl(&new_int_value, newval, assign_msglvl(&new_int_value, newval,
true, interactive); true, source);
/* Limit non-superuser changes */ /* Limit non-superuser changes */
if (source > PGC_S_UNPRIVILEGED && if (source > PGC_S_UNPRIVILEGED &&
new_int_value > old_int_value && new_int_value > old_int_value &&
@ -3008,7 +3013,7 @@ set_config_option(const char *name, const char *value,
const char *hookresult; const char *hookresult;
hookresult = (*conf->assign_hook) (newval, hookresult = (*conf->assign_hook) (newval,
changeVal, interactive); changeVal, source);
guc_string_workspace = NULL; guc_string_workspace = NULL;
if (hookresult == NULL) if (hookresult == NULL)
{ {
@ -4189,7 +4194,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
/* test if the option is valid */ /* test if the option is valid */
set_config_option(name, value, set_config_option(name, value,
superuser() ? PGC_SUSET : PGC_USERSET, superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false); PGC_S_TEST, false, false);
/* convert name to canonical spelling, so we can use plain strcmp */ /* convert name to canonical spelling, so we can use plain strcmp */
(void) GetConfigOptionByName(name, &varname); (void) GetConfigOptionByName(name, &varname);
@ -4268,7 +4273,7 @@ GUCArrayDelete(ArrayType *array, const char *name)
/* test if the option is valid */ /* test if the option is valid */
set_config_option(name, NULL, set_config_option(name, NULL,
superuser() ? PGC_SUSET : PGC_USERSET, superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false); PGC_S_TEST, false, false);
/* convert name to canonical spelling, so we can use plain strcmp */ /* convert name to canonical spelling, so we can use plain strcmp */
(void) GetConfigOptionByName(name, &varname); (void) GetConfigOptionByName(name, &varname);
@ -4333,7 +4338,7 @@ GUCArrayDelete(ArrayType *array, const char *name)
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
static const char * static const char *
assign_facility(const char *facility, bool doit, bool interactive) assign_facility(const char *facility, bool doit, GucSource source)
{ {
if (strcasecmp(facility, "LOCAL0") == 0) if (strcasecmp(facility, "LOCAL0") == 0)
return facility; return facility;
@ -4357,7 +4362,7 @@ assign_facility(const char *facility, bool doit, bool interactive)
static const char * static const char *
assign_defaultxactisolevel(const char *newval, bool doit, bool interactive) assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "serializable") == 0) if (strcasecmp(newval, "serializable") == 0)
{ {
@ -4386,26 +4391,26 @@ assign_defaultxactisolevel(const char *newval, bool doit, bool interactive)
static const char * static const char *
assign_log_min_messages(const char *newval, assign_log_min_messages(const char *newval,
bool doit, bool interactive) bool doit, GucSource source)
{ {
return (assign_msglvl(&log_min_messages, newval, doit, interactive)); return (assign_msglvl(&log_min_messages, newval, doit, source));
} }
static const char * static const char *
assign_client_min_messages(const char *newval, assign_client_min_messages(const char *newval,
bool doit, bool interactive) bool doit, GucSource source)
{ {
return (assign_msglvl(&client_min_messages, newval, doit, interactive)); return (assign_msglvl(&client_min_messages, newval, doit, source));
} }
static const char * static const char *
assign_min_error_statement(const char *newval, bool doit, bool interactive) assign_min_error_statement(const char *newval, bool doit, GucSource source)
{ {
return (assign_msglvl(&log_min_error_statement, newval, doit, interactive)); return (assign_msglvl(&log_min_error_statement, newval, doit, source));
} }
static const char * static const char *
assign_msglvl(int *var, const char *newval, bool doit, bool interactive) assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "debug") == 0) if (strcasecmp(newval, "debug") == 0)
{ {
@ -4479,7 +4484,7 @@ assign_msglvl(int *var, const char *newval, bool doit, bool interactive)
} }
static const char * static const char *
assign_log_error_verbosity(const char *newval, bool doit, bool interactive) assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
{ {
if (strcasecmp(newval, "terse") == 0) if (strcasecmp(newval, "terse") == 0)
{ {
@ -4502,11 +4507,11 @@ assign_log_error_verbosity(const char *newval, bool doit, bool interactive)
} }
static bool static bool
assign_phony_autocommit(bool newval, bool doit, bool interactive) assign_phony_autocommit(bool newval, bool doit, GucSource source)
{ {
if (!newval) if (!newval)
{ {
if (doit && interactive) if (doit && source >= PGC_S_INTERACTIVE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SET AUTOCOMMIT TO OFF is no longer supported"))); errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.47 2004/01/06 17:26:23 neilc Exp $ * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.48 2004/01/19 19:04:40 tgl Exp $
*/ */
#ifndef XLOG_H #ifndef XLOG_H
#define XLOG_H #define XLOG_H
@ -222,7 +222,4 @@ extern XLogRecPtr GetRedoRecPtr(void);
*/ */
extern XLogRecPtr GetUndoRecPtr(void); extern XLogRecPtr GetUndoRecPtr(void);
extern const char *assign_xlog_sync_method(const char *method,
bool doit, bool interactive);
#endif /* XLOG_H */ #endif /* XLOG_H */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.29 2003/11/29 22:40:58 pgsql Exp $ * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.30 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -95,9 +95,6 @@ extern void AtEOXact_Namespace(bool isCommit);
/* stuff for search_path GUC variable */ /* stuff for search_path GUC variable */
extern char *namespace_search_path; extern char *namespace_search_path;
extern const char *assign_search_path(const char *newval,
bool doit, bool interactive);
extern List *fetch_search_path(bool includeImplicit); extern List *fetch_search_path(bool includeImplicit);
#endif /* NAMESPACE_H */ #endif /* NAMESPACE_H */

View File

@ -2,27 +2,32 @@
* variable.h * variable.h
* Routines for handling specialized SET variables. * Routines for handling specialized SET variables.
* *
* $PostgreSQL: pgsql/src/include/commands/variable.h,v 1.22 2003/11/29 22:40:59 pgsql Exp $ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/commands/variable.h,v 1.23 2004/01/19 19:04:40 tgl Exp $
*/ */
#ifndef VARIABLE_H #ifndef VARIABLE_H
#define VARIABLE_H #define VARIABLE_H
#include "utils/guc.h"
extern const char *assign_datestyle(const char *value, extern const char *assign_datestyle(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *assign_timezone(const char *value, extern const char *assign_timezone(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *show_timezone(void); extern const char *show_timezone(void);
extern const char *assign_XactIsoLevel(const char *value, extern const char *assign_XactIsoLevel(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *show_XactIsoLevel(void); extern const char *show_XactIsoLevel(void);
extern bool assign_random_seed(double value, extern bool assign_random_seed(double value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *show_random_seed(void); extern const char *show_random_seed(void);
extern const char *assign_client_encoding(const char *value, extern const char *assign_client_encoding(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *assign_session_authorization(const char *value, extern const char *assign_session_authorization(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *show_session_authorization(void); extern const char *show_session_authorization(void);
#endif /* VARIABLE_H */ #endif /* VARIABLE_H */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.232 2003/12/01 23:12:16 momjian Exp $ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.233 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -16,7 +16,6 @@
#include "fmgr.h" #include "fmgr.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "storage/itemptr.h" /* for setLastTid() */
/* /*
* Defined in adt/ * Defined in adt/
@ -415,8 +414,6 @@ extern Datum texticregexeq(PG_FUNCTION_ARGS);
extern Datum texticregexne(PG_FUNCTION_ARGS); extern Datum texticregexne(PG_FUNCTION_ARGS);
extern Datum textregexsubstr(PG_FUNCTION_ARGS); extern Datum textregexsubstr(PG_FUNCTION_ARGS);
extern Datum similar_escape(PG_FUNCTION_ARGS); extern Datum similar_escape(PG_FUNCTION_ARGS);
extern const char *assign_regex_flavor(const char *value,
bool doit, bool interactive);
/* regproc.c */ /* regproc.c */
extern Datum regprocin(PG_FUNCTION_ARGS); extern Datum regprocin(PG_FUNCTION_ARGS);
@ -483,7 +480,6 @@ extern Datum tidsend(PG_FUNCTION_ARGS);
extern Datum tideq(PG_FUNCTION_ARGS); extern Datum tideq(PG_FUNCTION_ARGS);
extern Datum currtid_byreloid(PG_FUNCTION_ARGS); extern Datum currtid_byreloid(PG_FUNCTION_ARGS);
extern Datum currtid_byrelname(PG_FUNCTION_ARGS); extern Datum currtid_byrelname(PG_FUNCTION_ARGS);
extern void setLastTid(const ItemPointer tid);
/* varchar.c */ /* varchar.c */
extern Datum bpcharin(PG_FUNCTION_ARGS); extern Datum bpcharin(PG_FUNCTION_ARGS);

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.46 2003/11/29 22:41:15 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.47 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -318,7 +318,6 @@ extern int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
extern int DecodeSpecial(int field, char *lowtoken, int *val); extern int DecodeSpecial(int field, char *lowtoken, int *val);
extern int DecodeUnits(int field, char *lowtoken, int *val); extern int DecodeUnits(int field, char *lowtoken, int *val);
extern bool ClearDateCache(bool newval, bool doit, bool interactive);
extern int j2day(int jd); extern int j2day(int jd);

View File

@ -7,7 +7,7 @@
* Copyright (c) 2000-2003, PostgreSQL Global Development Group * Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.43 2003/12/01 22:08:02 momjian Exp $ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.44 2004/01/19 19:04:40 tgl Exp $
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
#ifndef GUC_H #ifndef GUC_H
@ -76,6 +76,15 @@ typedef enum
* *
* PGC_S_UNPRIVILEGED isn't actually a source value, but the dividing line * PGC_S_UNPRIVILEGED isn't actually a source value, but the dividing line
* between privileged and unprivileged sources for USERLIMIT purposes. * between privileged and unprivileged sources for USERLIMIT purposes.
* Similarly, PGC_S_INTERACTIVE isn't a real source value, but is the
* dividing line between "interactive" and "non-interactive" sources for
* error reporting purposes.
*
* PGC_S_TEST is used when testing values to be stored as per-database or
* per-user defaults ("doit" will always be false, so this never gets stored
* as the actual source of any value). This is an interactive case, but
* it needs its own source value because some assign hooks need to make
* different validity checks in this case.
*/ */
typedef enum typedef enum
{ {
@ -88,6 +97,8 @@ typedef enum
PGC_S_USER, /* per-user setting */ PGC_S_USER, /* per-user setting */
PGC_S_CLIENT, /* from client connection request */ PGC_S_CLIENT, /* from client connection request */
PGC_S_OVERRIDE, /* special case to forcibly set default */ PGC_S_OVERRIDE, /* special case to forcibly set default */
PGC_S_INTERACTIVE, /* dividing line for error reporting */
PGC_S_TEST, /* test per-database or per-user setting */
PGC_S_SESSION /* SET command */ PGC_S_SESSION /* SET command */
} GucSource; } GucSource;
@ -152,4 +163,22 @@ void write_nondefault_variables(GucContext context);
void read_nondefault_variables(void); void read_nondefault_variables(void);
#endif #endif
/*
* The following functions are not in guc.c, but are declared here to avoid
* having to include guc.h in some widely used headers that it really doesn't
* belong in.
*/
/* in utils/adt/datetime.c */
extern bool ClearDateCache(bool newval, bool doit, GucSource source);
/* in utils/adt/regexp.c */
extern const char *assign_regex_flavor(const char *value,
bool doit, GucSource source);
/* in catalog/namespace.c */
extern const char *assign_search_path(const char *newval,
bool doit, GucSource source);
/* in access/transam/xlog.c */
extern const char *assign_xlog_sync_method(const char *method,
bool doit, GucSource source);
#endif /* GUC_H */ #endif /* GUC_H */

View File

@ -7,7 +7,7 @@
* *
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.8 2003/12/03 18:52:00 joe Exp $ * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.9 2004/01/19 19:04:40 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -113,7 +113,7 @@ struct config_bool
/* (all but reset_val are constants) */ /* (all but reset_val are constants) */
bool *variable; bool *variable;
bool reset_val; bool reset_val;
bool (*assign_hook) (bool newval, bool doit, bool interactive); bool (*assign_hook) (bool newval, bool doit, GucSource source);
const char *(*show_hook) (void); const char *(*show_hook) (void);
/* variable fields, initialized at runtime: */ /* variable fields, initialized at runtime: */
bool session_val; bool session_val;
@ -129,7 +129,7 @@ struct config_int
int reset_val; int reset_val;
int min; int min;
int max; int max;
bool (*assign_hook) (int newval, bool doit, bool interactive); bool (*assign_hook) (int newval, bool doit, GucSource source);
const char *(*show_hook) (void); const char *(*show_hook) (void);
/* variable fields, initialized at runtime: */ /* variable fields, initialized at runtime: */
int session_val; int session_val;
@ -145,7 +145,7 @@ struct config_real
double reset_val; double reset_val;
double min; double min;
double max; double max;
bool (*assign_hook) (double newval, bool doit, bool interactive); bool (*assign_hook) (double newval, bool doit, GucSource source);
const char *(*show_hook) (void); const char *(*show_hook) (void);
/* variable fields, initialized at runtime: */ /* variable fields, initialized at runtime: */
double session_val; double session_val;
@ -159,7 +159,7 @@ struct config_string
/* (all are constants) */ /* (all are constants) */
char **variable; char **variable;
const char *boot_val; const char *boot_val;
const char *(*assign_hook) (const char *newval, bool doit, bool interactive); const char *(*assign_hook) (const char *newval, bool doit, GucSource source);
const char *(*show_hook) (void); const char *(*show_hook) (void);
/* variable fields, initialized at runtime: */ /* variable fields, initialized at runtime: */
char *reset_val; char *reset_val;

View File

@ -2,7 +2,7 @@
* *
* PostgreSQL locale utilities * PostgreSQL locale utilities
* *
* $PostgreSQL: pgsql/src/include/utils/pg_locale.h,v 1.16 2003/11/29 22:41:16 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/pg_locale.h,v 1.17 2004/01/19 19:04:40 tgl Exp $
* *
* Copyright (c) 2002-2003, PostgreSQL Global Development Group * Copyright (c) 2002-2003, PostgreSQL Global Development Group
* *
@ -14,19 +14,22 @@
#include <locale.h> #include <locale.h>
#include "utils/guc.h"
extern char *locale_messages; extern char *locale_messages;
extern char *locale_monetary; extern char *locale_monetary;
extern char *locale_numeric; extern char *locale_numeric;
extern char *locale_time; extern char *locale_time;
extern const char *locale_messages_assign(const char *value, extern const char *locale_messages_assign(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *locale_monetary_assign(const char *value, extern const char *locale_monetary_assign(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *locale_numeric_assign(const char *value, extern const char *locale_numeric_assign(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern const char *locale_time_assign(const char *value, extern const char *locale_time_assign(const char *value,
bool doit, bool interactive); bool doit, GucSource source);
extern bool lc_collate_is_c(void); extern bool lc_collate_is_c(void);

View File

@ -298,7 +298,6 @@ int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
int tm2timestamp(struct tm *, fsec_t, int *, timestamp *); int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
int DecodeUnits(int field, char *lowtoken, int *val); int DecodeUnits(int field, char *lowtoken, int *val);
bool ClearDateCache(bool, bool, bool);
bool CheckDateTokenTables(void); bool CheckDateTokenTables(void);