1 /*--------------------------------------------------------------------
4 * Support for grand unified configuration scheme, including SET
5 * command, configuration file, and command line options.
6 * See src/backend/utils/misc/README for more information.
9 * Copyright (c) 2000-2006, PostgreSQL Global Development Group
10 * Written by Peter Eisentraut <peter_e@gmx.net>.
13 * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.315 2006/04/10 21:53:38 tgl Exp $
15 *--------------------------------------------------------------------
28 #include "utils/guc.h"
29 #include "utils/guc_tables.h"
31 #include "access/twophase.h"
32 #include "catalog/namespace.h"
33 #include "catalog/pg_type.h"
34 #include "commands/async.h"
35 #include "commands/variable.h"
36 #include "commands/vacuum.h"
37 #include "executor/executor.h"
40 #include "libpq/auth.h"
41 #include "libpq/pqcomm.h"
42 #include "libpq/pqformat.h"
43 #include "mb/pg_wchar.h"
44 #include "miscadmin.h"
45 #include "optimizer/cost.h"
46 #include "optimizer/geqo.h"
47 #include "optimizer/paths.h"
48 #include "optimizer/planmain.h"
49 #include "parser/parse_expr.h"
50 #include "parser/parse_relation.h"
51 #include "parser/scansup.h"
52 #include "postmaster/autovacuum.h"
53 #include "postmaster/bgwriter.h"
54 #include "postmaster/syslogger.h"
55 #include "postmaster/postmaster.h"
56 #include "storage/bufmgr.h"
57 #include "storage/fd.h"
58 #include "storage/freespace.h"
59 #include "storage/lock.h"
60 #include "storage/proc.h"
61 #include "tcop/tcopprot.h"
62 #include "utils/array.h"
63 #include "utils/builtins.h"
64 #include "utils/memutils.h"
65 #include "utils/pg_locale.h"
70 #define PG_KRB_SRVTAB ""
73 #define PG_KRB_SRVNAM ""
76 #define CONFIG_FILENAME "postgresql.conf"
77 #define HBA_FILENAME "pg_hba.conf"
78 #define IDENT_FILENAME "pg_ident.conf"
81 #define CONFIG_EXEC_PARAMS "global/config_exec_params"
82 #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
85 /* upper limit for GUC variables measured in kilobytes of memory */
87 #define MAX_KILOBYTES INT_MAX
89 #define MAX_KILOBYTES (INT_MAX / 1024)
92 /* XXX these should appear in other modules' header files */
93 extern bool Log_disconnections;
94 extern bool check_function_bodies;
95 extern int CommitDelay;
96 extern int CommitSiblings;
97 extern char *default_tablespace;
98 extern bool fullPageWrites;
101 extern bool trace_sort;
104 static const char *assign_log_destination(const char *value,
105 bool doit, GucSource source);
108 static int syslog_facility = LOG_LOCAL0;
110 static const char *assign_syslog_facility(const char *facility,
111 bool doit, GucSource source);
112 static const char *assign_syslog_ident(const char *ident,
113 bool doit, GucSource source);
116 static const char *assign_defaultxactisolevel(const char *newval, bool doit,
118 static const char *assign_log_min_messages(const char *newval, bool doit,
120 static const char *assign_client_min_messages(const char *newval,
121 bool doit, GucSource source);
122 static const char *assign_min_error_statement(const char *newval, bool doit,
124 static const char *assign_msglvl(int *var, const char *newval, bool doit,
126 static const char *assign_log_error_verbosity(const char *newval, bool doit,
128 static const char *assign_log_statement(const char *newval, bool doit,
130 static const char *show_num_temp_buffers(void);
131 static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
132 static const char *assign_custom_variable_classes(const char *newval, bool doit,
134 static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
135 static bool assign_ssl(bool newval, bool doit, GucSource source);
136 static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
137 static bool assign_log_stats(bool newval, bool doit, GucSource source);
138 static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
139 static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
141 static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
142 static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);
143 static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source);
144 static const char *show_tcp_keepalives_idle(void);
145 static const char *show_tcp_keepalives_interval(void);
146 static const char *show_tcp_keepalives_count(void);
149 * GUC option variables that are exported from this module
151 #ifdef USE_ASSERT_CHECKING
152 bool assert_enabled = true;
154 bool assert_enabled = false;
156 bool log_duration = false;
157 bool Debug_print_plan = false;
158 bool Debug_print_parse = false;
159 bool Debug_print_rewritten = false;
160 bool Debug_pretty_print = false;
161 bool Explain_pretty_print = true;
163 bool log_parser_stats = false;
164 bool log_planner_stats = false;
165 bool log_executor_stats = false;
166 bool log_statement_stats = false; /* this is sort of all three
168 bool log_btree_build_stats = false;
170 bool SQL_inheritance = true;
172 bool Australian_timezones = false;
174 bool Password_encryption = true;
176 bool default_with_oids = false;
178 int log_min_error_statement = PANIC;
179 int log_min_messages = NOTICE;
180 int client_min_messages = NOTICE;
181 int log_min_duration_statement = -1;
183 int num_temp_buffers = 1000;
185 char *ConfigFileName;
188 char *external_pid_file;
190 int tcp_keepalives_idle;
191 int tcp_keepalives_interval;
192 int tcp_keepalives_count;
195 * These variables are all dummies that don't do anything, except in some
196 * cases provide the value for SHOW to display. The real state is elsewhere
197 * and is kept in sync by assign_hooks.
199 static char *client_min_messages_str;
200 static char *log_min_messages_str;
201 static char *log_error_verbosity_str;
202 static char *log_statement_str;
203 static char *log_min_error_statement_str;
204 static char *log_destination_string;
206 static char *syslog_facility_str;
207 static char *syslog_ident_str;
209 static bool phony_autocommit;
210 static bool session_auth_is_superuser;
211 static double phony_random_seed;
212 static char *client_encoding_string;
213 static char *datestyle_string;
214 static char *default_iso_level_string;
215 static char *locale_collate;
216 static char *locale_ctype;
217 static char *regex_flavor_string;
218 static char *server_encoding_string;
219 static char *server_version_string;
220 static char *timezone_string;
221 static char *XactIsoLevel_string;
222 static char *data_directory;
223 static char *custom_variable_classes;
224 static int max_function_args;
225 static int max_index_keys;
226 static int max_identifier_length;
227 static int block_size;
228 static bool integer_datetimes;
230 /* should be static, but commands/variable.c needs to get at these */
232 char *session_authorization_string;
236 * Displayable names for context types (enum GucContext)
238 * Note: these strings are deliberately not localized.
240 const char *const GucContext_Names[] =
242 /* PGC_INTERNAL */ "internal",
243 /* PGC_POSTMASTER */ "postmaster",
244 /* PGC_SIGHUP */ "sighup",
245 /* PGC_BACKEND */ "backend",
246 /* PGC_SUSET */ "superuser",
247 /* PGC_USERSET */ "user"
251 * Displayable names for source types (enum GucSource)
253 * Note: these strings are deliberately not localized.
255 const char *const GucSource_Names[] =
257 /* PGC_S_DEFAULT */ "default",
258 /* PGC_S_ENV_VAR */ "environment variable",
259 /* PGC_S_FILE */ "configuration file",
260 /* PGC_S_ARGV */ "command line",
261 /* PGC_S_DATABASE */ "database",
262 /* PGC_S_USER */ "user",
263 /* PGC_S_CLIENT */ "client",
264 /* PGC_S_OVERRIDE */ "override",
265 /* PGC_S_INTERACTIVE */ "interactive",
266 /* PGC_S_TEST */ "test",
267 /* PGC_S_SESSION */ "session"
271 * Displayable names for the groupings defined in enum config_group
273 const char *const config_group_names[] =
276 gettext_noop("Ungrouped"),
278 gettext_noop("File Locations"),
280 gettext_noop("Connections and Authentication"),
281 /* CONN_AUTH_SETTINGS */
282 gettext_noop("Connections and Authentication / Connection Settings"),
283 /* CONN_AUTH_SECURITY */
284 gettext_noop("Connections and Authentication / Security and Authentication"),
286 gettext_noop("Resource Usage"),
288 gettext_noop("Resource Usage / Memory"),
290 gettext_noop("Resource Usage / Free Space Map"),
291 /* RESOURCES_KERNEL */
292 gettext_noop("Resource Usage / Kernel Resources"),
294 gettext_noop("Write-Ahead Log"),
296 gettext_noop("Write-Ahead Log / Settings"),
297 /* WAL_CHECKPOINTS */
298 gettext_noop("Write-Ahead Log / Checkpoints"),
300 gettext_noop("Query Tuning"),
301 /* QUERY_TUNING_METHOD */
302 gettext_noop("Query Tuning / Planner Method Configuration"),
303 /* QUERY_TUNING_COST */
304 gettext_noop("Query Tuning / Planner Cost Constants"),
305 /* QUERY_TUNING_GEQO */
306 gettext_noop("Query Tuning / Genetic Query Optimizer"),
307 /* QUERY_TUNING_OTHER */
308 gettext_noop("Query Tuning / Other Planner Options"),
310 gettext_noop("Reporting and Logging"),
312 gettext_noop("Reporting and Logging / Where to Log"),
314 gettext_noop("Reporting and Logging / When to Log"),
316 gettext_noop("Reporting and Logging / What to Log"),
318 gettext_noop("Statistics"),
319 /* STATS_MONITORING */
320 gettext_noop("Statistics / Monitoring"),
321 /* STATS_COLLECTOR */
322 gettext_noop("Statistics / Query and Index Statistics Collector"),
324 gettext_noop("Autovacuum"),
326 gettext_noop("Client Connection Defaults"),
327 /* CLIENT_CONN_STATEMENT */
328 gettext_noop("Client Connection Defaults / Statement Behavior"),
329 /* CLIENT_CONN_LOCALE */
330 gettext_noop("Client Connection Defaults / Locale and Formatting"),
331 /* CLIENT_CONN_OTHER */
332 gettext_noop("Client Connection Defaults / Other Defaults"),
333 /* LOCK_MANAGEMENT */
334 gettext_noop("Lock Management"),
336 gettext_noop("Version and Platform Compatibility"),
337 /* COMPAT_OPTIONS_PREVIOUS */
338 gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
339 /* COMPAT_OPTIONS_CLIENT */
340 gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
342 gettext_noop("Preset Options"),
344 gettext_noop("Customized Options"),
345 /* DEVELOPER_OPTIONS */
346 gettext_noop("Developer Options"),
347 /* help_config wants this array to be null-terminated */
352 * Displayable names for GUC variable types (enum config_type)
354 * Note: these strings are deliberately not localized.
356 const char *const config_type_names[] =
358 /* PGC_BOOL */ "bool",
359 /* PGC_INT */ "integer",
360 /* PGC_REAL */ "real",
361 /* PGC_STRING */ "string"
366 * Contents of GUC tables
368 * See src/backend/utils/misc/README for design notes.
372 * 1. Declare a global variable of type bool, int, double, or char*
373 * and make use of it.
375 * 2. Decide at what times it's safe to set the option. See guc.h for
378 * 3. Decide on a name, a default value, upper and lower bounds (if
381 * 4. Add a record below.
383 * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
386 * 6. Add it to src/bin/psql/tab-complete.c, if it's a USERSET option.
388 * 7. Don't forget to document the option.
390 * 8. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
391 * it is not single quoted at dump time.
395 /******** option records follow ********/
397 static struct config_bool ConfigureNamesBool[] =
400 {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
401 gettext_noop("Enables the planner's use of sequential-scan plans."),
408 {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
409 gettext_noop("Enables the planner's use of index-scan plans."),
416 {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
417 gettext_noop("Enables the planner's use of bitmap-scan plans."),
424 {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
425 gettext_noop("Enables the planner's use of TID scan plans."),
432 {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
433 gettext_noop("Enables the planner's use of explicit sort steps."),
440 {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
441 gettext_noop("Enables the planner's use of hashed aggregation plans."),
448 {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
449 gettext_noop("Enables the planner's use of nested-loop join plans."),
456 {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
457 gettext_noop("Enables the planner's use of merge join plans."),
464 {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
465 gettext_noop("Enables the planner's use of hash join plans."),
472 {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
473 gettext_noop("Enables the planner to use constraints to optimize queries."),
474 gettext_noop("Child table scans will be skipped if their "
475 "constraints guarantee that no rows match the query.")
477 &constraint_exclusion,
481 {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
482 gettext_noop("Enables genetic query optimization."),
483 gettext_noop("This algorithm attempts to do planning without "
484 "exhaustive searching.")
490 /* Not for general use --- used by SET SESSION AUTHORIZATION */
491 {"is_superuser", PGC_INTERNAL, UNGROUPED,
492 gettext_noop("Shows whether the current user is a superuser."),
494 GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
496 &session_auth_is_superuser,
500 {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
501 gettext_noop("Enables SSL connections."),
505 false, assign_ssl, NULL
508 {"fsync", PGC_SIGHUP, WAL_SETTINGS,
509 gettext_noop("Forces synchronization of updates to disk."),
510 gettext_noop("The server will use the fsync() system call in several places to make "
511 "sure that updates are physically written to disk. This insures "
512 "that a database cluster will recover to a consistent state after "
513 "an operating system or hardware crash.")
519 {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
520 gettext_noop("Continues processing past damaged page headers."),
521 gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
522 "report an error, aborting the current transaction. Setting "
523 "zero_damaged_pages to true causes the system to instead report a "
524 "warning, zero out the damaged page, and continue processing. This "
525 "behavior will destroy data, namely all the rows on the damaged page."),
532 {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
533 gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
534 gettext_noop("A page write in process during an operating system crash might be "
535 "only partially written to disk. During recovery, the row changes "
536 "stored in WAL are not enough to recover. This option writes "
537 "pages when first modified after a checkpoint to WAL so full recovery "
544 {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
545 gettext_noop("Runs the server silently."),
546 gettext_noop("If this parameter is set, the server will automatically run in the "
547 "background and any controlling terminals are dissociated.")
553 {"log_connections", PGC_BACKEND, LOGGING_WHAT,
554 gettext_noop("Logs each successful connection."),
561 {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
562 gettext_noop("Logs end of a session, including duration."),
569 {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
570 gettext_noop("Turns on various assertion checks."),
571 gettext_noop("This is a debugging aid."),
575 #ifdef USE_ASSERT_CHECKING
580 assign_debug_assertions, NULL
583 /* currently undocumented, so don't show in SHOW ALL */
584 {"exit_on_error", PGC_USERSET, UNGROUPED,
585 gettext_noop("no description available"),
587 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
593 {"log_duration", PGC_SUSET, LOGGING_WHAT,
594 gettext_noop("Logs the duration of each completed SQL statement."),
601 {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
602 gettext_noop("Prints the parse tree to the server log."),
609 {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
610 gettext_noop("Prints the parse tree after rewriting to server log."),
613 &Debug_print_rewritten,
617 {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
618 gettext_noop("Prints the execution plan to server log."),
625 {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
626 gettext_noop("Indents parse and plan tree displays."),
633 {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
634 gettext_noop("Writes parser performance statistics to the server log."),
638 false, assign_stage_log_stats, NULL
641 {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
642 gettext_noop("Writes planner performance statistics to the server log."),
646 false, assign_stage_log_stats, NULL
649 {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
650 gettext_noop("Writes executor performance statistics to the server log."),
654 false, assign_stage_log_stats, NULL
657 {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
658 gettext_noop("Writes cumulative performance statistics to the server log."),
661 &log_statement_stats,
662 false, assign_log_stats, NULL
664 #ifdef BTREE_BUILD_STATS
666 {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
667 gettext_noop("no description available"),
671 &log_btree_build_stats,
677 {"explain_pretty_print", PGC_USERSET, CLIENT_CONN_OTHER,
678 gettext_noop("Uses the indented output format for EXPLAIN VERBOSE."),
681 &Explain_pretty_print,
685 {"stats_start_collector", PGC_POSTMASTER, STATS_COLLECTOR,
686 gettext_noop("Starts the server statistics-collection subprocess."),
689 &pgstat_collect_startcollector,
693 {"stats_reset_on_server_start", PGC_POSTMASTER, STATS_COLLECTOR,
694 gettext_noop("Zeroes collected statistics on server restart."),
697 &pgstat_collect_resetonpmstart,
701 {"stats_command_string", PGC_SUSET, STATS_COLLECTOR,
702 gettext_noop("Collects statistics about executing commands."),
703 gettext_noop("Enables the collection of statistics on the currently "
704 "executing command of each session, along with the time "
705 "at which that command began execution.")
707 &pgstat_collect_querystring,
711 {"stats_row_level", PGC_SUSET, STATS_COLLECTOR,
712 gettext_noop("Collects row-level statistics on database activity."),
715 &pgstat_collect_tuplelevel,
719 {"stats_block_level", PGC_SUSET, STATS_COLLECTOR,
720 gettext_noop("Collects block-level statistics on database activity."),
723 &pgstat_collect_blocklevel,
728 {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
729 gettext_noop("Starts the autovacuum subprocess."),
732 &autovacuum_start_daemon,
737 {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
738 gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
748 {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
749 gettext_noop("no description available"),
757 {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
758 gettext_noop("no description available"),
766 {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
767 gettext_noop("no description available"),
775 {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
776 gettext_noop("no description available"),
786 {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
787 gettext_noop("Logs the host name in the connection logs."),
788 gettext_noop("By default, connection logs only show the IP address "
789 "of the connecting host. If you want them to show the host name you "
790 "can turn this on, but depending on your host name resolution "
791 "setup it might impose a non-negligible performance penalty.")
797 {"sql_inheritance", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
798 gettext_noop("Causes subtables to be included by default in various commands."),
805 {"australian_timezones", PGC_USERSET, CLIENT_CONN_LOCALE,
806 gettext_noop("Interprets ACST, CST, EST, and SAT as Australian time zones."),
807 gettext_noop("Otherwise they are interpreted as North/South American "
808 "time zones and Saturday.")
810 &Australian_timezones,
811 false, ClearDateCache, NULL
814 {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
815 gettext_noop("Encrypt passwords."),
816 gettext_noop("When a password is specified in CREATE USER or "
817 "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
818 "this parameter determines whether the password is to be encrypted.")
820 &Password_encryption,
824 {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
825 gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
826 gettext_noop("When turned on, expressions of the form expr = NULL "
827 "(or NULL = expr) are treated as expr IS NULL, that is, they "
828 "return true if expr evaluates to the null value, and false "
829 "otherwise. The correct behavior of expr = NULL is to always "
830 "return null (unknown).")
832 &Transform_null_equals,
836 {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
837 gettext_noop("Enables per-database user names."),
844 /* only here for backwards compatibility */
845 {"autocommit", PGC_USERSET, CLIENT_CONN_STATEMENT,
846 gettext_noop("This parameter doesn't do anything."),
847 gettext_noop("It's just here so that we won't choke on SET AUTOCOMMIT TO ON from 7.3-vintage clients."),
848 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
851 true, assign_phony_autocommit, NULL
854 {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
855 gettext_noop("Sets the default read-only status of new transactions."),
858 &DefaultXactReadOnly,
862 {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
863 gettext_noop("Sets the current transaction's read-only status."),
865 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
868 false, assign_transaction_read_only, NULL
871 {"add_missing_from", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
872 gettext_noop("Automatically adds missing table references to FROM clauses."),
879 {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
880 gettext_noop("Check function bodies during CREATE FUNCTION."),
883 &check_function_bodies,
887 {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
888 gettext_noop("Enable input of NULL elements in arrays."),
889 gettext_noop("When turned on, unquoted NULL in an array input "
890 "value means a NULL value; "
891 "otherwise it is taken literally.")
897 {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
898 gettext_noop("Create new tables with OIDs by default."),
905 {"redirect_stderr", PGC_POSTMASTER, LOGGING_WHERE,
906 gettext_noop("Start a subprocess to capture stderr output into log files."),
913 {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
914 gettext_noop("Truncate existing log files of same name during log rotation."),
917 &Log_truncate_on_rotation,
923 {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
924 gettext_noop("Emit information about resource usage in sorting."),
935 {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
936 gettext_noop("Emit WAL-related debugging output."),
946 {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
947 gettext_noop("Datetimes are integer based."),
949 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
952 #ifdef HAVE_INT64_TIMESTAMP
960 {"krb_caseins_users", PGC_POSTMASTER, CONN_AUTH_SECURITY,
961 gettext_noop("Sets whether Kerberos user names should be treated as case-insensitive."),
964 &pg_krb_caseins_users,
969 {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
970 gettext_noop("Warn about backslash escapes in ordinary string literals."),
973 &escape_string_warning,
978 {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
979 gettext_noop("'...' strings treat backslashes literally."),
983 &standard_conforming_strings,
988 {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
989 gettext_noop("Allows modifications of the structure of system tables."),
993 &allowSystemTableMods,
998 {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
999 gettext_noop("Disabled reading from system indexes."),
1000 gettext_noop("It does not prevent updating the indexes, so it is safe "
1001 "to use. The worst consequence is slowness."),
1004 &IgnoreSystemIndexes,
1008 /* End-of-list marker */
1010 {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
1015 static struct config_int ConfigureNamesInt[] =
1018 {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1019 gettext_noop("Waits N seconds on connection startup after authentication."),
1020 gettext_noop("This allows attaching a debugger to the process."),
1024 0, 0, INT_MAX, NULL, NULL
1027 {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1028 gettext_noop("Sets the default statistics target."),
1029 gettext_noop("This applies to table columns that have not had a "
1030 "column-specific target set via ALTER TABLE SET STATISTICS.")
1032 &default_statistics_target,
1033 10, 1, 1000, NULL, NULL
1036 {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1037 gettext_noop("Sets the FROM-list size beyond which subqueries are not "
1039 gettext_noop("The planner will merge subqueries into upper "
1040 "queries if the resulting FROM list would have no more than "
1043 &from_collapse_limit,
1044 8, 1, INT_MAX, NULL, NULL
1047 {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1048 gettext_noop("Sets the FROM-list size beyond which JOIN constructs are not "
1050 gettext_noop("The planner will flatten explicit JOIN "
1051 "constructs into lists of FROM items whenever a list of no more "
1052 "than this many items would result.")
1054 &join_collapse_limit,
1055 8, 1, INT_MAX, NULL, NULL
1058 {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1059 gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1063 12, 2, INT_MAX, NULL, NULL
1066 {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1067 gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1071 DEFAULT_GEQO_EFFORT, MIN_GEQO_EFFORT, MAX_GEQO_EFFORT, NULL, NULL
1074 {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1075 gettext_noop("GEQO: number of individuals in the population."),
1076 gettext_noop("Zero selects a suitable default value.")
1079 0, 0, INT_MAX, NULL, NULL
1082 {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1083 gettext_noop("GEQO: number of iterations of the algorithm."),
1084 gettext_noop("Zero selects a suitable default value.")
1087 0, 0, INT_MAX, NULL, NULL
1091 {"deadlock_timeout", PGC_SIGHUP, LOCK_MANAGEMENT,
1092 gettext_noop("The time in milliseconds to wait on lock before checking for deadlock."),
1096 1000, 0, INT_MAX, NULL, NULL
1100 * Note: There is some postprocessing done in PostmasterMain() to make
1101 * sure the buffers are at least twice the number of backends, so the
1102 * constraints here are partially unused. Similarly, the superuser
1103 * reserved number is checked to ensure it is less than the max backends
1106 * MaxBackends is limited to INT_MAX/4 because some places compute
1107 * 4*MaxBackends without any overflow check. Likewise we have to limit
1108 * NBuffers to INT_MAX/2.
1111 {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1112 gettext_noop("Sets the maximum number of concurrent connections."),
1116 100, 1, INT_MAX / 4, NULL, NULL
1120 {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1121 gettext_noop("Sets the number of connection slots reserved for superusers."),
1125 2, 0, INT_MAX / 4, NULL, NULL
1129 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1130 gettext_noop("Sets the number of shared memory buffers used by the server."),
1134 1000, 16, INT_MAX / 2, NULL, NULL
1138 {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1139 gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1143 1000, 100, INT_MAX / 2, NULL, show_num_temp_buffers
1147 {"port", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1148 gettext_noop("Sets the TCP port the server listens on."),
1152 DEF_PGPORT, 1, 65535, NULL, NULL
1156 {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1157 gettext_noop("Sets the access permissions of the Unix-domain socket."),
1158 gettext_noop("Unix-domain sockets use the usual Unix file system "
1159 "permission set. The parameter value is expected to be an numeric mode "
1160 "specification in the form accepted by the chmod and umask system "
1161 "calls. (To use the customary octal format the number must start with "
1164 &Unix_socket_permissions,
1165 0777, 0000, 0777, NULL, NULL
1169 {"work_mem", PGC_USERSET, RESOURCES_MEM,
1170 gettext_noop("Sets the maximum memory to be used for query workspaces."),
1171 gettext_noop("This much memory may be used by each internal "
1172 "sort operation and hash table before switching to "
1173 "temporary disk files.")
1176 1024, 8 * BLCKSZ / 1024, MAX_KILOBYTES, NULL, NULL
1180 {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1181 gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1182 gettext_noop("This includes operations such as VACUUM and CREATE INDEX.")
1184 &maintenance_work_mem,
1185 16384, 1024, MAX_KILOBYTES, NULL, NULL
1189 {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1190 gettext_noop("Sets the maximum stack depth, in kilobytes."),
1194 2048, 100, MAX_KILOBYTES, assign_max_stack_depth, NULL
1198 {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
1199 gettext_noop("Vacuum cost for a page found in the buffer cache."),
1203 1, 0, 10000, NULL, NULL
1207 {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
1208 gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1211 &VacuumCostPageMiss,
1212 10, 0, 10000, NULL, NULL
1216 {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
1217 gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1220 &VacuumCostPageDirty,
1221 20, 0, 10000, NULL, NULL
1225 {"vacuum_cost_limit", PGC_USERSET, RESOURCES,
1226 gettext_noop("Vacuum cost amount available before napping."),
1230 200, 1, 10000, NULL, NULL
1234 {"vacuum_cost_delay", PGC_USERSET, RESOURCES,
1235 gettext_noop("Vacuum cost delay in milliseconds."),
1239 0, 0, 1000, NULL, NULL
1243 {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
1244 gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
1247 &autovacuum_vac_cost_delay,
1248 -1, -1, 1000, NULL, NULL
1252 {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
1253 gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
1256 &autovacuum_vac_cost_limit,
1257 -1, -1, 10000, NULL, NULL
1261 {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
1262 gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
1265 &max_files_per_process,
1266 1000, 25, INT_MAX, NULL, NULL
1270 {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
1271 gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
1274 &max_prepared_xacts,
1275 5, 0, INT_MAX, NULL, NULL
1280 {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
1281 gettext_noop("no description available"),
1286 FirstNormalObjectId, 0, INT_MAX, NULL, NULL
1289 {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
1290 gettext_noop("no description available"),
1295 0, 0, INT_MAX, NULL, NULL
1300 {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
1301 gettext_noop("Sets the maximum allowed duration (in milliseconds) of any statement."),
1302 gettext_noop("A value of 0 turns off the timeout.")
1305 0, 0, INT_MAX, NULL, NULL
1309 {"max_fsm_relations", PGC_POSTMASTER, RESOURCES_FSM,
1310 gettext_noop("Sets the maximum number of tables and indexes for which free space is tracked."),
1314 1000, 100, INT_MAX, NULL, NULL
1317 {"max_fsm_pages", PGC_POSTMASTER, RESOURCES_FSM,
1318 gettext_noop("Sets the maximum number of disk pages for which free space is tracked."),
1322 20000, 1000, INT_MAX, NULL, NULL
1326 {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
1327 gettext_noop("Sets the maximum number of locks per transaction."),
1328 gettext_noop("The shared lock table is sized on the assumption that "
1329 "at most max_locks_per_transaction * max_connections distinct "
1330 "objects will need to be locked at any one time.")
1332 &max_locks_per_xact,
1333 64, 10, INT_MAX, NULL, NULL
1337 {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
1338 gettext_noop("Sets the maximum time in seconds to complete client authentication."),
1341 &AuthenticationTimeout,
1342 60, 1, 600, NULL, NULL
1346 /* Not for general use */
1347 {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
1348 gettext_noop("no description available"),
1353 0, 0, 60, NULL, NULL
1357 {"checkpoint_segments", PGC_SIGHUP, WAL_CHECKPOINTS,
1358 gettext_noop("Sets the maximum distance in log segments between automatic WAL checkpoints."),
1361 &CheckPointSegments,
1362 3, 1, INT_MAX, NULL, NULL
1366 {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
1367 gettext_noop("Sets the maximum time in seconds between automatic WAL checkpoints."),
1371 300, 30, 3600, NULL, NULL
1375 {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
1376 gettext_noop("Logs if filling of checkpoint segments happens more "
1377 "frequently than this (in seconds)."),
1378 gettext_noop("Write a message to the server log if checkpoints "
1379 "caused by the filling of checkpoint segment files happens more "
1380 "frequently than this number of seconds. Zero turns off the warning.")
1383 30, 0, INT_MAX, NULL, NULL
1387 {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
1388 gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
1392 8, 4, INT_MAX, NULL, NULL
1396 {"commit_delay", PGC_USERSET, WAL_CHECKPOINTS,
1397 gettext_noop("Sets the delay in microseconds between transaction commit and "
1398 "flushing WAL to disk."),
1402 0, 0, 100000, NULL, NULL
1406 {"commit_siblings", PGC_USERSET, WAL_CHECKPOINTS,
1407 gettext_noop("Sets the minimum concurrent open transactions before performing "
1412 5, 1, 1000, NULL, NULL
1416 {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
1417 gettext_noop("Sets the number of digits displayed for floating-point values."),
1418 gettext_noop("This affects real, double precision, and geometric data types. "
1419 "The parameter value is added to the standard number of digits "
1420 "(FLT_DIG or DBL_DIG as appropriate).")
1422 &extra_float_digits,
1423 0, -15, 2, NULL, NULL
1427 {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
1428 gettext_noop("Sets the minimum execution time in milliseconds above which statements will "
1430 gettext_noop("Zero prints all queries. The default is -1 (turning this feature off).")
1432 &log_min_duration_statement,
1433 -1, -1, INT_MAX / 1000, NULL, NULL
1437 {"bgwriter_delay", PGC_SIGHUP, RESOURCES,
1438 gettext_noop("Background writer sleep time between rounds in milliseconds"),
1442 200, 10, 10000, NULL, NULL
1446 {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
1447 gettext_noop("Background writer maximum number of LRU pages to flush per round"),
1450 &bgwriter_lru_maxpages,
1451 5, 0, 1000, NULL, NULL
1455 {"bgwriter_all_maxpages", PGC_SIGHUP, RESOURCES,
1456 gettext_noop("Background writer maximum number of all pages to flush per round"),
1459 &bgwriter_all_maxpages,
1460 5, 0, 1000, NULL, NULL
1464 {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
1465 gettext_noop("Automatic log file rotation will occur after N minutes"),
1469 HOURS_PER_DAY * MINS_PER_HOUR, 0, INT_MAX / MINS_PER_HOUR, NULL, NULL
1473 {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
1474 gettext_noop("Automatic log file rotation will occur after N kilobytes"),
1478 10 * 1024, 0, INT_MAX / 1024, NULL, NULL
1482 {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
1483 gettext_noop("Shows the maximum number of function arguments."),
1485 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1488 FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
1492 {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
1493 gettext_noop("Shows the maximum number of index keys."),
1495 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1498 INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
1502 {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
1503 gettext_noop("Shows the maximum identifier length"),
1505 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1507 &max_identifier_length,
1508 NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
1512 {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
1513 gettext_noop("Shows size of a disk block"),
1515 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1518 BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
1522 {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
1523 gettext_noop("Time to sleep between autovacuum runs, in seconds."),
1526 &autovacuum_naptime,
1527 60, 1, INT_MAX, NULL, NULL
1530 {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
1531 gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
1534 &autovacuum_vac_thresh,
1535 1000, 0, INT_MAX, NULL, NULL
1538 {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
1539 gettext_noop("Minimum number of tuple inserts, updates or deletes prior to analyze."),
1542 &autovacuum_anl_thresh,
1543 500, 0, INT_MAX, NULL, NULL
1547 {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
1548 gettext_noop("Seconds between issuing TCP keepalives."),
1549 gettext_noop("A value of 0 uses the system default."),
1551 &tcp_keepalives_idle,
1552 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle
1556 {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
1557 gettext_noop("Seconds between TCP keepalive retransmits."),
1558 gettext_noop("A value of 0 uses the system default."),
1560 &tcp_keepalives_interval,
1561 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
1565 {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
1566 gettext_noop("Maximum number of TCP keepalive retransmits."),
1567 gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
1568 "lost before a connection is considered dead. A value of 0 uses the "
1571 &tcp_keepalives_count,
1572 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count
1575 /* End-of-list marker */
1577 {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
1582 static struct config_real ConfigureNamesReal[] =
1585 {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
1586 gettext_noop("Sets the planner's assumption about size of the disk cache."),
1587 gettext_noop("That is, the portion of the kernel's disk cache that "
1588 "will be used for PostgreSQL data files. This is measured in disk "
1589 "pages, which are normally 8 kB each.")
1591 &effective_cache_size,
1592 DEFAULT_EFFECTIVE_CACHE_SIZE, 1, DBL_MAX, NULL, NULL
1595 {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1596 gettext_noop("Sets the planner's estimate of the cost of a nonsequentially "
1597 "fetched disk page."),
1598 gettext_noop("This is measured as a multiple of the cost of a "
1599 "sequential page fetch. A higher value makes it more likely a "
1600 "sequential scan will be used, a lower value makes it more likely an "
1601 "index scan will be used.")
1604 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
1607 {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1608 gettext_noop("Sets the planner's estimate of the cost of processing each tuple (row)."),
1609 gettext_noop("This is measured as a fraction of the cost of a "
1610 "sequential page fetch.")
1613 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1616 {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1617 gettext_noop("Sets the planner's estimate of processing cost for each "
1618 "index tuple (row) during index scan."),
1619 gettext_noop("This is measured as a fraction of the cost of a "
1620 "sequential page fetch.")
1622 &cpu_index_tuple_cost,
1623 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1626 {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
1627 gettext_noop("Sets the planner's estimate of processing cost of each operator in WHERE."),
1628 gettext_noop("This is measured as a fraction of the cost of a sequential "
1632 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
1636 {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
1637 gettext_noop("GEQO: selective pressure within the population."),
1640 &Geqo_selection_bias,
1641 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
1642 MAX_GEQO_SELECTION_BIAS, NULL, NULL
1646 {"bgwriter_lru_percent", PGC_SIGHUP, RESOURCES,
1647 gettext_noop("Background writer percentage of LRU buffers to flush per round"),
1650 &bgwriter_lru_percent,
1651 1.0, 0.0, 100.0, NULL, NULL
1655 {"bgwriter_all_percent", PGC_SIGHUP, RESOURCES,
1656 gettext_noop("Background writer percentage of all buffers to flush per round"),
1659 &bgwriter_all_percent,
1660 0.333, 0.0, 100.0, NULL, NULL
1664 {"seed", PGC_USERSET, UNGROUPED,
1665 gettext_noop("Sets the seed for random-number generation."),
1667 GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1670 0.5, 0.0, 1.0, assign_random_seed, show_random_seed
1674 {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1675 gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
1678 &autovacuum_vac_scale,
1679 0.4, 0.0, 100.0, NULL, NULL
1682 {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1683 gettext_noop("Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples."),
1686 &autovacuum_anl_scale,
1687 0.2, 0.0, 100.0, NULL, NULL
1690 /* End-of-list marker */
1692 {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL
1697 static struct config_string ConfigureNamesString[] =
1700 {"archive_command", PGC_SIGHUP, WAL_SETTINGS,
1701 gettext_noop("WAL archiving command."),
1702 gettext_noop("The shell command that will be called to archive a WAL file.")
1704 &XLogArchiveCommand,
1709 {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
1710 gettext_noop("Sets the client's character set encoding."),
1712 GUC_IS_NAME | GUC_REPORT
1714 &client_encoding_string,
1715 "SQL_ASCII", assign_client_encoding, NULL
1719 {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
1720 gettext_noop("Sets the message levels that are sent to the client."),
1721 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, "
1722 "DEBUG1, LOG, NOTICE, WARNING, and ERROR. Each level includes all the "
1723 "levels that follow it. The later the level, the fewer messages are "
1726 &client_min_messages_str,
1727 "notice", assign_client_min_messages, NULL
1731 {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
1732 gettext_noop("Sets the message levels that are logged."),
1733 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, "
1734 "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level "
1735 "includes all the levels that follow it.")
1737 &log_min_messages_str,
1738 "notice", assign_log_min_messages, NULL
1742 {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
1743 gettext_noop("Sets the verbosity of logged messages."),
1744 gettext_noop("Valid values are \"terse\", \"default\", and \"verbose\".")
1746 &log_error_verbosity_str,
1747 "default", assign_log_error_verbosity, NULL
1750 {"log_statement", PGC_SUSET, LOGGING_WHAT,
1751 gettext_noop("Sets the type of statements logged."),
1752 gettext_noop("Valid values are \"none\", \"ddl\", \"mod\", and \"all\".")
1755 "none", assign_log_statement, NULL
1759 {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
1760 gettext_noop("Causes all statements generating error at or above this level to be logged."),
1761 gettext_noop("All SQL statements that cause an error of the "
1762 "specified level or a higher level are logged.")
1764 &log_min_error_statement_str,
1765 "panic", assign_min_error_statement, NULL
1769 {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
1770 gettext_noop("Controls information prefixed to each log line"),
1771 gettext_noop("if blank no prefix is used")
1779 {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
1780 gettext_noop("Sets the display format for date and time values."),
1781 gettext_noop("Also controls interpretation of ambiguous "
1783 GUC_LIST_INPUT | GUC_REPORT
1786 "ISO, MDY", assign_datestyle, NULL
1790 {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
1791 gettext_noop("Sets the default tablespace to create tables and indexes in."),
1792 gettext_noop("An empty string selects the database's default tablespace."),
1795 &default_tablespace,
1796 "", assign_default_tablespace, NULL
1800 {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
1801 gettext_noop("Sets the transaction isolation level of each new transaction."),
1802 gettext_noop("Each SQL transaction has an isolation level, which "
1803 "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
1805 &default_iso_level_string,
1806 "read committed", assign_defaultxactisolevel, NULL
1810 {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
1811 gettext_noop("Sets the path for dynamically loadable modules."),
1812 gettext_noop("If a dynamically loadable module needs to be opened and "
1813 "the specified name does not have a directory component (i.e., the "
1814 "name does not contain a slash), the system will search this path for "
1815 "the specified file."),
1818 &Dynamic_library_path,
1819 "$libdir", NULL, NULL
1823 {"krb_server_keyfile", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1824 gettext_noop("Sets the location of the Kerberos server key file."),
1828 &pg_krb_server_keyfile,
1829 PG_KRB_SRVTAB, NULL, NULL
1833 {"krb_srvname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1834 gettext_noop("Sets the name of the Kerberos service."),
1838 PG_KRB_SRVNAM, NULL, NULL
1842 {"krb_server_hostname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1843 gettext_noop("Sets the hostname of the Kerberos server."),
1846 &pg_krb_server_hostname,
1851 {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1852 gettext_noop("Sets the Bonjour broadcast service name."),
1859 /* See main.c about why defaults for LC_foo are not all alike */
1862 {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1863 gettext_noop("Shows the collation order locale."),
1865 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1872 {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1873 gettext_noop("Shows the character classification and case conversion locale."),
1875 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1882 {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
1883 gettext_noop("Sets the language in which messages are displayed."),
1887 "", locale_messages_assign, NULL
1891 {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
1892 gettext_noop("Sets the locale for formatting monetary amounts."),
1896 "C", locale_monetary_assign, NULL
1900 {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
1901 gettext_noop("Sets the locale for formatting numbers."),
1905 "C", locale_numeric_assign, NULL
1909 {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
1910 gettext_noop("Sets the locale for formatting date and time values."),
1914 "C", locale_time_assign, NULL
1918 {"preload_libraries", PGC_POSTMASTER, RESOURCES_KERNEL,
1919 gettext_noop("Lists shared libraries to preload into server."),
1921 GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
1923 &preload_libraries_string,
1928 {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1929 gettext_noop("Sets the regular expression \"flavor\"."),
1930 gettext_noop("This can be set to advanced, extended, or basic.")
1932 ®ex_flavor_string,
1933 "advanced", assign_regex_flavor, NULL
1937 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
1938 gettext_noop("Sets the schema search order for names that are not schema-qualified."),
1940 GUC_LIST_INPUT | GUC_LIST_QUOTE
1942 &namespace_search_path,
1943 "\"$user\",public", assign_search_path, NULL
1947 /* Can't be set in postgresql.conf */
1948 {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1949 gettext_noop("Sets the server (database) character set encoding."),
1951 GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1953 &server_encoding_string,
1954 "SQL_ASCII", NULL, NULL
1958 /* Can't be set in postgresql.conf */
1959 {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
1960 gettext_noop("Shows the server version."),
1962 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1964 &server_version_string,
1965 PG_VERSION, NULL, NULL
1969 /* Not for general use --- used by SET ROLE */
1970 {"role", PGC_USERSET, UNGROUPED,
1971 gettext_noop("Sets the current role."),
1973 GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1976 "none", assign_role, show_role
1980 /* Not for general use --- used by SET SESSION AUTHORIZATION */
1981 {"session_authorization", PGC_USERSET, UNGROUPED,
1982 gettext_noop("Sets the session user name."),
1984 GUC_IS_NAME | GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1986 &session_authorization_string,
1987 NULL, assign_session_authorization, show_session_authorization
1991 {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
1992 gettext_noop("Sets the destination for server log output."),
1993 gettext_noop("Valid values are combinations of \"stderr\", \"syslog\", "
1994 "and \"eventlog\", depending on the platform."),
1997 &log_destination_string,
1998 "stderr", assign_log_destination, NULL
2001 {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
2002 gettext_noop("Sets the destination directory for log files."),
2003 gettext_noop("May be specified as relative to the data directory "
2004 "or as absolute path."),
2008 "pg_log", assign_canonical_path, NULL
2011 {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
2012 gettext_noop("Sets the file name pattern for log files."),
2017 "postgresql-%Y-%m-%d_%H%M%S.log", NULL, NULL
2022 {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2023 gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2024 gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2025 "LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2027 &syslog_facility_str,
2028 "LOCAL0", assign_syslog_facility, NULL
2031 {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
2032 gettext_noop("Sets the program name used to identify PostgreSQL "
2033 "messages in syslog."),
2037 "postgres", assign_syslog_ident, NULL
2042 {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
2043 gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
2048 "UNKNOWN", assign_timezone, show_timezone
2052 {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2053 gettext_noop("Sets the current transaction's isolation level."),
2055 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2057 &XactIsoLevel_string,
2058 NULL, assign_XactIsoLevel, show_XactIsoLevel
2062 {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2063 gettext_noop("Sets the owning group of the Unix-domain socket."),
2064 gettext_noop("(The owning user of the socket is always the user "
2065 "that starts the server.)")
2072 {"unix_socket_directory", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2073 gettext_noop("Sets the directory where the Unix-domain socket will be created."),
2078 "", assign_canonical_path, NULL
2082 {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2083 gettext_noop("Sets the host name or IP address(es) to listen to."),
2088 "localhost", NULL, NULL
2092 {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
2093 gettext_noop("Selects the method used for forcing WAL updates out to disk."),
2097 XLOG_sync_method_default, assign_xlog_sync_method, NULL
2101 {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
2102 gettext_noop("Sets the list of known custom variable classes."),
2104 GUC_LIST_INPUT | GUC_LIST_QUOTE
2106 &custom_variable_classes,
2107 NULL, assign_custom_variable_classes, NULL
2111 {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
2112 gettext_noop("Sets the server's data directory."),
2121 {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
2122 gettext_noop("Sets the server's main configuration file."),
2124 GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
2131 {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
2132 gettext_noop("Sets the server's \"hba\" configuration file"),
2141 {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
2142 gettext_noop("Sets the server's \"ident\" configuration file"),
2151 {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
2152 gettext_noop("Writes the postmaster PID to the specified file."),
2157 NULL, assign_canonical_path, NULL
2160 /* End-of-list marker */
2162 {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
2167 /******** end of options list ********/
2171 * To allow continued support of obsolete names for GUC variables, we apply
2172 * the following mappings to any unrecognized name. Note that an old name
2173 * should be mapped to a new one only if the new variable has very similar
2174 * semantics to the old.
2176 static const char *const map_old_guc_names[] = {
2177 "sort_mem", "work_mem",
2178 "vacuum_mem", "maintenance_work_mem",
2184 * Actual lookup of variables is done through this single, sorted array.
2186 static struct config_generic **guc_variables;
2188 /* Current number of variables contained in the vector */
2189 static int num_guc_variables;
2191 /* Vector capacity */
2192 static int size_guc_variables;
2195 static bool guc_dirty; /* TRUE if need to do commit/abort work */
2197 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
2200 static int guc_var_compare(const void *a, const void *b);
2201 static int guc_name_compare(const char *namea, const char *nameb);
2202 static void push_old_value(struct config_generic * gconf);
2203 static void ReportGUCOption(struct config_generic * record);
2204 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
2205 static void ShowAllGUCConfig(DestReceiver *dest);
2206 static char *_ShowOption(struct config_generic * record);
2207 static bool is_newvalue_equal(struct config_generic *record, const char *newvalue);
2211 * Some infrastructure for checking malloc/strdup/realloc calls
2214 guc_malloc(int elevel, size_t size)
2218 data = malloc(size);
2221 (errcode(ERRCODE_OUT_OF_MEMORY),
2222 errmsg("out of memory")));
2227 guc_realloc(int elevel, void *old, size_t size)
2231 data = realloc(old, size);
2234 (errcode(ERRCODE_OUT_OF_MEMORY),
2235 errmsg("out of memory")));
2240 guc_strdup(int elevel, const char *src)
2247 (errcode(ERRCODE_OUT_OF_MEMORY),
2248 errmsg("out of memory")));
2254 * Support for assigning to a field of a string GUC item. Free the prior
2255 * value if it's not referenced anywhere else in the item (including stacked
2259 set_string_field(struct config_string * conf, char **field, char *newval)
2261 char *oldval = *field;
2264 /* Do the assignment */
2267 /* Exit if any duplicate references, or if old value was NULL anyway */
2268 if (oldval == NULL ||
2269 oldval == *(conf->variable) ||
2270 oldval == conf->reset_val ||
2271 oldval == conf->tentative_val)
2273 for (stack = conf->gen.stack; stack; stack = stack->prev)
2275 if (oldval == stack->tentative_val.stringval ||
2276 oldval == stack->value.stringval)
2280 /* Not used anymore, so free it */
2285 * Detect whether strval is referenced anywhere in a GUC string item
2288 string_field_used(struct config_string * conf, char *strval)
2292 if (strval == *(conf->variable) ||
2293 strval == conf->reset_val ||
2294 strval == conf->tentative_val)
2296 for (stack = conf->gen.stack; stack; stack = stack->prev)
2298 if (strval == stack->tentative_val.stringval ||
2299 strval == stack->value.stringval)
2306 struct config_generic **
2307 get_guc_variables(void)
2309 return guc_variables;
2314 * Build the sorted array. This is split out so that it could be
2315 * re-executed after startup (eg, we could allow loadable modules to
2316 * add vars, and then we'd need to re-sort).
2319 build_guc_variables(void)
2323 struct config_generic **guc_vars;
2326 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2328 struct config_bool *conf = &ConfigureNamesBool[i];
2330 /* Rather than requiring vartype to be filled in by hand, do this: */
2331 conf->gen.vartype = PGC_BOOL;
2335 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2337 struct config_int *conf = &ConfigureNamesInt[i];
2339 conf->gen.vartype = PGC_INT;
2343 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2345 struct config_real *conf = &ConfigureNamesReal[i];
2347 conf->gen.vartype = PGC_REAL;
2351 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2353 struct config_string *conf = &ConfigureNamesString[i];
2355 conf->gen.vartype = PGC_STRING;
2360 * Create table with 20% slack
2362 size_vars = num_vars + num_vars / 4;
2364 guc_vars = (struct config_generic **)
2365 guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
2369 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2370 guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
2372 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2373 guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
2375 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2376 guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
2378 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2379 guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
2382 free(guc_variables);
2383 guc_variables = guc_vars;
2384 num_guc_variables = num_vars;
2385 size_guc_variables = size_vars;
2386 qsort((void *) guc_variables, num_guc_variables,
2387 sizeof(struct config_generic *), guc_var_compare);
2391 is_custom_class(const char *name, int dotPos)
2394 * assign_custom_variable_classes() has made sure no empty identifiers or
2395 * whitespace exists in the variable
2397 bool result = false;
2398 const char *ccs = GetConfigOption("custom_variable_classes");
2402 const char *start = ccs;
2408 if (c == 0 || c == ',')
2410 if (dotPos == ccs - start && strncmp(start, name, dotPos) == 0)
2425 * Add a new GUC variable to the list of known variables. The
2426 * list is expanded if needed.
2429 add_guc_variable(struct config_generic * var, int elevel)
2431 if (num_guc_variables + 1 >= size_guc_variables)
2434 * Increase the vector by 25%
2436 int size_vars = size_guc_variables + size_guc_variables / 4;
2437 struct config_generic **guc_vars;
2442 guc_vars = (struct config_generic **)
2443 guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
2447 guc_vars = (struct config_generic **)
2448 guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
2451 if (guc_vars == NULL)
2452 return false; /* out of memory */
2454 guc_variables = guc_vars;
2455 size_guc_variables = size_vars;
2457 guc_variables[num_guc_variables++] = var;
2458 qsort((void *) guc_variables, num_guc_variables,
2459 sizeof(struct config_generic *), guc_var_compare);
2464 * Create and add a placeholder variable. It's presumed to belong
2465 * to a valid custom variable class at this point.
2467 static struct config_string *
2468 add_placeholder_variable(const char *name, int elevel)
2470 size_t sz = sizeof(struct config_string) + sizeof(char *);
2471 struct config_string *var;
2472 struct config_generic *gen;
2474 var = (struct config_string *) guc_malloc(elevel, sz);
2481 gen->name = guc_strdup(elevel, name);
2482 if (gen->name == NULL)
2488 gen->context = PGC_USERSET;
2489 gen->group = CUSTOM_OPTIONS;
2490 gen->short_desc = "GUC placeholder variable";
2491 gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
2492 gen->vartype = PGC_STRING;
2495 * The char* is allocated at the end of the struct since we have no
2496 * 'static' place to point to.
2498 var->variable = (char **) (var + 1);
2500 if (!add_guc_variable((struct config_generic *) var, elevel))
2502 free((void *) gen->name);
2511 * Look up option NAME. If it exists, return a pointer to its record,
2514 static struct config_generic *
2515 find_option(const char *name, int elevel)
2518 const char **key = &name;
2519 struct config_generic **res;
2525 * By equating const char ** with struct config_generic *, we are assuming
2526 * the name field is first in config_generic.
2528 res = (struct config_generic **) bsearch((void *) &key,
2529 (void *) guc_variables,
2531 sizeof(struct config_generic *),
2537 * See if the name is an obsolete name for a variable. We assume that the
2538 * set of supported old names is short enough that a brute-force search is
2541 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
2543 if (guc_name_compare(name, map_old_guc_names[i]) == 0)
2544 return find_option(map_old_guc_names[i + 1], elevel);
2548 * Check if the name is qualified, and if so, check if the qualifier maps
2549 * to a custom variable class.
2551 dot = strchr(name, GUC_QUALIFIER_SEPARATOR);
2552 if (dot != NULL && is_custom_class(name, dot - name))
2553 /* Add a placeholder variable for this name */
2554 return (struct config_generic *) add_placeholder_variable(name, elevel);
2562 * comparator for qsorting and bsearching guc_variables array
2565 guc_var_compare(const void *a, const void *b)
2567 struct config_generic *confa = *(struct config_generic **) a;
2568 struct config_generic *confb = *(struct config_generic **) b;
2570 return guc_name_compare(confa->name, confb->name);
2575 guc_name_compare(const char *namea, const char *nameb)
2578 * The temptation to use strcasecmp() here must be resisted, because the
2579 * array ordering has to remain stable across setlocale() calls. So, build
2580 * our own with a simple ASCII-only downcasing.
2582 while (*namea && *nameb)
2584 char cha = *namea++;
2585 char chb = *nameb++;
2587 if (cha >= 'A' && cha <= 'Z')
2589 if (chb >= 'A' && chb <= 'Z')
2595 return 1; /* a is longer */
2597 return -1; /* b is longer */
2603 * Initialize GUC options during program startup.
2605 * Note that we cannot read the config file yet, since we have not yet
2606 * processed command-line switches.
2609 InitializeGUCOptions(void)
2615 * Build sorted array of all GUC variables.
2617 build_guc_variables();
2620 * Load all variables with their compiled-in defaults, and initialize
2621 * status fields as needed.
2623 for (i = 0; i < num_guc_variables; i++)
2625 struct config_generic *gconf = guc_variables[i];
2628 gconf->reset_source = PGC_S_DEFAULT;
2629 gconf->tentative_source = PGC_S_DEFAULT;
2630 gconf->source = PGC_S_DEFAULT;
2631 gconf->stack = NULL;
2633 switch (gconf->vartype)
2637 struct config_bool *conf = (struct config_bool *) gconf;
2639 if (conf->assign_hook)
2640 if (!(*conf->assign_hook) (conf->reset_val, true,
2642 elog(FATAL, "failed to initialize %s to %d",
2643 conf->gen.name, (int) conf->reset_val);
2644 *conf->variable = conf->reset_val;
2649 struct config_int *conf = (struct config_int *) gconf;
2651 Assert(conf->reset_val >= conf->min);
2652 Assert(conf->reset_val <= conf->max);
2653 if (conf->assign_hook)
2654 if (!(*conf->assign_hook) (conf->reset_val, true,
2656 elog(FATAL, "failed to initialize %s to %d",
2657 conf->gen.name, conf->reset_val);
2658 *conf->variable = conf->reset_val;
2663 struct config_real *conf = (struct config_real *) gconf;
2665 Assert(conf->reset_val >= conf->min);
2666 Assert(conf->reset_val <= conf->max);
2667 if (conf->assign_hook)
2668 if (!(*conf->assign_hook) (conf->reset_val, true,
2670 elog(FATAL, "failed to initialize %s to %g",
2671 conf->gen.name, conf->reset_val);
2672 *conf->variable = conf->reset_val;
2677 struct config_string *conf = (struct config_string *) gconf;
2680 *conf->variable = NULL;
2681 conf->reset_val = NULL;
2682 conf->tentative_val = NULL;
2684 if (conf->boot_val == NULL)
2686 /* Cannot set value yet */
2690 str = guc_strdup(FATAL, conf->boot_val);
2691 conf->reset_val = str;
2693 if (conf->assign_hook)
2697 newstr = (*conf->assign_hook) (str, true,
2701 elog(FATAL, "failed to initialize %s to \"%s\"",
2702 conf->gen.name, str);
2704 else if (newstr != str)
2709 * See notes in set_config_option about casting
2711 str = (char *) newstr;
2712 conf->reset_val = str;
2715 *conf->variable = str;
2723 reporting_enabled = false;
2726 * Prevent any attempt to override the transaction modes from
2727 * non-interactive sources.
2729 SetConfigOption("transaction_isolation", "default",
2730 PGC_POSTMASTER, PGC_S_OVERRIDE);
2731 SetConfigOption("transaction_read_only", "no",
2732 PGC_POSTMASTER, PGC_S_OVERRIDE);
2735 * For historical reasons, some GUC parameters can receive defaults from
2736 * environment variables. Process those settings.
2739 env = getenv("PGPORT");
2741 SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2743 env = getenv("PGDATESTYLE");
2745 SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2747 env = getenv("PGCLIENTENCODING");
2749 SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2754 * Select the configuration files and data directory to be used, and
2755 * do the initial read of postgresql.conf.
2757 * This is called after processing command-line switches.
2758 * userDoption is the -D switch value if any (NULL if unspecified).
2759 * progname is just for use in error messages.
2761 * Returns true on success; on failure, prints a suitable error message
2762 * to stderr and returns false.
2765 SelectConfigFiles(const char *userDoption, const char *progname)
2769 struct stat stat_buf;
2771 /* configdir is -D option, or $PGDATA if no -D */
2773 configdir = make_absolute_path(userDoption);
2775 configdir = make_absolute_path(getenv("PGDATA"));
2778 * Find the configuration file: if config_file was specified on the
2779 * command line, use it, else use configdir/postgresql.conf. In any case
2780 * ensure the result is an absolute path, so that it will be interpreted
2781 * the same way by future backends.
2784 fname = make_absolute_path(ConfigFileName);
2787 fname = guc_malloc(FATAL,
2788 strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
2789 sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
2793 write_stderr("%s does not know where to find the server configuration file.\n"
2794 "You must specify the --config-file or -D invocation "
2795 "option or set the PGDATA environment variable.\n",
2801 * Set the ConfigFileName GUC variable to its final value, ensuring that
2802 * it can't be overridden later.
2804 SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2808 * Now read the config file for the first time.
2810 if (stat(ConfigFileName, &stat_buf) != 0)
2812 write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
2813 progname, ConfigFileName, strerror(errno));
2817 ProcessConfigFile(PGC_POSTMASTER);
2820 * If the data_directory GUC variable has been set, use that as DataDir;
2821 * otherwise use configdir if set; else punt.
2823 * Note: SetDataDir will copy and absolute-ize its argument, so we don't
2827 SetDataDir(data_directory);
2829 SetDataDir(configdir);
2832 write_stderr("%s does not know where to find the database system data.\n"
2833 "This can be specified as \"data_directory\" in \"%s\", "
2834 "or by the -D invocation option, or by the "
2835 "PGDATA environment variable.\n",
2836 progname, ConfigFileName);
2841 * Reflect the final DataDir value back into the data_directory GUC var.
2842 * (If you are wondering why we don't just make them a single variable,
2843 * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
2844 * child backends specially. XXX is that still true? Given that we now
2845 * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
2846 * DataDir in advance.)
2848 SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
2851 * Figure out where pg_hba.conf is, and make sure the path is absolute.
2854 fname = make_absolute_path(HbaFileName);
2857 fname = guc_malloc(FATAL,
2858 strlen(configdir) + strlen(HBA_FILENAME) + 2);
2859 sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
2863 write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
2864 "This can be specified as \"hba_file\" in \"%s\", "
2865 "or by the -D invocation option, or by the "
2866 "PGDATA environment variable.\n",
2867 progname, ConfigFileName);
2870 SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2874 * Likewise for pg_ident.conf.
2877 fname = make_absolute_path(IdentFileName);
2880 fname = guc_malloc(FATAL,
2881 strlen(configdir) + strlen(IDENT_FILENAME) + 2);
2882 sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
2886 write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
2887 "This can be specified as \"ident_file\" in \"%s\", "
2888 "or by the -D invocation option, or by the "
2889 "PGDATA environment variable.\n",
2890 progname, ConfigFileName);
2893 SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2903 * Reset all options to their saved default values (implements RESET ALL)
2906 ResetAllOptions(void)
2910 for (i = 0; i < num_guc_variables; i++)
2912 struct config_generic *gconf = guc_variables[i];
2914 /* Don't reset non-SET-able values */
2915 if (gconf->context != PGC_SUSET &&
2916 gconf->context != PGC_USERSET)
2918 /* Don't reset if special exclusion from RESET ALL */
2919 if (gconf->flags & GUC_NO_RESET_ALL)
2921 /* No need to reset if wasn't SET */
2922 if (gconf->source <= PGC_S_OVERRIDE)
2925 /* Save old value to support transaction abort */
2926 push_old_value(gconf);
2928 switch (gconf->vartype)
2932 struct config_bool *conf = (struct config_bool *) gconf;
2934 if (conf->assign_hook)
2935 if (!(*conf->assign_hook) (conf->reset_val, true,
2937 elog(ERROR, "failed to reset %s", conf->gen.name);
2938 *conf->variable = conf->reset_val;
2939 conf->tentative_val = conf->reset_val;
2940 conf->gen.source = conf->gen.reset_source;
2941 conf->gen.tentative_source = conf->gen.reset_source;
2942 conf->gen.status |= GUC_HAVE_TENTATIVE;
2948 struct config_int *conf = (struct config_int *) gconf;
2950 if (conf->assign_hook)
2951 if (!(*conf->assign_hook) (conf->reset_val, true,
2953 elog(ERROR, "failed to reset %s", conf->gen.name);
2954 *conf->variable = conf->reset_val;
2955 conf->tentative_val = conf->reset_val;
2956 conf->gen.source = conf->gen.reset_source;
2957 conf->gen.tentative_source = conf->gen.reset_source;
2958 conf->gen.status |= GUC_HAVE_TENTATIVE;
2964 struct config_real *conf = (struct config_real *) gconf;
2966 if (conf->assign_hook)
2967 if (!(*conf->assign_hook) (conf->reset_val, true,
2969 elog(ERROR, "failed to reset %s", conf->gen.name);
2970 *conf->variable = conf->reset_val;
2971 conf->tentative_val = conf->reset_val;
2972 conf->gen.source = conf->gen.reset_source;
2973 conf->gen.tentative_source = conf->gen.reset_source;
2974 conf->gen.status |= GUC_HAVE_TENTATIVE;
2980 struct config_string *conf = (struct config_string *) gconf;
2983 if (conf->reset_val == NULL)
2985 /* Nothing to reset to, as yet; so do nothing */
2989 /* We need not strdup here */
2990 str = conf->reset_val;
2992 if (conf->assign_hook)
2996 newstr = (*conf->assign_hook) (str, true,
2999 elog(ERROR, "failed to reset %s", conf->gen.name);
3000 else if (newstr != str)
3003 * See notes in set_config_option about casting
3005 str = (char *) newstr;
3009 set_string_field(conf, conf->variable, str);
3010 set_string_field(conf, &conf->tentative_val, str);
3011 conf->gen.source = conf->gen.reset_source;
3012 conf->gen.tentative_source = conf->gen.reset_source;
3013 conf->gen.status |= GUC_HAVE_TENTATIVE;
3019 if (gconf->flags & GUC_REPORT)
3020 ReportGUCOption(gconf);
3027 * Push previous state during first assignment to a GUC variable
3028 * within a particular transaction.
3030 * We have to be willing to "back-fill" the state stack if the first
3031 * assignment occurs within a subtransaction nested several levels deep.
3032 * This ensures that if an intermediate transaction aborts, it will have
3033 * the proper value available to restore the setting to.
3036 push_old_value(struct config_generic * gconf)
3038 int my_level = GetCurrentTransactionNestLevel();
3041 /* If we're not inside a transaction, do nothing */
3047 /* Done if we already pushed it at this nesting depth */
3048 if (gconf->stack && gconf->stack->nest_level >= my_level)
3052 * We keep all the stack entries in TopTransactionContext so as to
3053 * avoid allocation problems when a subtransaction back-fills stack
3054 * entries for upper transaction levels.
3056 stack = (GucStack *) MemoryContextAlloc(TopTransactionContext,
3059 stack->prev = gconf->stack;
3060 stack->nest_level = stack->prev ? stack->prev->nest_level + 1 : 1;
3061 stack->status = gconf->status;
3062 stack->tentative_source = gconf->tentative_source;
3063 stack->source = gconf->source;
3065 switch (gconf->vartype)
3068 stack->tentative_val.boolval =
3069 ((struct config_bool *) gconf)->tentative_val;
3070 stack->value.boolval =
3071 *((struct config_bool *) gconf)->variable;
3075 stack->tentative_val.intval =
3076 ((struct config_int *) gconf)->tentative_val;
3077 stack->value.intval =
3078 *((struct config_int *) gconf)->variable;
3082 stack->tentative_val.realval =
3083 ((struct config_real *) gconf)->tentative_val;
3084 stack->value.realval =
3085 *((struct config_real *) gconf)->variable;
3089 stack->tentative_val.stringval =
3090 ((struct config_string *) gconf)->tentative_val;
3091 stack->value.stringval =
3092 *((struct config_string *) gconf)->variable;
3096 gconf->stack = stack;
3098 /* Set state to indicate nothing happened yet within this level */
3099 gconf->status = GUC_HAVE_STACK;
3101 /* Ensure we remember to pop at end of xact */
3107 * Do GUC processing at transaction or subtransaction commit or abort.
3110 AtEOXact_GUC(bool isCommit, bool isSubXact)
3115 /* Quick exit if nothing's changed in this transaction */
3119 my_level = GetCurrentTransactionNestLevel();
3120 Assert(isSubXact ? (my_level > 1) : (my_level == 1));
3122 for (i = 0; i < num_guc_variables; i++)
3124 struct config_generic *gconf = guc_variables[i];
3125 int my_status = gconf->status;
3126 GucStack *stack = gconf->stack;
3131 * Skip if nothing's happened to this var in this transaction
3135 Assert(stack == NULL);
3138 /* Assert that we stacked old value before changing it */
3139 Assert(stack != NULL && (my_status & GUC_HAVE_STACK));
3140 /* However, the last change may have been at an outer xact level */
3141 if (stack->nest_level < my_level)
3143 Assert(stack->nest_level == my_level);
3146 * We will pop the stack entry. Start by restoring outer xact status
3147 * (since we may want to modify it below). Be careful to use
3148 * my_status to reference the inner xact status below this point...
3150 gconf->status = stack->status;
3153 * We have two cases:
3155 * If commit and HAVE_TENTATIVE, set actual value to tentative (this
3156 * is to override a SET LOCAL if one occurred later than SET). We keep
3157 * the tentative value and propagate HAVE_TENTATIVE to the parent
3158 * status, allowing the SET's effect to percolate up. (But if we're
3159 * exiting the outermost transaction, we'll drop the HAVE_TENTATIVE
3162 * Otherwise, we have a transaction that aborted or executed only SET
3163 * LOCAL (or no SET at all). In either case it should have no further
3164 * effect, so restore both tentative and actual values from the stack
3168 useTentative = isCommit && (my_status & GUC_HAVE_TENTATIVE) != 0;
3171 switch (gconf->vartype)
3175 struct config_bool *conf = (struct config_bool *) gconf;
3177 GucSource newsource;
3181 newval = conf->tentative_val;
3182 newsource = conf->gen.tentative_source;
3183 conf->gen.status |= GUC_HAVE_TENTATIVE;
3187 newval = stack->value.boolval;
3188 newsource = stack->source;
3189 conf->tentative_val = stack->tentative_val.boolval;
3190 conf->gen.tentative_source = stack->tentative_source;
3193 if (*conf->variable != newval)
3195 if (conf->assign_hook)
3196 if (!(*conf->assign_hook) (newval,
3197 true, PGC_S_OVERRIDE))
3198 elog(LOG, "failed to commit %s",
3200 *conf->variable = newval;
3203 conf->gen.source = newsource;
3208 struct config_int *conf = (struct config_int *) gconf;
3210 GucSource newsource;
3214 newval = conf->tentative_val;
3215 newsource = conf->gen.tentative_source;
3216 conf->gen.status |= GUC_HAVE_TENTATIVE;
3220 newval = stack->value.intval;
3221 newsource = stack->source;
3222 conf->tentative_val = stack->tentative_val.intval;
3223 conf->gen.tentative_source = stack->tentative_source;
3226 if (*conf->variable != newval)
3228 if (conf->assign_hook)
3229 if (!(*conf->assign_hook) (newval,
3230 true, PGC_S_OVERRIDE))
3231 elog(LOG, "failed to commit %s",
3233 *conf->variable = newval;
3236 conf->gen.source = newsource;
3241 struct config_real *conf = (struct config_real *) gconf;
3243 GucSource newsource;
3247 newval = conf->tentative_val;
3248 newsource = conf->gen.tentative_source;
3249 conf->gen.status |= GUC_HAVE_TENTATIVE;
3253 newval = stack->value.realval;
3254 newsource = stack->source;
3255 conf->tentative_val = stack->tentative_val.realval;
3256 conf->gen.tentative_source = stack->tentative_source;
3259 if (*conf->variable != newval)
3261 if (conf->assign_hook)
3262 if (!(*conf->assign_hook) (newval,
3263 true, PGC_S_OVERRIDE))
3264 elog(LOG, "failed to commit %s",
3266 *conf->variable = newval;
3269 conf->gen.source = newsource;
3274 struct config_string *conf = (struct config_string *) gconf;
3276 GucSource newsource;
3280 newval = conf->tentative_val;
3281 newsource = conf->gen.tentative_source;
3282 conf->gen.status |= GUC_HAVE_TENTATIVE;
3286 newval = stack->value.stringval;
3287 newsource = stack->source;
3288 set_string_field(conf, &conf->tentative_val,
3289 stack->tentative_val.stringval);
3290 conf->gen.tentative_source = stack->tentative_source;
3293 if (*conf->variable != newval)
3295 if (conf->assign_hook)
3299 newstr = (*conf->assign_hook) (newval, true,
3302 elog(LOG, "failed to commit %s",
3304 else if (newstr != newval)
3307 * If newval should now be freed, it'll be
3308 * taken care of below.
3310 * See notes in set_config_option about
3313 newval = (char *) newstr;
3317 set_string_field(conf, conf->variable, newval);
3320 conf->gen.source = newsource;
3321 /* Release stacked values if not used anymore */
3322 set_string_field(conf, &stack->value.stringval,
3324 set_string_field(conf, &stack->tentative_val.stringval,
3326 /* Don't store tentative value separately after commit */
3328 set_string_field(conf, &conf->tentative_val, NULL);
3333 /* Finish popping the state stack */
3334 gconf->stack = stack->prev;
3338 * If we're now out of all xact levels, forget TENTATIVE status bit;
3339 * there's nothing tentative about the value anymore.
3343 Assert(gconf->stack == NULL);
3347 /* Report new value if we changed it */
3348 if (changed && (gconf->flags & GUC_REPORT))
3349 ReportGUCOption(gconf);
3353 * If we're now out of all xact levels, we can clear guc_dirty. (Note: we
3354 * cannot reset guc_dirty when exiting a subtransaction, because we know
3355 * that all outer transaction levels will have stacked values to deal
3364 * Start up automatic reporting of changes to variables marked GUC_REPORT.
3365 * This is executed at completion of backend startup.
3368 BeginReportingGUCOptions(void)
3373 * Don't do anything unless talking to an interactive frontend of protocol
3376 if (whereToSendOutput != DestRemote ||
3377 PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
3380 reporting_enabled = true;
3382 /* Transmit initial values of interesting variables */
3383 for (i = 0; i < num_guc_variables; i++)
3385 struct config_generic *conf = guc_variables[i];
3387 if (conf->flags & GUC_REPORT)
3388 ReportGUCOption(conf);
3393 * ReportGUCOption: if appropriate, transmit option value to frontend
3396 ReportGUCOption(struct config_generic * record)
3398 if (reporting_enabled && (record->flags & GUC_REPORT))
3400 char *val = _ShowOption(record);
3401 StringInfoData msgbuf;
3403 pq_beginmessage(&msgbuf, 'S');
3404 pq_sendstring(&msgbuf, record->name);
3405 pq_sendstring(&msgbuf, val);
3406 pq_endmessage(&msgbuf);
3414 * Try to interpret value as boolean value. Valid values are: true,
3415 * false, yes, no, on, off, 1, 0. If the string parses okay, return
3416 * true, else false. If result is not NULL, return the parsing result
3420 parse_bool(const char *value, bool *result)
3422 size_t len = strlen(value);
3424 if (pg_strncasecmp(value, "true", len) == 0)
3429 else if (pg_strncasecmp(value, "false", len) == 0)
3435 else if (pg_strncasecmp(value, "yes", len) == 0)
3440 else if (pg_strncasecmp(value, "no", len) == 0)
3446 else if (pg_strcasecmp(value, "on") == 0)
3451 else if (pg_strcasecmp(value, "off") == 0)
3457 else if (pg_strcasecmp(value, "1") == 0)
3462 else if (pg_strcasecmp(value, "0") == 0)
3471 *result = false; /* suppress compiler warning */
3480 * Try to parse value as an integer. The accepted formats are the
3481 * usual decimal, octal, or hexadecimal formats. If the string parses
3482 * okay, return true, else false. If result is not NULL, return the
3486 parse_int(const char *value, int *result)
3492 val = strtol(value, &endptr, 0);
3493 if (endptr == value || *endptr != '\0' || errno == ERANGE
3494 #ifdef HAVE_LONG_INT_64
3495 /* if long > 32 bits, check for overflow of int4 */
3496 || val != (long) ((int32) val)
3501 *result = 0; /* suppress compiler warning */
3505 *result = (int) val;
3512 * Try to parse value as a floating point constant in the usual
3513 * format. If the value parsed okay return true, else false. If
3514 * result is not NULL, return the semantic value there.
3517 parse_real(const char *value, double *result)
3523 val = strtod(value, &endptr);
3524 if (endptr == value || *endptr != '\0' || errno == ERANGE)
3527 *result = 0; /* suppress compiler warning */
3537 * Call a GucStringAssignHook function, being careful to free the
3538 * "newval" string if the hook ereports.
3540 * This is split out of set_config_option just to avoid the "volatile"
3541 * qualifiers that would otherwise have to be plastered all over.
3544 call_string_assign_hook(GucStringAssignHook assign_hook,
3545 char *newval, bool doit, GucSource source)
3551 result = (*assign_hook) (newval, doit, source);
3565 * Sets option `name' to given value. The value should be a string
3566 * which is going to be parsed and converted to the appropriate data
3567 * type. The context and source parameters indicate in which context this
3568 * function is being called so it can apply the access restrictions
3571 * If value is NULL, set the option to its default value. If the
3572 * parameter changeVal is false then don't really set the option but do all
3573 * the checks to see if it would work.
3575 * If there is an error (non-existing option, invalid value) then an
3576 * ereport(ERROR) is thrown *unless* this is called in a context where we
3577 * don't want to ereport (currently, startup or SIGHUP config file reread).
3578 * In that case we write a suitable error message via ereport(DEBUG) and
3579 * return false. This is working around the deficiencies in the ereport
3580 * mechanism, so don't blame me. In all other cases, the function
3581 * returns true, including cases where the input is valid but we chose
3582 * not to apply it because of context or source-priority considerations.
3584 * See also SetConfigOption for an external interface.
3587 set_config_option(const char *name, const char *value,
3588 GucContext context, GucSource source,
3589 bool isLocal, bool changeVal)
3591 struct config_generic *record;
3595 if (context == PGC_SIGHUP || source == PGC_S_DEFAULT)
3598 * To avoid cluttering the log, only the postmaster bleats loudly
3599 * about problems with the config file.
3601 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
3603 else if (source == PGC_S_DATABASE || source == PGC_S_USER)
3608 record = find_option(name, elevel);
3612 (errcode(ERRCODE_UNDEFINED_OBJECT),
3613 errmsg("unrecognized configuration parameter \"%s\"", name)));
3618 * Check if the option can be set at this time. See guc.h for the precise
3619 * rules. Note that we don't want to throw errors if we're in the SIGHUP
3620 * context. In that case we just ignore the attempt and return true.
3622 switch (record->context)
3625 if (context == PGC_SIGHUP)
3627 if (context != PGC_INTERNAL)
3630 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3631 errmsg("parameter \"%s\" cannot be changed",
3636 case PGC_POSTMASTER:
3637 if (context == PGC_SIGHUP)
3639 if (changeVal && !is_newvalue_equal(record, value))
3641 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3642 errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
3647 if (context != PGC_POSTMASTER)
3650 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3651 errmsg("parameter \"%s\" cannot be changed after server start",
3657 if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
3660 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3661 errmsg("parameter \"%s\" cannot be changed now",
3667 * Hmm, the idea of the SIGHUP context is "ought to be global, but
3668 * can be changed after postmaster start". But there's nothing
3669 * that prevents a crafty administrator from sending SIGHUP
3670 * signals to individual backends only.
3674 if (context == PGC_SIGHUP)
3677 * If a PGC_BACKEND parameter is changed in the config file,
3678 * we want to accept the new value in the postmaster (whence
3679 * it will propagate to subsequently-started backends), but
3680 * ignore it in existing backends. This is a tad klugy, but
3681 * necessary because we don't re-read the config file during
3684 if (IsUnderPostmaster)
3687 else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
3690 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3691 errmsg("parameter \"%s\" cannot be set after connection start",
3697 if (context == PGC_USERSET || context == PGC_BACKEND)
3700 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3701 errmsg("permission denied to set parameter \"%s\"",
3712 * Should we set reset/stacked values? (If so, the behavior is not
3715 makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL);
3718 * Ignore attempted set if overridden by previously processed setting.
3719 * However, if changeVal is false then plow ahead anyway since we are
3720 * trying to find out if the value is potentially good, not actually use
3721 * it. Also keep going if makeDefault is true, since we may want to set
3722 * the reset/stacked values even if we can't set the variable itself.
3724 if (record->source > source)
3726 if (changeVal && !makeDefault)
3728 elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
3736 * Evaluate value and set variable.
3738 switch (record->vartype)
3742 struct config_bool *conf = (struct config_bool *) record;
3747 if (!parse_bool(value, &newval))
3750 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3751 errmsg("parameter \"%s\" requires a Boolean value",
3758 newval = conf->reset_val;
3759 source = conf->gen.reset_source;
3762 if (conf->assign_hook)
3763 if (!(*conf->assign_hook) (newval, changeVal, source))
3766 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3767 errmsg("invalid value for parameter \"%s\": %d",
3768 name, (int) newval)));
3772 if (changeVal || makeDefault)
3774 /* Save old value to support transaction abort */
3776 push_old_value(&conf->gen);
3779 *conf->variable = newval;
3780 conf->gen.source = source;
3786 if (conf->gen.reset_source <= source)
3788 conf->reset_val = newval;
3789 conf->gen.reset_source = source;
3791 for (stack = conf->gen.stack; stack; stack = stack->prev)
3793 if (stack->source <= source)
3795 stack->value.boolval = newval;
3796 stack->source = source;
3802 conf->gen.status |= GUC_HAVE_LOCAL;
3807 conf->tentative_val = newval;
3808 conf->gen.tentative_source = source;
3809 conf->gen.status |= GUC_HAVE_TENTATIVE;
3818 struct config_int *conf = (struct config_int *) record;
3823 if (!parse_int(value, &newval))
3826 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3827 errmsg("parameter \"%s\" requires an integer value",
3831 if (newval < conf->min || newval > conf->max)
3834 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3835 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
3836 newval, name, conf->min, conf->max)));
3842 newval = conf->reset_val;
3843 source = conf->gen.reset_source;
3846 if (conf->assign_hook)
3847 if (!(*conf->assign_hook) (newval, changeVal, source))
3850 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3851 errmsg("invalid value for parameter \"%s\": %d",
3856 if (changeVal || makeDefault)
3858 /* Save old value to support transaction abort */
3860 push_old_value(&conf->gen);
3863 *conf->variable = newval;
3864 conf->gen.source = source;
3870 if (conf->gen.reset_source <= source)
3872 conf->reset_val = newval;
3873 conf->gen.reset_source = source;
3875 for (stack = conf->gen.stack; stack; stack = stack->prev)
3877 if (stack->source <= source)
3879 stack->value.intval = newval;
3880 stack->source = source;
3886 conf->gen.status |= GUC_HAVE_LOCAL;
3891 conf->tentative_val = newval;
3892 conf->gen.tentative_source = source;
3893 conf->gen.status |= GUC_HAVE_TENTATIVE;
3902 struct config_real *conf = (struct config_real *) record;
3907 if (!parse_real(value, &newval))
3910 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3911 errmsg("parameter \"%s\" requires a numeric value",
3915 if (newval < conf->min || newval > conf->max)
3918 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3919 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
3920 newval, name, conf->min, conf->max)));
3926 newval = conf->reset_val;
3927 source = conf->gen.reset_source;
3930 if (conf->assign_hook)
3931 if (!(*conf->assign_hook) (newval, changeVal, source))
3934 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3935 errmsg("invalid value for parameter \"%s\": %g",
3940 if (changeVal || makeDefault)
3942 /* Save old value to support transaction abort */
3944 push_old_value(&conf->gen);
3947 *conf->variable = newval;
3948 conf->gen.source = source;
3954 if (conf->gen.reset_source <= source)
3956 conf->reset_val = newval;
3957 conf->gen.reset_source = source;
3959 for (stack = conf->gen.stack; stack; stack = stack->prev)
3961 if (stack->source <= source)
3963 stack->value.realval = newval;
3964 stack->source = source;
3970 conf->gen.status |= GUC_HAVE_LOCAL;
3975 conf->tentative_val = newval;
3976 conf->gen.tentative_source = source;
3977 conf->gen.status |= GUC_HAVE_TENTATIVE;
3986 struct config_string *conf = (struct config_string *) record;
3991 newval = guc_strdup(elevel, value);
3995 * The only sort of "parsing" check we need to do is
3996 * apply truncation if GUC_IS_NAME.
3998 if (conf->gen.flags & GUC_IS_NAME)
3999 truncate_identifier(newval, strlen(newval), true);
4001 else if (conf->reset_val)
4004 * We could possibly avoid strdup here, but easier to make
4005 * this case work the same as the normal assignment case.
4007 newval = guc_strdup(elevel, conf->reset_val);
4010 source = conf->gen.reset_source;
4014 /* Nothing to reset to, as yet; so do nothing */
4018 if (conf->assign_hook)
4020 const char *hookresult;
4023 * If the hook ereports, we have to make sure we free
4024 * newval, else it will be a permanent memory leak.
4026 hookresult = call_string_assign_hook(conf->assign_hook,
4030 if (hookresult == NULL)
4034 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4035 errmsg("invalid value for parameter \"%s\": \"%s\"",
4036 name, value ? value : "")));
4039 else if (hookresult != newval)
4044 * Having to cast away const here is annoying, but the
4045 * alternative is to declare assign_hooks as returning
4046 * char*, which would mean they'd have to cast away
4047 * const, or as both taking and returning char*, which
4048 * doesn't seem attractive either --- we don't want
4049 * them to scribble on the passed str.
4051 newval = (char *) hookresult;
4055 if (changeVal || makeDefault)
4057 /* Save old value to support transaction abort */
4059 push_old_value(&conf->gen);
4062 set_string_field(conf, conf->variable, newval);
4063 conf->gen.source = source;
4069 if (conf->gen.reset_source <= source)
4071 set_string_field(conf, &conf->reset_val, newval);
4072 conf->gen.reset_source = source;
4074 for (stack = conf->gen.stack; stack; stack = stack->prev)
4076 if (stack->source <= source)
4078 set_string_field(conf, &stack->value.stringval,
4080 stack->source = source;
4083 /* Perhaps we didn't install newval anywhere */
4084 if (!string_field_used(conf, newval))
4089 conf->gen.status |= GUC_HAVE_LOCAL;
4094 set_string_field(conf, &conf->tentative_val, newval);
4095 conf->gen.tentative_source = source;
4096 conf->gen.status |= GUC_HAVE_TENTATIVE;
4106 if (changeVal && (record->flags & GUC_REPORT))
4107 ReportGUCOption(record);
4114 * Set a config option to the given value. See also set_config_option,
4115 * this is just the wrapper to be called from outside GUC. NB: this
4116 * is used only for non-transactional operations.
4119 SetConfigOption(const char *name, const char *value,
4120 GucContext context, GucSource source)
4122 (void) set_config_option(name, value, context, source, false, true);
4128 * Fetch the current value of the option `name'. If the option doesn't exist,
4129 * throw an ereport and don't return.
4131 * The string is *not* allocated for modification and is really only
4132 * valid until the next call to configuration related functions.
4135 GetConfigOption(const char *name)
4137 struct config_generic *record;
4138 static char buffer[256];
4140 record = find_option(name, ERROR);
4143 (errcode(ERRCODE_UNDEFINED_OBJECT),
4144 errmsg("unrecognized configuration parameter \"%s\"", name)));
4145 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4147 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4148 errmsg("must be superuser to examine \"%s\"", name)));
4150 switch (record->vartype)
4153 return *((struct config_bool *) record)->variable ? "on" : "off";
4156 snprintf(buffer, sizeof(buffer), "%d",
4157 *((struct config_int *) record)->variable);
4161 snprintf(buffer, sizeof(buffer), "%g",
4162 *((struct config_real *) record)->variable);
4166 return *((struct config_string *) record)->variable;
4172 * Get the RESET value associated with the given option.
4175 GetConfigOptionResetString(const char *name)
4177 struct config_generic *record;
4178 static char buffer[256];
4180 record = find_option(name, ERROR);
4183 (errcode(ERRCODE_UNDEFINED_OBJECT),
4184 errmsg("unrecognized configuration parameter \"%s\"", name)));
4185 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4187 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4188 errmsg("must be superuser to examine \"%s\"", name)));
4190 switch (record->vartype)
4193 return ((struct config_bool *) record)->reset_val ? "on" : "off";
4196 snprintf(buffer, sizeof(buffer), "%d",
4197 ((struct config_int *) record)->reset_val);
4201 snprintf(buffer, sizeof(buffer), "%g",
4202 ((struct config_real *) record)->reset_val);
4206 return ((struct config_string *) record)->reset_val;
4212 * Detect whether the given configuration option can only be set by
4216 IsSuperuserConfigOption(const char *name)
4218 struct config_generic *record;
4220 record = find_option(name, ERROR);
4221 /* On an unrecognized name, don't error, just return false. */
4224 return (record->context == PGC_SUSET);
4229 * flatten_set_variable_args
4230 * Given a parsenode List as emitted by the grammar for SET,
4231 * convert to the flat string representation used by GUC.
4233 * We need to be told the name of the variable the args are for, because
4234 * the flattening rules vary (ugh).
4236 * The result is NULL if input is NIL (ie, SET ... TO DEFAULT), otherwise
4237 * a palloc'd string.
4240 flatten_set_variable_args(const char *name, List *args)
4242 struct config_generic *record;
4248 * Fast path if just DEFAULT. We do not check the variable name in this
4249 * case --- necessary for RESET ALL to work correctly.
4254 /* Else get flags for the variable */
4255 record = find_option(name, ERROR);
4258 (errcode(ERRCODE_UNDEFINED_OBJECT),
4259 errmsg("unrecognized configuration parameter \"%s\"", name)));
4261 flags = record->flags;
4263 /* Complain if list input and non-list variable */
4264 if ((flags & GUC_LIST_INPUT) == 0 &&
4265 list_length(args) != 1)
4267 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4268 errmsg("SET %s takes only one argument", name)));
4270 initStringInfo(&buf);
4274 A_Const *arg = (A_Const *) lfirst(l);
4277 if (l != list_head(args))
4278 appendStringInfo(&buf, ", ");
4280 if (!IsA(arg, A_Const))
4281 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
4283 switch (nodeTag(&arg->val))
4286 appendStringInfo(&buf, "%ld", intVal(&arg->val));
4289 /* represented as a string, so just copy it */
4290 appendStringInfoString(&buf, strVal(&arg->val));
4293 val = strVal(&arg->val);
4294 if (arg->typename != NULL)
4297 * Must be a ConstInterval argument for TIME ZONE. Coerce
4298 * to interval and back to normalize the value and account
4305 DirectFunctionCall3(interval_in,
4306 CStringGetDatum(val),
4307 ObjectIdGetDatum(InvalidOid),
4308 Int32GetDatum(arg->typename->typmod));
4311 DatumGetCString(DirectFunctionCall1(interval_out,
4313 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
4318 * Plain string literal or identifier. For quote mode,
4319 * quote it if it's not a vanilla identifier.
4321 if (flags & GUC_LIST_QUOTE)
4322 appendStringInfoString(&buf, quote_identifier(val));
4324 appendStringInfoString(&buf, val);
4328 elog(ERROR, "unrecognized node type: %d",
4329 (int) nodeTag(&arg->val));
4342 SetPGVariable(const char *name, List *args, bool is_local)
4344 char *argstring = flatten_set_variable_args(name, args);
4346 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4347 set_config_option(name,
4349 (superuser() ? PGC_SUSET : PGC_USERSET),
4356 * SET command wrapped as a SQL callable function.
4359 set_config_by_name(PG_FUNCTION_ARGS)
4367 if (PG_ARGISNULL(0))
4369 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
4370 errmsg("SET requires parameter name")));
4372 /* Get the GUC variable name */
4373 name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4375 /* Get the desired value or set to NULL for a reset request */
4376 if (PG_ARGISNULL(1))
4379 value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
4382 * Get the desired state of is_local. Default to false if provided value
4385 if (PG_ARGISNULL(2))
4388 is_local = PG_GETARG_BOOL(2);
4390 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4391 set_config_option(name,
4393 (superuser() ? PGC_SUSET : PGC_USERSET),
4398 /* get the new current value */
4399 new_value = GetConfigOptionByName(name, NULL);
4401 /* Convert return string to text */
4402 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
4405 PG_RETURN_TEXT_P(result_text);
4409 define_custom_variable(struct config_generic * variable)
4411 const char *name = variable->name;
4412 const char **nameAddr = &name;
4414 struct config_string *pHolder;
4415 struct config_generic **res = (struct config_generic **) bsearch(
4417 (void *) guc_variables,
4419 sizeof(struct config_generic *),
4424 add_guc_variable(variable, ERROR);
4429 * This better be a placeholder
4431 if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
4433 (errcode(ERRCODE_INTERNAL_ERROR),
4434 errmsg("attempt to redefine parameter \"%s\"", name)));
4436 Assert((*res)->vartype == PGC_STRING);
4437 pHolder = (struct config_string *) * res;
4439 /* We have the same name, no sorting is necessary */
4442 value = *pHolder->variable;
4445 * Assign the string value stored in the placeholder to the real variable.
4447 * XXX this is not really good enough --- it should be a nontransactional
4448 * assignment, since we don't want it to roll back if the current xact
4451 set_config_option(name, value,
4452 pHolder->gen.context, pHolder->gen.source,
4456 * Free up as much as we conveniently can of the placeholder structure
4457 * (this neglects any stack items...)
4459 set_string_field(pHolder, pHolder->variable, NULL);
4460 set_string_field(pHolder, &pHolder->reset_val, NULL);
4461 set_string_field(pHolder, &pHolder->tentative_val, NULL);
4467 init_custom_variable(struct config_generic * gen,
4469 const char *short_desc,
4470 const char *long_desc,
4472 enum config_type type)
4474 gen->name = guc_strdup(ERROR, name);
4475 gen->context = context;
4476 gen->group = CUSTOM_OPTIONS;
4477 gen->short_desc = short_desc;
4478 gen->long_desc = long_desc;
4479 gen->vartype = type;
4483 DefineCustomBoolVariable(const char *name,
4484 const char *short_desc,
4485 const char *long_desc,
4488 GucBoolAssignHook assign_hook,
4489 GucShowHook show_hook)
4491 size_t sz = sizeof(struct config_bool);
4492 struct config_bool *var = (struct config_bool *) guc_malloc(ERROR, sz);
4495 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_BOOL);
4497 var->variable = valueAddr;
4498 var->reset_val = *valueAddr;
4499 var->assign_hook = assign_hook;
4500 var->show_hook = show_hook;
4501 define_custom_variable(&var->gen);
4505 DefineCustomIntVariable(const char *name,
4506 const char *short_desc,
4507 const char *long_desc,
4512 GucIntAssignHook assign_hook,
4513 GucShowHook show_hook)
4515 size_t sz = sizeof(struct config_int);
4516 struct config_int *var = (struct config_int *) guc_malloc(ERROR, sz);
4519 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_INT);
4521 var->variable = valueAddr;
4522 var->reset_val = *valueAddr;
4523 var->min = minValue;
4524 var->max = maxValue;
4525 var->assign_hook = assign_hook;
4526 var->show_hook = show_hook;
4527 define_custom_variable(&var->gen);
4531 DefineCustomRealVariable(const char *name,
4532 const char *short_desc,
4533 const char *long_desc,
4538 GucRealAssignHook assign_hook,
4539 GucShowHook show_hook)
4541 size_t sz = sizeof(struct config_real);
4542 struct config_real *var = (struct config_real *) guc_malloc(ERROR, sz);
4545 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_REAL);
4547 var->variable = valueAddr;
4548 var->reset_val = *valueAddr;
4549 var->min = minValue;
4550 var->max = maxValue;
4551 var->assign_hook = assign_hook;
4552 var->show_hook = show_hook;
4553 define_custom_variable(&var->gen);
4557 DefineCustomStringVariable(const char *name,
4558 const char *short_desc,
4559 const char *long_desc,
4562 GucStringAssignHook assign_hook,
4563 GucShowHook show_hook)
4565 size_t sz = sizeof(struct config_string);
4566 struct config_string *var = (struct config_string *) guc_malloc(ERROR, sz);
4569 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_STRING);
4571 var->variable = valueAddr;
4572 var->reset_val = *valueAddr;
4573 var->assign_hook = assign_hook;
4574 var->show_hook = show_hook;
4575 define_custom_variable(&var->gen);
4579 EmitWarningsOnPlaceholders(const char *className)
4581 struct config_generic **vars = guc_variables;
4582 struct config_generic **last = vars + num_guc_variables;
4584 int nameLen = strlen(className);
4588 struct config_generic *var = *vars++;
4590 if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
4591 strncmp(className, var->name, nameLen) == 0 &&
4592 var->name[nameLen] == GUC_QUALIFIER_SEPARATOR)
4595 (errcode(ERRCODE_UNDEFINED_OBJECT),
4596 errmsg("unrecognized configuration parameter \"%s\"", var->name)));
4606 GetPGVariable(const char *name, DestReceiver *dest)
4608 if (pg_strcasecmp(name, "all") == 0)
4609 ShowAllGUCConfig(dest);
4611 ShowGUCConfigOption(name, dest);
4615 GetPGVariableResultDesc(const char *name)
4619 if (pg_strcasecmp(name, "all") == 0)
4621 /* need a tuple descriptor representing three TEXT columns */
4622 tupdesc = CreateTemplateTupleDesc(3, false);
4623 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4625 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4627 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4633 const char *varname;
4635 /* Get the canonical spelling of name */
4636 (void) GetConfigOptionByName(name, &varname);
4638 /* need a tuple descriptor representing a single TEXT column */
4639 tupdesc = CreateTemplateTupleDesc(1, false);
4640 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4650 ResetPGVariable(const char *name)
4652 if (pg_strcasecmp(name, "all") == 0)
4655 set_config_option(name,
4657 (superuser() ? PGC_SUSET : PGC_USERSET),
4668 ShowGUCConfigOption(const char *name, DestReceiver *dest)
4670 TupOutputState *tstate;
4672 const char *varname;
4675 /* Get the value and canonical spelling of name */
4676 value = GetConfigOptionByName(name, &varname);
4678 /* need a tuple descriptor representing a single TEXT column */
4679 tupdesc = CreateTemplateTupleDesc(1, false);
4680 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4683 /* prepare for projection of tuples */
4684 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4687 do_text_output_oneline(tstate, value);
4689 end_tup_output(tstate);
4696 ShowAllGUCConfig(DestReceiver *dest)
4698 bool am_superuser = superuser();
4700 TupOutputState *tstate;
4704 /* need a tuple descriptor representing three TEXT columns */
4705 tupdesc = CreateTemplateTupleDesc(3, false);
4706 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4708 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4710 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4714 /* prepare for projection of tuples */
4715 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4717 for (i = 0; i < num_guc_variables; i++)
4719 struct config_generic *conf = guc_variables[i];
4721 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4722 ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
4725 /* assign to the values array */
4726 values[0] = (char *) conf->name;
4727 values[1] = _ShowOption(conf);
4728 values[2] = (char *) conf->short_desc;
4730 /* send it to dest */
4731 do_tup_output(tstate, values);
4734 if (values[1] != NULL)
4738 end_tup_output(tstate);
4742 * Return GUC variable value by name; optionally return canonical
4743 * form of name. Return value is palloc'd.
4746 GetConfigOptionByName(const char *name, const char **varname)
4748 struct config_generic *record;
4750 record = find_option(name, ERROR);
4753 (errcode(ERRCODE_UNDEFINED_OBJECT),
4754 errmsg("unrecognized configuration parameter \"%s\"", name)));
4755 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4757 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4758 errmsg("must be superuser to examine \"%s\"", name)));
4761 *varname = record->name;
4763 return _ShowOption(record);
4767 * Return GUC variable value by variable number; optionally return canonical
4768 * form of name. Return value is palloc'd.
4771 GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
4774 struct config_generic *conf;
4776 /* check requested variable number valid */
4777 Assert((varnum >= 0) && (varnum < num_guc_variables));
4779 conf = guc_variables[varnum];
4783 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4784 ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
4790 /* first get the generic attributes */
4793 values[0] = conf->name;
4795 /* setting : use _ShowOption in order to avoid duplicating the logic */
4796 values[1] = _ShowOption(conf);
4799 values[2] = config_group_names[conf->group];
4802 values[3] = conf->short_desc;
4805 values[4] = conf->long_desc;
4808 values[5] = GucContext_Names[conf->context];
4811 values[6] = config_type_names[conf->vartype];
4814 values[7] = GucSource_Names[conf->source];
4816 /* now get the type specifc attributes */
4817 switch (conf->vartype)
4831 struct config_int *lconf = (struct config_int *) conf;
4834 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
4835 values[8] = pstrdup(buffer);
4838 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
4839 values[9] = pstrdup(buffer);
4845 struct config_real *lconf = (struct config_real *) conf;
4848 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
4849 values[8] = pstrdup(buffer);
4852 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
4853 values[9] = pstrdup(buffer);
4870 * should never get here, but in case we do, set 'em to NULL
4884 * Return the total number of GUC variables
4887 GetNumConfigOptions(void)
4889 return num_guc_variables;
4893 * show_config_by_name - equiv to SHOW X command but implemented as
4897 show_config_by_name(PG_FUNCTION_ARGS)
4903 /* Get the GUC variable name */
4904 varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4907 varval = GetConfigOptionByName(varname, NULL);
4909 /* Convert to text */
4910 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));
4913 PG_RETURN_TEXT_P(result_text);
4917 * show_all_settings - equiv to SHOW ALL command but implemented as
4920 #define NUM_PG_SETTINGS_ATTS 10
4923 show_all_settings(PG_FUNCTION_ARGS)
4925 FuncCallContext *funcctx;
4929 AttInMetadata *attinmeta;
4930 MemoryContext oldcontext;
4932 /* stuff done only on the first call of the function */
4933 if (SRF_IS_FIRSTCALL())
4935 /* create a function context for cross-call persistence */
4936 funcctx = SRF_FIRSTCALL_INIT();
4939 * switch to memory context appropriate for multiple function calls
4941 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
4944 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
4945 * of the appropriate types
4947 tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
4948 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4950 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4952 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "category",
4954 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "short_desc",
4956 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "extra_desc",
4958 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "context",
4960 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "vartype",
4962 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "source",
4964 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "min_val",
4966 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "max_val",
4970 * Generate attribute metadata needed later to produce tuples from raw
4973 attinmeta = TupleDescGetAttInMetadata(tupdesc);
4974 funcctx->attinmeta = attinmeta;
4976 /* total number of tuples to be returned */
4977 funcctx->max_calls = GetNumConfigOptions();
4979 MemoryContextSwitchTo(oldcontext);
4982 /* stuff done on every call of the function */
4983 funcctx = SRF_PERCALL_SETUP();
4985 call_cntr = funcctx->call_cntr;
4986 max_calls = funcctx->max_calls;
4987 attinmeta = funcctx->attinmeta;
4989 if (call_cntr < max_calls) /* do when there is more left to send */
4991 char *values[NUM_PG_SETTINGS_ATTS];
4997 * Get the next visible GUC variable name and value
5001 GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
5004 /* bump the counter and get the next config setting */
5005 call_cntr = ++funcctx->call_cntr;
5007 /* make sure we haven't gone too far now */
5008 if (call_cntr >= max_calls)
5009 SRF_RETURN_DONE(funcctx);
5014 tuple = BuildTupleFromCStrings(attinmeta, values);
5016 /* make the tuple into a datum */
5017 result = HeapTupleGetDatum(tuple);
5019 SRF_RETURN_NEXT(funcctx, result);
5023 /* do when there is no more left */
5024 SRF_RETURN_DONE(funcctx);
5029 _ShowOption(struct config_generic * record)
5034 switch (record->vartype)
5038 struct config_bool *conf = (struct config_bool *) record;
5040 if (conf->show_hook)
5041 val = (*conf->show_hook) ();
5043 val = *conf->variable ? "on" : "off";
5049 struct config_int *conf = (struct config_int *) record;
5051 if (conf->show_hook)
5052 val = (*conf->show_hook) ();
5055 snprintf(buffer, sizeof(buffer), "%d",
5064 struct config_real *conf = (struct config_real *) record;
5066 if (conf->show_hook)
5067 val = (*conf->show_hook) ();
5070 snprintf(buffer, sizeof(buffer), "%g",
5079 struct config_string *conf = (struct config_string *) record;
5081 if (conf->show_hook)
5082 val = (*conf->show_hook) ();
5083 else if (*conf->variable && **conf->variable)
5084 val = *conf->variable;
5091 /* just to keep compiler quiet */
5096 return pstrdup(val);
5101 is_newvalue_equal(struct config_generic *record, const char *newvalue)
5103 switch (record->vartype)
5107 struct config_bool *conf = (struct config_bool *) record;
5110 return parse_bool(newvalue, &newval) && *conf->variable == newval;
5114 struct config_int *conf = (struct config_int *) record;
5117 return parse_int(newvalue, &newval) && *conf->variable == newval;
5121 struct config_real *conf = (struct config_real *) record;
5124 return parse_real(newvalue, &newval) && *conf->variable == newval;
5128 struct config_string *conf = (struct config_string *) record;
5130 return strcmp(*conf->variable, newvalue) == 0;
5141 * This routine dumps out all non-default GUC options into a binary
5142 * file that is read by all exec'ed backends. The format is:
5144 * variable name, string, null terminated
5145 * variable value, string, null terminated
5146 * variable source, integer
5149 write_nondefault_variables(GucContext context)
5155 Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
5157 elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
5162 fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
5166 (errcode_for_file_access(),
5167 errmsg("could not write to file \"%s\": %m",
5168 CONFIG_EXEC_PARAMS_NEW)));
5172 for (i = 0; i < num_guc_variables; i++)
5174 struct config_generic *gconf = guc_variables[i];
5176 if (gconf->source != PGC_S_DEFAULT)
5178 fprintf(fp, "%s", gconf->name);
5181 switch (gconf->vartype)
5185 struct config_bool *conf = (struct config_bool *) gconf;
5187 if (*conf->variable == 0)
5188 fprintf(fp, "false");
5190 fprintf(fp, "true");
5196 struct config_int *conf = (struct config_int *) gconf;
5198 fprintf(fp, "%d", *conf->variable);
5204 struct config_real *conf = (struct config_real *) gconf;
5206 /* Could lose precision here? */
5207 fprintf(fp, "%f", *conf->variable);
5213 struct config_string *conf = (struct config_string *) gconf;
5215 fprintf(fp, "%s", *conf->variable);
5222 fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
5229 (errcode_for_file_access(),
5230 errmsg("could not write to file \"%s\": %m",
5231 CONFIG_EXEC_PARAMS_NEW)));
5236 * Put new file in place. This could delay on Win32, but we don't hold
5237 * any exclusive locks.
5239 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5244 * Read string, including null byte from file
5246 * Return NULL on EOF and nothing read
5249 read_string_with_null(FILE *fp)
5258 if ((ch = fgetc(fp)) == EOF)
5263 elog(FATAL, "invalid format of exec config params file");
5266 str = guc_malloc(FATAL, maxlen);
5267 else if (i == maxlen)
5268 str = guc_realloc(FATAL, str, maxlen *= 2);
5277 * This routine loads a previous postmaster dump of its non-default
5281 read_nondefault_variables(void)
5291 fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
5294 /* File not found is fine */
5295 if (errno != ENOENT)
5297 (errcode_for_file_access(),
5298 errmsg("could not read from file \"%s\": %m",
5299 CONFIG_EXEC_PARAMS)));
5305 struct config_generic *record;
5307 if ((varname = read_string_with_null(fp)) == NULL)
5310 if ((record = find_option(varname, FATAL)) == NULL)
5311 elog(FATAL, "failed to locate variable %s in exec config params file", varname);
5312 if ((varvalue = read_string_with_null(fp)) == NULL)
5313 elog(FATAL, "invalid format of exec config params file");
5314 if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
5315 elog(FATAL, "invalid format of exec config params file");
5317 (void) set_config_option(varname, varvalue, record->context,
5318 varsource, false, true);
5325 #endif /* EXEC_BACKEND */
5329 * A little "long argument" simulation, although not quite GNU
5330 * compliant. Takes a string of the form "some-option=some value" and
5331 * returns name = "some_option" and value = "some value" in malloc'ed
5332 * storage. Note that '-' is converted to '_' in the option name. If
5333 * there is no '=' in the input string then value will be NULL.
5336 ParseLongOption(const char *string, char **name, char **value)
5345 equal_pos = strcspn(string, "=");
5347 if (string[equal_pos] == '=')
5349 *name = guc_malloc(FATAL, equal_pos + 1);
5350 strncpy(*name, string, equal_pos);
5351 (*name)[equal_pos] = '\0';
5353 *value = guc_strdup(FATAL, &string[equal_pos + 1]);
5357 /* no equal sign in string */
5358 *name = guc_strdup(FATAL, string);
5362 for (cp = *name; *cp; cp++)
5369 * Handle options fetched from pg_database.datconfig or pg_authid.rolconfig.
5370 * The array parameter must be an array of TEXT (it must not be NULL).
5373 ProcessGUCArray(ArrayType *array, GucSource source)
5377 Assert(array != NULL);
5378 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5379 Assert(ARR_NDIM(array) == 1);
5380 Assert(ARR_LBOUND(array)[0] == 1);
5381 Assert(source == PGC_S_DATABASE || source == PGC_S_USER);
5383 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5391 d = array_ref(array, 1, &i,
5392 -1 /* varlenarray */ ,
5393 -1 /* TEXT's typlen */ ,
5394 false /* TEXT's typbyval */ ,
5395 'i' /* TEXT's typalign */ ,
5401 s = DatumGetCString(DirectFunctionCall1(textout, d));
5403 ParseLongOption(s, &name, &value);
5407 (errcode(ERRCODE_SYNTAX_ERROR),
5408 errmsg("could not parse setting for parameter \"%s\"", name)));
5414 * We process all these options at SUSET level. We assume that the
5415 * right to insert an option into pg_database or pg_authid was checked
5416 * when it was inserted.
5418 SetConfigOption(name, value, PGC_SUSET, source);
5428 * Add an entry to an option array. The array parameter may be NULL
5429 * to indicate the current table entry is NULL.
5432 GUCArrayAdd(ArrayType *array, const char *name, const char *value)
5434 const char *varname;
5442 /* test if the option is valid */
5443 set_config_option(name, value,
5444 superuser() ? PGC_SUSET : PGC_USERSET,
5445 PGC_S_TEST, false, false);
5447 /* convert name to canonical spelling, so we can use plain strcmp */
5448 (void) GetConfigOptionByName(name, &varname);
5451 newval = palloc(strlen(name) + 1 + strlen(value) + 1);
5452 sprintf(newval, "%s=%s", name, value);
5453 datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
5461 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5462 Assert(ARR_NDIM(array) == 1);
5463 Assert(ARR_LBOUND(array)[0] == 1);
5465 index = ARR_DIMS(array)[0] + 1; /* add after end */
5467 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5472 d = array_ref(array, 1, &i,
5473 -1 /* varlenarray */ ,
5474 -1 /* TEXT's typlen */ ,
5475 false /* TEXT's typbyval */ ,
5476 'i' /* TEXT's typalign */ ,
5480 current = DatumGetCString(DirectFunctionCall1(textout, d));
5481 if (strncmp(current, newval, strlen(name) + 1) == 0)
5488 a = array_set(array, 1, &index,
5491 -1 /* varlena array */ ,
5492 -1 /* TEXT's typlen */ ,
5493 false /* TEXT's typbyval */ ,
5494 'i' /* TEXT's typalign */ );
5497 a = construct_array(&datum, 1,
5506 * Delete an entry from an option array. The array parameter may be NULL
5507 * to indicate the current table entry is NULL. Also, if the return value
5508 * is NULL then a null should be stored.
5511 GUCArrayDelete(ArrayType *array, const char *name)
5513 const char *varname;
5514 ArrayType *newarray;
5520 /* test if the option is valid */
5521 set_config_option(name, NULL,
5522 superuser() ? PGC_SUSET : PGC_USERSET,
5523 PGC_S_TEST, false, false);
5525 /* convert name to canonical spelling, so we can use plain strcmp */
5526 (void) GetConfigOptionByName(name, &varname);
5529 /* if array is currently null, then surely nothing to delete */
5536 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5542 d = array_ref(array, 1, &i,
5543 -1 /* varlenarray */ ,
5544 -1 /* TEXT's typlen */ ,
5545 false /* TEXT's typbyval */ ,
5546 'i' /* TEXT's typalign */ ,
5550 val = DatumGetCString(DirectFunctionCall1(textout, d));
5552 /* ignore entry if it's what we want to delete */
5553 if (strncmp(val, name, strlen(name)) == 0
5554 && val[strlen(name)] == '=')
5557 /* else add it to the output array */
5560 newarray = array_set(newarray, 1, &index,
5563 -1 /* varlenarray */ ,
5564 -1 /* TEXT's typlen */ ,
5565 false /* TEXT's typbyval */ ,
5566 'i' /* TEXT's typalign */ );
5569 newarray = construct_array(&d, 1,
5581 * assign_hook subroutines
5585 assign_log_destination(const char *value, bool doit, GucSource source)
5592 /* Need a modifiable copy of string */
5593 rawstring = pstrdup(value);
5595 /* Parse string into list of identifiers */
5596 if (!SplitIdentifierString(rawstring, ',', &elemlist))
5598 /* syntax error in list */
5600 list_free(elemlist);
5601 if (source >= PGC_S_INTERACTIVE)
5603 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5604 errmsg("invalid list syntax for parameter \"log_destination\"")));
5608 foreach(l, elemlist)
5610 char *tok = (char *) lfirst(l);
5612 if (pg_strcasecmp(tok, "stderr") == 0)
5613 newlogdest |= LOG_DESTINATION_STDERR;
5615 else if (pg_strcasecmp(tok, "syslog") == 0)
5616 newlogdest |= LOG_DESTINATION_SYSLOG;
5619 else if (pg_strcasecmp(tok, "eventlog") == 0)
5620 newlogdest |= LOG_DESTINATION_EVENTLOG;
5624 if (source >= PGC_S_INTERACTIVE)
5626 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5627 errmsg("unrecognized \"log_destination\" key word: \"%s\"",
5630 list_free(elemlist);
5636 Log_destination = newlogdest;
5639 list_free(elemlist);
5647 assign_syslog_facility(const char *facility, bool doit, GucSource source)
5651 if (pg_strcasecmp(facility, "LOCAL0") == 0)
5652 syslog_fac = LOG_LOCAL0;
5653 else if (pg_strcasecmp(facility, "LOCAL1") == 0)
5654 syslog_fac = LOG_LOCAL1;
5655 else if (pg_strcasecmp(facility, "LOCAL2") == 0)
5656 syslog_fac = LOG_LOCAL2;
5657 else if (pg_strcasecmp(facility, "LOCAL3") == 0)
5658 syslog_fac = LOG_LOCAL3;
5659 else if (pg_strcasecmp(facility, "LOCAL4") == 0)
5660 syslog_fac = LOG_LOCAL4;
5661 else if (pg_strcasecmp(facility, "LOCAL5") == 0)
5662 syslog_fac = LOG_LOCAL5;
5663 else if (pg_strcasecmp(facility, "LOCAL6") == 0)
5664 syslog_fac = LOG_LOCAL6;
5665 else if (pg_strcasecmp(facility, "LOCAL7") == 0)
5666 syslog_fac = LOG_LOCAL7;
5668 return NULL; /* reject */
5672 syslog_facility = syslog_fac;
5673 set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
5681 assign_syslog_ident(const char *ident, bool doit, GucSource source)
5684 set_syslog_parameters(ident, syslog_facility);
5688 #endif /* HAVE_SYSLOG */
5692 assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
5694 if (pg_strcasecmp(newval, "serializable") == 0)
5697 DefaultXactIsoLevel = XACT_SERIALIZABLE;
5699 else if (pg_strcasecmp(newval, "repeatable read") == 0)
5702 DefaultXactIsoLevel = XACT_REPEATABLE_READ;
5704 else if (pg_strcasecmp(newval, "read committed") == 0)
5707 DefaultXactIsoLevel = XACT_READ_COMMITTED;
5709 else if (pg_strcasecmp(newval, "read uncommitted") == 0)
5712 DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
5720 assign_log_min_messages(const char *newval,
5721 bool doit, GucSource source)
5723 return (assign_msglvl(&log_min_messages, newval, doit, source));
5727 assign_client_min_messages(const char *newval, bool doit, GucSource source)
5729 return (assign_msglvl(&client_min_messages, newval, doit, source));
5733 assign_min_error_statement(const char *newval, bool doit, GucSource source)
5735 return (assign_msglvl(&log_min_error_statement, newval, doit, source));
5739 assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
5741 if (pg_strcasecmp(newval, "debug") == 0)
5746 else if (pg_strcasecmp(newval, "debug5") == 0)
5751 else if (pg_strcasecmp(newval, "debug4") == 0)
5756 else if (pg_strcasecmp(newval, "debug3") == 0)
5761 else if (pg_strcasecmp(newval, "debug2") == 0)
5766 else if (pg_strcasecmp(newval, "debug1") == 0)
5771 else if (pg_strcasecmp(newval, "log") == 0)
5778 * Client_min_messages always prints 'info', but we allow it as a value
5781 else if (pg_strcasecmp(newval, "info") == 0)
5786 else if (pg_strcasecmp(newval, "notice") == 0)
5791 else if (pg_strcasecmp(newval, "warning") == 0)
5796 else if (pg_strcasecmp(newval, "error") == 0)
5801 /* We allow FATAL/PANIC for client-side messages too. */
5802 else if (pg_strcasecmp(newval, "fatal") == 0)
5807 else if (pg_strcasecmp(newval, "panic") == 0)
5813 return NULL; /* fail */
5814 return newval; /* OK */
5818 assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
5820 if (pg_strcasecmp(newval, "terse") == 0)
5823 Log_error_verbosity = PGERROR_TERSE;
5825 else if (pg_strcasecmp(newval, "default") == 0)
5828 Log_error_verbosity = PGERROR_DEFAULT;
5830 else if (pg_strcasecmp(newval, "verbose") == 0)
5833 Log_error_verbosity = PGERROR_VERBOSE;
5836 return NULL; /* fail */
5837 return newval; /* OK */
5841 assign_log_statement(const char *newval, bool doit, GucSource source)
5843 if (pg_strcasecmp(newval, "none") == 0)
5846 log_statement = LOGSTMT_NONE;
5848 else if (pg_strcasecmp(newval, "ddl") == 0)
5851 log_statement = LOGSTMT_DDL;
5853 else if (pg_strcasecmp(newval, "mod") == 0)
5856 log_statement = LOGSTMT_MOD;
5858 else if (pg_strcasecmp(newval, "all") == 0)
5861 log_statement = LOGSTMT_ALL;
5864 return NULL; /* fail */
5865 return newval; /* OK */
5869 show_num_temp_buffers(void)
5872 * We show the GUC var until local buffers have been initialized, and
5873 * NLocBuffer afterwards.
5875 static char nbuf[32];
5877 sprintf(nbuf, "%d", NLocBuffer ? NLocBuffer : num_temp_buffers);
5882 assign_phony_autocommit(bool newval, bool doit, GucSource source)
5886 if (doit && source >= PGC_S_INTERACTIVE)
5888 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5889 errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
5896 assign_custom_variable_classes(const char *newval, bool doit, GucSource source)
5899 * Check syntax. newval must be a comma separated list of identifiers.
5900 * Whitespace is allowed but skipped.
5902 bool hasSpaceAfterToken = false;
5903 const char *cp = newval;
5908 initStringInfo(&buf);
5909 while ((c = *cp++) != 0)
5914 hasSpaceAfterToken = true;
5920 hasSpaceAfterToken = false;
5924 appendStringInfoChar(&buf, ',');
5929 if (hasSpaceAfterToken || !isalnum(c))
5932 * Syntax error due to token following space after token or non
5933 * alpha numeric character
5936 (errcode(ERRCODE_SYNTAX_ERROR),
5937 errmsg("invalid syntax for \"custom_variable_classes\": \"%s\"", newval)));
5942 appendStringInfoChar(&buf, (char) c);
5945 /* Remove stray ',' at end */
5946 if (symLen == 0 && buf.len > 0)
5947 buf.data[--buf.len] = '\0';
5952 newval = strdup(buf.data);
5959 assign_debug_assertions(bool newval, bool doit, GucSource source)
5961 #ifndef USE_ASSERT_CHECKING
5964 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5965 errmsg("assertion checking is not supported by this build")));
5971 assign_ssl(bool newval, bool doit, GucSource source)
5976 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5977 errmsg("SSL is not supported by this build")));
5983 assign_stage_log_stats(bool newval, bool doit, GucSource source)
5985 if (newval && log_statement_stats)
5987 if (source >= PGC_S_INTERACTIVE)
5989 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5990 errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
5991 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
5992 else if (source != PGC_S_OVERRIDE)
5999 assign_log_stats(bool newval, bool doit, GucSource source)
6002 (log_parser_stats || log_planner_stats || log_executor_stats))
6004 if (source >= PGC_S_INTERACTIVE)
6006 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6007 errmsg("cannot enable \"log_statement_stats\" when "
6008 "\"log_parser_stats\", \"log_planner_stats\", "
6009 "or \"log_executor_stats\" is true")));
6010 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6011 else if (source != PGC_S_OVERRIDE)
6018 assign_transaction_read_only(bool newval, bool doit, GucSource source)
6020 /* Can't go to r/w mode inside a r/o transaction */
6021 if (newval == false && XactReadOnly && IsSubTransaction())
6023 if (source >= PGC_S_INTERACTIVE)
6025 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6026 errmsg("cannot set transaction read-write mode inside a read-only transaction")));
6027 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6028 else if (source != PGC_S_OVERRIDE)
6035 assign_canonical_path(const char *newval, bool doit, GucSource source)
6039 char *canon_val = guc_strdup(ERROR, newval);
6041 canonicalize_path(canon_val);
6049 assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
6052 return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
6058 show_tcp_keepalives_idle(void)
6060 static char nbuf[16];
6062 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
6067 assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
6070 return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
6076 show_tcp_keepalives_interval(void)
6078 static char nbuf[16];
6080 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
6085 assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
6088 return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
6094 show_tcp_keepalives_count(void)
6096 static char nbuf[16];
6098 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
6103 #include "guc-file.c"