Commit 5233dc15 authored by Tom Lane's avatar Tom Lane

Improve consistency of error reporting in GUC assign_hook routines. Some

were reporting ERROR for interactive assignments and LOG for other cases,
some were saying nothing for non-interactive cases, and a few did yet other
things.  Make them use a new function GUC_complaint_elevel() to establish
a reasonably uniform policy about how to report.  There are still a few
edge cases such as assign_search_path(), but it's much better than before.
Per gripe from Devrim Gunduz and subsequent discussion.

As noted by Alvaro, it'd be better to fold these custom messages into the
standard "invalid parameter value" complaint from guc.c, perhaps as the DETAIL
field.  However that will require more redesign than seems prudent for 8.3.
This is a relatively safe, low-impact change that we can afford to risk now.
parent 2e4cb708
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.51 2007/11/15 21:14:34 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.52 2007/12/28 00:23:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -923,11 +923,10 @@ assign_default_tablespace(const char *newval, bool doit, GucSource source) ...@@ -923,11 +923,10 @@ assign_default_tablespace(const char *newval, bool doit, GucSource source)
if (newval[0] != '\0' && if (newval[0] != '\0' &&
!OidIsValid(get_tablespace_oid(newval))) !OidIsValid(get_tablespace_oid(newval)))
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
(errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("tablespace \"%s\" does not exist",
errmsg("tablespace \"%s\" does not exist", newval)));
newval)));
return NULL; return NULL;
} }
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.122 2007/11/15 21:14:34 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.123 2007/12/28 00:23:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,9 +57,8 @@ assign_datestyle(const char *value, bool doit, GucSource source) ...@@ -57,9 +57,8 @@ assign_datestyle(const char *value, bool doit, GucSource source)
/* syntax error in list */ /* syntax error in list */
pfree(rawstring); pfree(rawstring);
list_free(elemlist); list_free(elemlist);
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
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\"")));
return NULL; return NULL;
} }
...@@ -157,11 +156,10 @@ assign_datestyle(const char *value, bool doit, GucSource source) ...@@ -157,11 +156,10 @@ assign_datestyle(const char *value, bool doit, GucSource source)
} }
else else
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized \"datestyle\" key word: \"%s\"",
errmsg("unrecognized \"datestyle\" key word: \"%s\"", tok)));
tok)));
ok = false; ok = false;
break; break;
} }
...@@ -172,10 +170,9 @@ assign_datestyle(const char *value, bool doit, GucSource source) ...@@ -172,10 +170,9 @@ assign_datestyle(const char *value, bool doit, GucSource source)
if (!ok) if (!ok)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("conflicting \"datestyle\" specifications")));
errmsg("conflicting \"datestyle\" specifications")));
return NULL; return NULL;
} }
...@@ -271,9 +268,9 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -271,9 +268,9 @@ assign_timezone(const char *value, bool doit, GucSource source)
/* /*
* Try to parse it. XXX an invalid interval format will result in * Try to parse it. XXX an invalid interval format will result in
* ereport, which is not desirable for GUC. We did what we could to * ereport(ERROR), which is not desirable for GUC. We did what we
* guard against this in flatten_set_variable_args, but a string * could to guard against this in flatten_set_variable_args, but a
* coming in from postgresql.conf might contain anything. * string coming in from postgresql.conf might contain anything.
*/ */
interval = DatumGetIntervalP(DirectFunctionCall3(interval_in, interval = DatumGetIntervalP(DirectFunctionCall3(interval_in,
CStringGetDatum(val), CStringGetDatum(val),
...@@ -283,19 +280,17 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -283,19 +280,17 @@ assign_timezone(const char *value, bool doit, GucSource source)
pfree(val); pfree(val);
if (interval->month != 0) if (interval->month != 0)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
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")));
pfree(interval); pfree(interval);
return NULL; return NULL;
} }
if (interval->day != 0) if (interval->day != 0)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid interval value for time zone: day not allowed")));
errmsg("invalid interval value for time zone: day not allowed")));
pfree(interval); pfree(interval);
return NULL; return NULL;
} }
...@@ -361,7 +356,7 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -361,7 +356,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
if (!new_tz) if (!new_tz)
{ {
ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized time zone name: \"%s\"", errmsg("unrecognized time zone name: \"%s\"",
value))); value)));
...@@ -370,7 +365,7 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -370,7 +365,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
if (!tz_acceptable(new_tz)) if (!tz_acceptable(new_tz))
{ {
ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, ereport(GUC_complaint_elevel(source),
(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),
...@@ -493,7 +488,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source) ...@@ -493,7 +488,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
if (!new_tz) if (!new_tz)
{ {
ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized time zone name: \"%s\"", errmsg("unrecognized time zone name: \"%s\"",
value))); value)));
...@@ -502,7 +497,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source) ...@@ -502,7 +497,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
if (!tz_acceptable(new_tz)) if (!tz_acceptable(new_tz))
{ {
ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, ereport(GUC_complaint_elevel(source),
(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),
...@@ -557,22 +552,20 @@ assign_XactIsoLevel(const char *value, bool doit, GucSource source) ...@@ -557,22 +552,20 @@ assign_XactIsoLevel(const char *value, bool doit, GucSource source)
{ {
if (SerializableSnapshot != NULL) if (SerializableSnapshot != NULL)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
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")));
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
else if (source != PGC_S_OVERRIDE) if (source != PGC_S_OVERRIDE)
return NULL; return NULL;
} }
if (IsSubTransaction()) else if (IsSubTransaction())
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
else if (source != PGC_S_OVERRIDE) if (source != PGC_S_OVERRIDE)
return NULL; return NULL;
} }
...@@ -667,11 +660,10 @@ assign_client_encoding(const char *value, bool doit, GucSource source) ...@@ -667,11 +660,10 @@ assign_client_encoding(const char *value, bool doit, GucSource source)
*/ */
if (SetClientEncoding(encoding, doit) < 0) if (SetClientEncoding(encoding, doit) < 0)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
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", value, GetDatabaseEncodingName())));
value, GetDatabaseEncodingName())));
return NULL; return NULL;
} }
return value; return value;
...@@ -740,10 +732,9 @@ assign_session_authorization(const char *value, bool doit, GucSource source) ...@@ -740,10 +732,9 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(roleTup)) if (!HeapTupleIsValid(roleTup))
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
(errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("role \"%s\" does not exist", value)));
errmsg("role \"%s\" does not exist", value)));
return NULL; return NULL;
} }
...@@ -853,10 +844,9 @@ assign_role(const char *value, bool doit, GucSource source) ...@@ -853,10 +844,9 @@ assign_role(const char *value, bool doit, GucSource source)
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(roleTup)) if (!HeapTupleIsValid(roleTup))
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT),
(errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("role \"%s\" does not exist", value)));
errmsg("role \"%s\" does not exist", value)));
return NULL; return NULL;
} }
...@@ -870,11 +860,10 @@ assign_role(const char *value, bool doit, GucSource source) ...@@ -870,11 +860,10 @@ assign_role(const char *value, bool doit, GucSource source)
*/ */
if (!is_member_of_role(GetSessionUserId(), roleid)) if (!is_member_of_role(GetSessionUserId(), roleid))
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied to set role \"%s\"",
errmsg("permission denied to set role \"%s\"", value)));
value)));
return NULL; return NULL;
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.539 2007/12/06 14:32:54 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.540 2007/12/28 00:23:23 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -2644,7 +2644,7 @@ assign_max_stack_depth(int newval, bool doit, GucSource source) ...@@ -2644,7 +2644,7 @@ assign_max_stack_depth(int newval, bool doit, GucSource source)
if (stack_rlimit > 0 && newval_bytes > stack_rlimit - STACK_DEPTH_SLOP) if (stack_rlimit > 0 && newval_bytes > stack_rlimit - STACK_DEPTH_SLOP)
{ {
ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"max_stack_depth\" must not exceed %ldkB", errmsg("\"max_stack_depth\" must not exceed %ldkB",
(stack_rlimit - STACK_DEPTH_SLOP) / 1024L), (stack_rlimit - STACK_DEPTH_SLOP) / 1024L),
......
$PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.7 2007/09/11 00:06:42 tgl Exp $ $PostgreSQL: pgsql/src/backend/utils/misc/README,v 1.8 2007/12/28 00:23:23 tgl Exp $
GUC IMPLEMENTATION NOTES GUC IMPLEMENTATION NOTES
...@@ -28,16 +28,18 @@ function returns "true" then the assignment is completed; if it returns ...@@ -28,16 +28,18 @@ function returns "true" then the assignment is completed; if it returns
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. The "source" parameter validity of newvalue and not change any derived state. The "source" parameter
indicates where the new value came from. If it is >= PGC_S_INTERACTIVE, indicates where the new value came from. If it is >= PGC_S_INTERACTIVE,
then we are performing an interactive assignment (e.g., a SET command). then we are performing an interactive assignment (e.g., a SET command), and
In such cases it is okay for the assign_hook to raise an error via ereport(). ereport(ERROR) is safe to do. But when source < PGC_S_INTERACTIVE, we are
If the function returns false for an interactive assignment then guc.c will reading a non-interactive option source, such as postgresql.conf. In this
report a generic "invalid value" error message. (An internal ereport() in case the assign_hook should *not* ereport but should just return false if it
an assign_hook is only needed if you want to generate a specialized error doesn't like the newvalue.
message.) But when source < PGC_S_INTERACTIVE, we are reading a
non-interactive option source, such as postgresql.conf. In this case the If an assign_hook returns false then guc.c will report a generic "invalid
assign_hook should *not* ereport but should just return false if it doesn't value for option FOO" error message. If you feel the need to provide a more
like the newvalue. (An ereport(LOG) call would be acceptable if you feel a specific error message, ereport() it using "GUC_complaint_elevel(source)"
need for a custom complaint in this situation.) as the error level. Note that this might return either ERROR or a lower level
such as LOG, so the ereport call might or might not return. If it does
return, return false out of the assign_hook.
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,
......
...@@ -10,7 +10,7 @@ ...@@ -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.427 2007/12/27 13:02:48 petere Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.428 2007/12/28 00:23:23 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
...@@ -4157,7 +4157,7 @@ call_string_assign_hook(GucStringAssignHook assign_hook, ...@@ -4157,7 +4157,7 @@ call_string_assign_hook(GucStringAssignHook assign_hook,
* If there is an error (non-existing option, invalid value) then an * If there is an error (non-existing option, invalid value) then an
* ereport(ERROR) is thrown *unless* this is called in a context where we * ereport(ERROR) is thrown *unless* this is called in a context where we
* don't want to ereport (currently, startup or SIGHUP config file reread). * don't want to ereport (currently, startup or SIGHUP config file reread).
* In that case we write a suitable error message via ereport(DEBUG) and * In that case we write a suitable error message via ereport(LOG) and
* return false. This is working around the deficiencies in the ereport * return false. This is working around the deficiencies in the ereport
* mechanism, so don't blame me. In all other cases, the function * mechanism, so don't blame me. In all other cases, the function
* returns true, including cases where the input is valid but we chose * returns true, including cases where the input is valid but we chose
...@@ -4180,7 +4180,7 @@ set_config_option(const char *name, const char *value, ...@@ -4180,7 +4180,7 @@ set_config_option(const char *name, const char *value,
* To avoid cluttering the log, only the postmaster bleats loudly * To avoid cluttering the log, only the postmaster bleats loudly
* about problems with the config file. * about problems with the config file.
*/ */
elevel = IsUnderPostmaster ? DEBUG2 : LOG; elevel = IsUnderPostmaster ? DEBUG3 : LOG;
} }
else if (source == PGC_S_DATABASE || source == PGC_S_USER) else if (source == PGC_S_DATABASE || source == PGC_S_USER)
elevel = INFO; elevel = INFO;
...@@ -4803,6 +4803,41 @@ IsSuperuserConfigOption(const char *name) ...@@ -4803,6 +4803,41 @@ IsSuperuserConfigOption(const char *name)
} }
/*
* GUC_complaint_elevel
* Get the ereport error level to use in an assign_hook's error report.
*
* This should be used by assign hooks that want to emit a custom error
* report (in addition to the generic "invalid value for option FOO" that
* guc.c will provide). Note that the result might be ERROR or a lower
* level, so the caller must be prepared for control to return from ereport,
* or not. If control does return, return false/NULL from the hook function.
*
* At some point it'd be nice to replace this with a mechanism that allows
* the custom message to become the DETAIL line of guc.c's generic message.
*/
int
GUC_complaint_elevel(GucSource source)
{
int elevel;
if (source == PGC_S_FILE)
{
/*
* To avoid cluttering the log, only the postmaster bleats loudly
* about problems with the config file.
*/
elevel = IsUnderPostmaster ? DEBUG3 : LOG;
}
else if (source < PGC_S_INTERACTIVE)
elevel = LOG;
else
elevel = ERROR;
return elevel;
}
/* /*
* flatten_set_variable_args * flatten_set_variable_args
* Given a parsenode List as emitted by the grammar for SET, * Given a parsenode List as emitted by the grammar for SET,
...@@ -6406,9 +6441,8 @@ assign_log_destination(const char *value, bool doit, GucSource source) ...@@ -6406,9 +6441,8 @@ assign_log_destination(const char *value, bool doit, GucSource source)
/* syntax error in list */ /* syntax error in list */
pfree(rawstring); pfree(rawstring);
list_free(elemlist); list_free(elemlist);
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid list syntax for parameter \"log_destination\""))); errmsg("invalid list syntax for parameter \"log_destination\"")));
return NULL; return NULL;
} }
...@@ -6431,9 +6465,8 @@ assign_log_destination(const char *value, bool doit, GucSource source) ...@@ -6431,9 +6465,8 @@ assign_log_destination(const char *value, bool doit, GucSource source)
#endif #endif
else else
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized \"log_destination\" key word: \"%s\"", errmsg("unrecognized \"log_destination\" key word: \"%s\"",
tok))); tok)));
pfree(rawstring); pfree(rawstring);
...@@ -6719,10 +6752,9 @@ assign_phony_autocommit(bool newval, bool doit, GucSource source) ...@@ -6719,10 +6752,9 @@ assign_phony_autocommit(bool newval, bool doit, GucSource source)
{ {
if (!newval) if (!newval)
{ {
if (doit && source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
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")));
return false; return false;
} }
return true; return true;
...@@ -6791,9 +6823,12 @@ assign_debug_assertions(bool newval, bool doit, GucSource source) ...@@ -6791,9 +6823,12 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
{ {
#ifndef USE_ASSERT_CHECKING #ifndef USE_ASSERT_CHECKING
if (newval) if (newval)
ereport(ERROR, {
ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("assertion checking is not supported by this build"))); errmsg("assertion checking is not supported by this build")));
return false;
}
#endif #endif
return true; return true;
} }
...@@ -6803,9 +6838,12 @@ assign_ssl(bool newval, bool doit, GucSource source) ...@@ -6803,9 +6838,12 @@ assign_ssl(bool newval, bool doit, GucSource source)
{ {
#ifndef USE_SSL #ifndef USE_SSL
if (newval) if (newval)
ereport(ERROR, {
ereport(GUC_complaint_elevel(source),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("SSL is not supported by this build"))); errmsg("SSL is not supported by this build")));
return false;
}
#endif #endif
return true; return true;
} }
...@@ -6815,12 +6853,11 @@ assign_stage_log_stats(bool newval, bool doit, GucSource source) ...@@ -6815,12 +6853,11 @@ assign_stage_log_stats(bool newval, bool doit, GucSource source)
{ {
if (newval && log_statement_stats) if (newval && log_statement_stats)
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
else if (source != PGC_S_OVERRIDE) if (source != PGC_S_OVERRIDE)
return false; return false;
} }
return true; return true;
...@@ -6832,14 +6869,13 @@ assign_log_stats(bool newval, bool doit, GucSource source) ...@@ -6832,14 +6869,13 @@ assign_log_stats(bool newval, bool doit, GucSource source)
if (newval && if (newval &&
(log_parser_stats || log_planner_stats || log_executor_stats)) (log_parser_stats || log_planner_stats || log_executor_stats))
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("cannot enable \"log_statement_stats\" when "
errmsg("cannot enable \"log_statement_stats\" when " "\"log_parser_stats\", \"log_planner_stats\", "
"\"log_parser_stats\", \"log_planner_stats\", " "or \"log_executor_stats\" is true")));
"or \"log_executor_stats\" is true")));
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
else if (source != PGC_S_OVERRIDE) if (source != PGC_S_OVERRIDE)
return false; return false;
} }
return true; return true;
...@@ -6851,12 +6887,11 @@ assign_transaction_read_only(bool newval, bool doit, GucSource source) ...@@ -6851,12 +6887,11 @@ assign_transaction_read_only(bool newval, bool doit, GucSource source)
/* Can't go to r/w mode inside a r/o transaction */ /* Can't go to r/w mode inside a r/o transaction */
if (newval == false && XactReadOnly && IsSubTransaction()) if (newval == false && XactReadOnly && IsSubTransaction())
{ {
if (source >= PGC_S_INTERACTIVE) ereport(GUC_complaint_elevel(source),
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("cannot set transaction read-write mode inside a read-only transaction")));
errmsg("cannot set transaction read-write mode inside a read-only transaction")));
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
else if (source != PGC_S_OVERRIDE) if (source != PGC_S_OVERRIDE)
return false; return false;
} }
return true; return true;
...@@ -6934,7 +6969,7 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source) ...@@ -6934,7 +6969,7 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
* and we use WARNING message level. * and we use WARNING message level.
*/ */
if (source == PGC_S_FILE) if (source == PGC_S_FILE)
elevel = IsUnderPostmaster ? DEBUG2 : LOG; elevel = IsUnderPostmaster ? DEBUG3 : LOG;
else else
elevel = WARNING; elevel = WARNING;
if (!load_tzoffsets(newval, doit, elevel)) if (!load_tzoffsets(newval, doit, elevel))
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, 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.88 2007/11/15 22:25:17 momjian Exp $ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.89 2007/12/28 00:23:23 tgl Exp $
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
#ifndef GUC_H #ifndef GUC_H
...@@ -221,6 +221,8 @@ extern void ProcessGUCArray(ArrayType *array, ...@@ -221,6 +221,8 @@ extern void ProcessGUCArray(ArrayType *array,
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value); extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name); extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
extern int GUC_complaint_elevel(GucSource source);
extern void pg_timezone_abbrev_initialize(void); extern void pg_timezone_abbrev_initialize(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment