]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/misc/guc.c
Add option to pg_ctl to choose event source for logging
[postgresql] / src / backend / utils / misc / guc.c
index 1d094f00c61062876986edbd53a54a2b77d9609a..6c52db859032af33eccb1eb53a890506f4e7b181 100644 (file)
@@ -174,7 +174,6 @@ static void assign_syslog_ident(const char *newval, void *extra);
 static void assign_session_replication_role(int newval, void *extra);
 static bool check_temp_buffers(int *newval, void **extra, GucSource source);
 static bool check_phony_autocommit(bool *newval, void **extra, GucSource source);
-static bool check_debug_assertions(bool *newval, void **extra, GucSource source);
 static bool check_bonjour(bool *newval, void **extra, GucSource source);
 static bool check_ssl(bool *newval, void **extra, GucSource source);
 static bool check_stage_log_stats(bool *newval, void **extra, GucSource source);
@@ -199,6 +198,7 @@ static void assign_effective_io_concurrency(int newval, void *extra);
 static void assign_pgstat_temp_directory(const char *newval, void *extra);
 static bool check_application_name(char **newval, void **extra, GucSource source);
 static void assign_application_name(const char *newval, void *extra);
+static bool check_cluster_name(char **newval, void **extra, GucSource source);
 static const char *show_unix_socket_permissions(void);
 static const char *show_log_file_mode(void);
 
@@ -413,11 +413,6 @@ extern const struct config_enum_entry dynamic_shared_memory_options[];
 /*
  * GUC option variables that are exported from this module
  */
-#ifdef USE_ASSERT_CHECKING
-bool           assert_enabled = true;
-#else
-bool           assert_enabled = false;
-#endif
 bool           log_duration = false;
 bool           Debug_print_plan = false;
 bool           Debug_print_parse = false;
@@ -449,6 +444,7 @@ int                 temp_file_limit = -1;
 
 int                    num_temp_buffers = 1024;
 
+char      *cluster_name = "";
 char      *data_directory;
 char      *ConfigFileName;
 char      *HbaFileName;
@@ -500,6 +496,7 @@ static bool data_checksums;
 static int     wal_segment_size;
 static bool integer_datetimes;
 static int     effective_io_concurrency;
+static bool    assert_enabled;
 
 /* should be static, but commands/variable.c needs to get at this */
 char      *role_string;
@@ -931,10 +928,10 @@ static struct config_bool ConfigureNamesBool[] =
                NULL, NULL, NULL
        },
        {
-               {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
-                       gettext_noop("Turns on various assertion checks."),
-                       gettext_noop("This is a debugging aid."),
-                       GUC_NOT_IN_SAMPLE
+               {"debug_assertions", PGC_INTERNAL, PRESET_OPTIONS,
+                       gettext_noop("Shows whether the running server has assertion checks enabled."),
+                       NULL,
+                       GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
                },
                &assert_enabled,
 #ifdef USE_ASSERT_CHECKING
@@ -942,7 +939,7 @@ static struct config_bool ConfigureNamesBool[] =
 #else
                false,
 #endif
-               check_debug_assertions, NULL, NULL
+               NULL, NULL, NULL
        },
 
        {
@@ -3022,7 +3019,7 @@ static struct config_string ConfigureNamesString[] =
                        NULL
                },
                &event_source,
-               "PostgreSQL",
+               DEFAULT_EVENT_SOURCE,
                NULL, NULL, NULL
        },
 
@@ -3095,10 +3092,14 @@ static struct config_string ConfigureNamesString[] =
        },
 
        {
+               /*
+                * Can't be set by ALTER SYSTEM as it can lead to recursive definition
+                * of data_directory.
+                */
                {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
                        gettext_noop("Sets the server's data directory."),
                        NULL,
-                       GUC_SUPERUSER_ONLY
+                       GUC_SUPERUSER_ONLY | GUC_DISALLOW_IN_AUTO_FILE
                },
                &data_directory,
                NULL,
@@ -3262,6 +3263,17 @@ static struct config_string ConfigureNamesString[] =
                check_application_name, assign_application_name, NULL
        },
 
+       {
+               {"cluster_name", PGC_POSTMASTER, LOGGING_WHAT,
+                       gettext_noop("Sets the name of the cluster which is included in the process title."),
+                       NULL,
+                       GUC_IS_NAME
+               },
+               &cluster_name,
+               "",
+               check_cluster_name, NULL, NULL
+       },
+
        /* End-of-list marker */
        {
                {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL, NULL
@@ -6735,12 +6747,17 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
                                (errcode(ERRCODE_UNDEFINED_OBJECT),
                           errmsg("unrecognized configuration parameter \"%s\"", name)));
 
+       /*
+        * Don't allow the parameters which can't be set in configuration
+        * files to be set in PG_AUTOCONF_FILENAME file.
+        */
        if ((record->context == PGC_INTERNAL) ||
-               (record->flags & GUC_DISALLOW_IN_FILE))
-               ereport(ERROR,
-                               (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
-                                errmsg("parameter \"%s\" cannot be changed",
-                                               name)));
+               (record->flags & GUC_DISALLOW_IN_FILE) ||
+               (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
+                ereport(ERROR,
+                                (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
+                                 errmsg("parameter \"%s\" cannot be changed",
+                                                name)));
 
        if (!validate_conf_option(record, name, value, PGC_S_FILE,
                                                          ERROR, true, NULL,
@@ -9108,19 +9125,6 @@ check_phony_autocommit(bool *newval, void **extra, GucSource source)
        return true;
 }
 
-static bool
-check_debug_assertions(bool *newval, void **extra, GucSource source)
-{
-#ifndef USE_ASSERT_CHECKING
-       if (*newval)
-       {
-               GUC_check_errmsg("assertion checking is not supported by this build");
-               return false;
-       }
-#endif
-       return true;
-}
-
 static bool
 check_bonjour(bool *newval, void **extra, GucSource source)
 {
@@ -9479,6 +9483,21 @@ assign_application_name(const char *newval, void *extra)
        pgstat_report_appname(newval);
 }
 
+static bool
+check_cluster_name(char **newval, void **extra, GucSource source)
+{
+       /* Only allow clean ASCII chars in the cluster name */
+       char       *p;
+
+       for (p = *newval; *p; p++)
+       {
+               if (*p < 32 || *p > 126)
+                       *p = '?';
+       }
+
+       return true;
+}
+
 static const char *
 show_unix_socket_permissions(void)
 {