]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/misc/guc.c
Document and enforce that the usable range of setseed() arguments is
[postgresql] / src / backend / utils / misc / guc.c
index 3ce3d4ed0476407ee7570ae034380ca5865ae164..49958cb4e7f3ab74c62a82ecf89b6fb80294fe11 100644 (file)
@@ -6,11 +6,11 @@
  * See src/backend/utils/misc/README for more information.
  *
  *
- * Copyright (c) 2000-2007, PostgreSQL Global Development Group
+ * Copyright (c) 2000-2008, PostgreSQL Global Development Group
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.426 2007/11/15 21:14:41 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.436 2008/03/10 12:39:23 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -110,6 +110,7 @@ extern int  CommitDelay;
 extern int     CommitSiblings;
 extern char *default_tablespace;
 extern char *temp_tablespaces;
+extern bool synchronize_seqscans;
 extern bool fullPageWrites;
 
 #ifdef TRACE_SORT
@@ -208,7 +209,7 @@ bool                SQL_inheritance = true;
 bool           Password_encryption = true;
 
 int                    log_min_error_statement = ERROR;
-int                    log_min_messages = NOTICE;
+int                    log_min_messages = WARNING;
 int                    client_min_messages = NOTICE;
 int                    log_min_duration_statement = -1;
 int                    log_temp_files = -1;
@@ -1052,6 +1053,15 @@ static struct config_bool ConfigureNamesBool[] =
                false, NULL, NULL
        },
 
+       {
+               {"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+                       gettext_noop("Enable synchronized sequential scans."),
+                       NULL
+               },
+               &synchronize_seqscans,
+               true, NULL, NULL
+       },
+
        {
                {"archive_mode", PGC_POSTMASTER, WAL_SETTINGS,
                        gettext_noop("Allows archiving of WAL files using archive_command."),
@@ -1185,16 +1195,10 @@ static struct config_int ConfigureNamesInt[] =
        },
 
        /*
-        * Note: There is some postprocessing done in PostmasterMain() to make
-        * sure the buffers are at least twice the number of backends, so the
-        * constraints here are partially unused. Similarly, the superuser
-        * reserved number is checked to ensure it is less than the max backends
-        * number.
-        *
-        * MaxBackends is limited to INT_MAX/4 because some places compute
-        * 4*MaxBackends without any overflow check.  This check is made on
+        * Note: MaxBackends is limited to INT_MAX/4 because some places compute
+        * 4*MaxBackends without any overflow check.  This check is made in
         * assign_maxconnections, since MaxBackends is computed as MaxConnections
-        * + autovacuum_max_workers.
+        * plus autovacuum_max_workers.
         *
         * Likewise we have to limit NBuffers to INT_MAX/2.
         */
@@ -1831,7 +1835,7 @@ static struct config_real ConfigureNamesReal[] =
 
        {
                {"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES,
-                       gettext_noop("Background writer multiplier on average buffers to scan per round."),
+                       gettext_noop("Multiple of the average buffer usage to free per round."),
                        NULL
                },
                &bgwriter_lru_multiplier,
@@ -1845,7 +1849,7 @@ static struct config_real ConfigureNamesReal[] =
                        GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
                },
                &phony_random_seed,
-               0.5, 0.0, 1.0, assign_random_seed, show_random_seed
+               0.0, -1.0, 1.0, assign_random_seed, show_random_seed
        },
 
        {
@@ -1931,7 +1935,7 @@ static struct config_string ConfigureNamesString[] =
                                                 "includes all the levels that follow it.")
                },
                &log_min_messages_str,
-               "notice", assign_log_min_messages, NULL
+               "warning", assign_log_min_messages, NULL
        },
 
        {
@@ -2022,9 +2026,9 @@ static struct config_string ConfigureNamesString[] =
 
        {
                {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
-                       gettext_noop("Sets the sessions behavior for triggers and rewrite rules."),
+                       gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
                        gettext_noop("Each session can be either"
-                                                " \"origin\", \"replica\" or \"local\".")
+                                                " \"origin\", \"replica\", or \"local\".")
                },
                &session_replication_role_string,
                "origin", assign_session_replication_role, NULL
@@ -4157,7 +4161,7 @@ call_string_assign_hook(GucStringAssignHook assign_hook,
  * 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
  * 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
  * mechanism, so don't blame me.  In all other cases, the function
  * returns true, including cases where the input is valid but we chose
@@ -4180,7 +4184,7 @@ set_config_option(const char *name, const char *value,
                 * To avoid cluttering the log, only the postmaster bleats loudly
                 * about problems with the config file.
                 */
-               elevel = IsUnderPostmaster ? DEBUG2 : LOG;
+               elevel = IsUnderPostmaster ? DEBUG3 : LOG;
        }
        else if (source == PGC_S_DATABASE || source == PGC_S_USER)
                elevel = INFO;
@@ -4803,6 +4807,51 @@ 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_OVERRIDE)
+       {
+               /*
+                * If we're a postmaster child, this is probably "undo" during
+                * transaction abort, so we don't want to clutter the log.  There's
+                * a small chance of a real problem with an OVERRIDE setting,
+                * though, so suppressing the message entirely wouldn't be desirable.
+                */
+               elevel = IsUnderPostmaster ? DEBUG5 : LOG;
+       }
+       else if (source < PGC_S_INTERACTIVE)
+               elevel = LOG;
+       else
+               elevel = ERROR;
+
+       return elevel;
+}
+
+
 /*
  * flatten_set_variable_args
  *             Given a parsenode List as emitted by the grammar for SET,
@@ -6406,9 +6455,8 @@ assign_log_destination(const char *value, bool doit, GucSource source)
                /* syntax error in list */
                pfree(rawstring);
                list_free(elemlist);
-               if (source >= PGC_S_INTERACTIVE)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+               ereport(GUC_complaint_elevel(source),
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                        errmsg("invalid list syntax for parameter \"log_destination\"")));
                return NULL;
        }
@@ -6431,9 +6479,8 @@ assign_log_destination(const char *value, bool doit, GucSource source)
 #endif
                else
                {
-                       if (source >= PGC_S_INTERACTIVE)
-                               ereport(ERROR,
-                                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                       ereport(GUC_complaint_elevel(source),
+                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                  errmsg("unrecognized \"log_destination\" key word: \"%s\"",
                                                 tok)));
                        pfree(rawstring);
@@ -6719,10 +6766,9 @@ assign_phony_autocommit(bool newval, bool doit, GucSource source)
 {
        if (!newval)
        {
-               if (doit && source >= PGC_S_INTERACTIVE)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                        errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
+               ereport(GUC_complaint_elevel(source),
+                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                                errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
                return false;
        }
        return true;
@@ -6791,9 +6837,12 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
 {
 #ifndef USE_ASSERT_CHECKING
        if (newval)
-               ereport(ERROR,
+       {
+               ereport(GUC_complaint_elevel(source),
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                           errmsg("assertion checking is not supported by this build")));
+               return false;
+       }
 #endif
        return true;
 }
@@ -6803,9 +6852,12 @@ assign_ssl(bool newval, bool doit, GucSource source)
 {
 #ifndef USE_SSL
        if (newval)
-               ereport(ERROR,
+       {
+               ereport(GUC_complaint_elevel(source),
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 errmsg("SSL is not supported by this build")));
+               return false;
+       }
 #endif
        return true;
 }
@@ -6815,12 +6867,11 @@ assign_stage_log_stats(bool newval, bool doit, GucSource source)
 {
        if (newval && log_statement_stats)
        {
-               if (source >= PGC_S_INTERACTIVE)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                        errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
+               ereport(GUC_complaint_elevel(source),
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
                /* 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 true;
@@ -6832,14 +6883,13 @@ assign_log_stats(bool newval, bool doit, GucSource source)
        if (newval &&
                (log_parser_stats || log_planner_stats || log_executor_stats))
        {
-               if (source >= PGC_S_INTERACTIVE)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                        errmsg("cannot enable \"log_statement_stats\" when "
-                                                       "\"log_parser_stats\", \"log_planner_stats\", "
-                                                       "or \"log_executor_stats\" is true")));
+               ereport(GUC_complaint_elevel(source),
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                errmsg("cannot enable \"log_statement_stats\" when "
+                                               "\"log_parser_stats\", \"log_planner_stats\", "
+                                               "or \"log_executor_stats\" is true")));
                /* 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 true;
@@ -6851,12 +6901,11 @@ assign_transaction_read_only(bool newval, bool doit, GucSource source)
        /* Can't go to r/w mode inside a r/o transaction */
        if (newval == false && XactReadOnly && IsSubTransaction())
        {
-               if (source >= PGC_S_INTERACTIVE)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                        errmsg("cannot set transaction read-write mode inside a read-only transaction")));
+               ereport(GUC_complaint_elevel(source),
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                errmsg("cannot set transaction read-write mode inside a read-only transaction")));
                /* 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 true;
@@ -6934,7 +6983,7 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
                 * and we use WARNING message level.
                 */
                if (source == PGC_S_FILE)
-                       elevel = IsUnderPostmaster ? DEBUG2 : LOG;
+                       elevel = IsUnderPostmaster ? DEBUG3 : LOG;
                else
                        elevel = WARNING;
                if (!load_tzoffsets(newval, doit, elevel))