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.312 2006/03/05 15:58:49 momjian 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;
205 static char *syslog_facility_str;
206 static char *syslog_ident_str;
207 static bool phony_autocommit;
208 static bool session_auth_is_superuser;
209 static double phony_random_seed;
210 static char *client_encoding_string;
211 static char *datestyle_string;
212 static char *default_iso_level_string;
213 static char *locale_collate;
214 static char *locale_ctype;
215 static char *regex_flavor_string;
216 static char *server_encoding_string;
217 static char *server_version_string;
218 static char *timezone_string;
219 static char *XactIsoLevel_string;
220 static char *data_directory;
221 static char *custom_variable_classes;
222 static int max_function_args;
223 static int max_index_keys;
224 static int max_identifier_length;
225 static int block_size;
226 static bool integer_datetimes;
227 static bool standard_conforming_strings;
229 /* should be static, but commands/variable.c needs to get at these */
231 char *session_authorization_string;
235 * Displayable names for context types (enum GucContext)
237 * Note: these strings are deliberately not localized.
239 const char *const GucContext_Names[] =
241 /* PGC_INTERNAL */ "internal",
242 /* PGC_POSTMASTER */ "postmaster",
243 /* PGC_SIGHUP */ "sighup",
244 /* PGC_BACKEND */ "backend",
245 /* PGC_SUSET */ "superuser",
246 /* PGC_USERSET */ "user"
250 * Displayable names for source types (enum GucSource)
252 * Note: these strings are deliberately not localized.
254 const char *const GucSource_Names[] =
256 /* PGC_S_DEFAULT */ "default",
257 /* PGC_S_ENV_VAR */ "environment variable",
258 /* PGC_S_FILE */ "configuration file",
259 /* PGC_S_ARGV */ "command line",
260 /* PGC_S_DATABASE */ "database",
261 /* PGC_S_USER */ "user",
262 /* PGC_S_CLIENT */ "client",
263 /* PGC_S_OVERRIDE */ "override",
264 /* PGC_S_INTERACTIVE */ "interactive",
265 /* PGC_S_TEST */ "test",
266 /* PGC_S_SESSION */ "session"
270 * Displayable names for the groupings defined in enum config_group
272 const char *const config_group_names[] =
275 gettext_noop("Ungrouped"),
277 gettext_noop("File Locations"),
279 gettext_noop("Connections and Authentication"),
280 /* CONN_AUTH_SETTINGS */
281 gettext_noop("Connections and Authentication / Connection Settings"),
282 /* CONN_AUTH_SECURITY */
283 gettext_noop("Connections and Authentication / Security and Authentication"),
285 gettext_noop("Resource Usage"),
287 gettext_noop("Resource Usage / Memory"),
289 gettext_noop("Resource Usage / Free Space Map"),
290 /* RESOURCES_KERNEL */
291 gettext_noop("Resource Usage / Kernel Resources"),
293 gettext_noop("Write-Ahead Log"),
295 gettext_noop("Write-Ahead Log / Settings"),
296 /* WAL_CHECKPOINTS */
297 gettext_noop("Write-Ahead Log / Checkpoints"),
299 gettext_noop("Query Tuning"),
300 /* QUERY_TUNING_METHOD */
301 gettext_noop("Query Tuning / Planner Method Configuration"),
302 /* QUERY_TUNING_COST */
303 gettext_noop("Query Tuning / Planner Cost Constants"),
304 /* QUERY_TUNING_GEQO */
305 gettext_noop("Query Tuning / Genetic Query Optimizer"),
306 /* QUERY_TUNING_OTHER */
307 gettext_noop("Query Tuning / Other Planner Options"),
309 gettext_noop("Reporting and Logging"),
311 gettext_noop("Reporting and Logging / Where to Log"),
313 gettext_noop("Reporting and Logging / When to Log"),
315 gettext_noop("Reporting and Logging / What to Log"),
317 gettext_noop("Statistics"),
318 /* STATS_MONITORING */
319 gettext_noop("Statistics / Monitoring"),
320 /* STATS_COLLECTOR */
321 gettext_noop("Statistics / Query and Index Statistics Collector"),
323 gettext_noop("Autovacuum"),
325 gettext_noop("Client Connection Defaults"),
326 /* CLIENT_CONN_STATEMENT */
327 gettext_noop("Client Connection Defaults / Statement Behavior"),
328 /* CLIENT_CONN_LOCALE */
329 gettext_noop("Client Connection Defaults / Locale and Formatting"),
330 /* CLIENT_CONN_OTHER */
331 gettext_noop("Client Connection Defaults / Other Defaults"),
332 /* LOCK_MANAGEMENT */
333 gettext_noop("Lock Management"),
335 gettext_noop("Version and Platform Compatibility"),
336 /* COMPAT_OPTIONS_PREVIOUS */
337 gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
338 /* COMPAT_OPTIONS_CLIENT */
339 gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
341 gettext_noop("Preset Options"),
343 gettext_noop("Customized Options"),
344 /* DEVELOPER_OPTIONS */
345 gettext_noop("Developer Options"),
346 /* help_config wants this array to be null-terminated */
351 * Displayable names for GUC variable types (enum config_type)
353 * Note: these strings are deliberately not localized.
355 const char *const config_type_names[] =
357 /* PGC_BOOL */ "bool",
358 /* PGC_INT */ "integer",
359 /* PGC_REAL */ "real",
360 /* PGC_STRING */ "string"
365 * Contents of GUC tables
367 * See src/backend/utils/misc/README for design notes.
371 * 1. Declare a global variable of type bool, int, double, or char*
372 * and make use of it.
374 * 2. Decide at what times it's safe to set the option. See guc.h for
377 * 3. Decide on a name, a default value, upper and lower bounds (if
380 * 4. Add a record below.
382 * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
385 * 6. Add it to src/bin/psql/tab-complete.c, if it's a USERSET option.
387 * 7. Don't forget to document the option.
389 * 8. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
390 * it is not single quoted at dump time.
394 /******** option records follow ********/
396 static struct config_bool ConfigureNamesBool[] =
399 {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
400 gettext_noop("Enables the planner's use of sequential-scan plans."),
407 {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
408 gettext_noop("Enables the planner's use of index-scan plans."),
415 {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
416 gettext_noop("Enables the planner's use of bitmap-scan plans."),
423 {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
424 gettext_noop("Enables the planner's use of TID scan plans."),
431 {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
432 gettext_noop("Enables the planner's use of explicit sort steps."),
439 {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
440 gettext_noop("Enables the planner's use of hashed aggregation plans."),
447 {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
448 gettext_noop("Enables the planner's use of nested-loop join plans."),
455 {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
456 gettext_noop("Enables the planner's use of merge join plans."),
463 {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
464 gettext_noop("Enables the planner's use of hash join plans."),
471 {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
472 gettext_noop("Enables the planner to use constraints to optimize queries."),
473 gettext_noop("Child table scans will be skipped if their "
474 "constraints guarantee that no rows match the query.")
476 &constraint_exclusion,
480 {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
481 gettext_noop("Enables genetic query optimization."),
482 gettext_noop("This algorithm attempts to do planning without "
483 "exhaustive searching.")
489 /* Not for general use --- used by SET SESSION AUTHORIZATION */
490 {"is_superuser", PGC_INTERNAL, UNGROUPED,
491 gettext_noop("Shows whether the current user is a superuser."),
493 GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
495 &session_auth_is_superuser,
499 {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
500 gettext_noop("Enables SSL connections."),
504 false, assign_ssl, NULL
507 {"fsync", PGC_SIGHUP, WAL_SETTINGS,
508 gettext_noop("Forces synchronization of updates to disk."),
509 gettext_noop("The server will use the fsync() system call in several places to make "
510 "sure that updates are physically written to disk. This insures "
511 "that a database cluster will recover to a consistent state after "
512 "an operating system or hardware crash.")
518 {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
519 gettext_noop("Continues processing past damaged page headers."),
520 gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
521 "report an error, aborting the current transaction. Setting "
522 "zero_damaged_pages to true causes the system to instead report a "
523 "warning, zero out the damaged page, and continue processing. This "
524 "behavior will destroy data, namely all the rows on the damaged page."),
531 {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
532 gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
533 gettext_noop("A page write in process during an operating system crash might be "
534 "only partially written to disk. During recovery, the row changes "
535 "stored in WAL are not enough to recover. This option writes "
536 "pages when first modified after a checkpoint to WAL so full recovery "
543 {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
544 gettext_noop("Runs the server silently."),
545 gettext_noop("If this parameter is set, the server will automatically run in the "
546 "background and any controlling terminals are dissociated.")
552 {"log_connections", PGC_BACKEND, LOGGING_WHAT,
553 gettext_noop("Logs each successful connection."),
560 {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
561 gettext_noop("Logs end of a session, including duration."),
568 {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
569 gettext_noop("Turns on various assertion checks."),
570 gettext_noop("This is a debugging aid."),
574 #ifdef USE_ASSERT_CHECKING
579 assign_debug_assertions, NULL
582 /* currently undocumented, so don't show in SHOW ALL */
583 {"exit_on_error", PGC_USERSET, UNGROUPED,
584 gettext_noop("no description available"),
586 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
592 {"log_duration", PGC_SUSET, LOGGING_WHAT,
593 gettext_noop("Logs the duration of each completed SQL statement."),
600 {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
601 gettext_noop("Prints the parse tree to the server log."),
608 {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
609 gettext_noop("Prints the parse tree after rewriting to server log."),
612 &Debug_print_rewritten,
616 {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
617 gettext_noop("Prints the execution plan to server log."),
624 {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
625 gettext_noop("Indents parse and plan tree displays."),
632 {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
633 gettext_noop("Writes parser performance statistics to the server log."),
637 false, assign_stage_log_stats, NULL
640 {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
641 gettext_noop("Writes planner performance statistics to the server log."),
645 false, assign_stage_log_stats, NULL
648 {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
649 gettext_noop("Writes executor performance statistics to the server log."),
653 false, assign_stage_log_stats, NULL
656 {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
657 gettext_noop("Writes cumulative performance statistics to the server log."),
660 &log_statement_stats,
661 false, assign_log_stats, NULL
663 #ifdef BTREE_BUILD_STATS
665 {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
666 gettext_noop("no description available"),
670 &log_btree_build_stats,
676 {"explain_pretty_print", PGC_USERSET, CLIENT_CONN_OTHER,
677 gettext_noop("Uses the indented output format for EXPLAIN VERBOSE."),
680 &Explain_pretty_print,
684 {"stats_start_collector", PGC_POSTMASTER, STATS_COLLECTOR,
685 gettext_noop("Starts the server statistics-collection subprocess."),
688 &pgstat_collect_startcollector,
692 {"stats_reset_on_server_start", PGC_POSTMASTER, STATS_COLLECTOR,
693 gettext_noop("Zeroes collected statistics on server restart."),
696 &pgstat_collect_resetonpmstart,
700 {"stats_command_string", PGC_SUSET, STATS_COLLECTOR,
701 gettext_noop("Collects statistics about executing commands."),
702 gettext_noop("Enables the collection of statistics on the currently "
703 "executing command of each session, along with the time "
704 "at which that command began execution.")
706 &pgstat_collect_querystring,
710 {"stats_row_level", PGC_SUSET, STATS_COLLECTOR,
711 gettext_noop("Collects row-level statistics on database activity."),
714 &pgstat_collect_tuplelevel,
718 {"stats_block_level", PGC_SUSET, STATS_COLLECTOR,
719 gettext_noop("Collects block-level statistics on database activity."),
722 &pgstat_collect_blocklevel,
727 {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
728 gettext_noop("Starts the autovacuum subprocess."),
731 &autovacuum_start_daemon,
736 {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
737 gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
747 {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
748 gettext_noop("no description available"),
756 {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
757 gettext_noop("no description available"),
765 {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
766 gettext_noop("no description available"),
774 {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
775 gettext_noop("no description available"),
785 {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
786 gettext_noop("Logs the host name in the connection logs."),
787 gettext_noop("By default, connection logs only show the IP address "
788 "of the connecting host. If you want them to show the host name you "
789 "can turn this on, but depending on your host name resolution "
790 "setup it might impose a non-negligible performance penalty.")
796 {"sql_inheritance", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
797 gettext_noop("Causes subtables to be included by default in various commands."),
804 {"australian_timezones", PGC_USERSET, CLIENT_CONN_LOCALE,
805 gettext_noop("Interprets ACST, CST, EST, and SAT as Australian time zones."),
806 gettext_noop("Otherwise they are interpreted as North/South American "
807 "time zones and Saturday.")
809 &Australian_timezones,
810 false, ClearDateCache, NULL
813 {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
814 gettext_noop("Encrypt passwords."),
815 gettext_noop("When a password is specified in CREATE USER or "
816 "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
817 "this parameter determines whether the password is to be encrypted.")
819 &Password_encryption,
823 {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
824 gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
825 gettext_noop("When turned on, expressions of the form expr = NULL "
826 "(or NULL = expr) are treated as expr IS NULL, that is, they "
827 "return true if expr evaluates to the null value, and false "
828 "otherwise. The correct behavior of expr = NULL is to always "
829 "return null (unknown).")
831 &Transform_null_equals,
835 {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
836 gettext_noop("Enables per-database user names."),
843 /* only here for backwards compatibility */
844 {"autocommit", PGC_USERSET, CLIENT_CONN_STATEMENT,
845 gettext_noop("This parameter doesn't do anything."),
846 gettext_noop("It's just here so that we won't choke on SET AUTOCOMMIT TO ON from 7.3-vintage clients."),
847 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
850 true, assign_phony_autocommit, NULL
853 {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
854 gettext_noop("Sets the default read-only status of new transactions."),
857 &DefaultXactReadOnly,
861 {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
862 gettext_noop("Sets the current transaction's read-only status."),
864 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
867 false, assign_transaction_read_only, NULL
870 {"add_missing_from", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
871 gettext_noop("Automatically adds missing table references to FROM clauses."),
878 {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
879 gettext_noop("Check function bodies during CREATE FUNCTION."),
882 &check_function_bodies,
886 {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
887 gettext_noop("Enable input of NULL elements in arrays."),
888 gettext_noop("When turned on, unquoted NULL in an array input "
889 "value means a NULL value; "
890 "otherwise it is taken literally.")
896 {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
897 gettext_noop("Create new tables with OIDs by default."),
904 {"redirect_stderr", PGC_POSTMASTER, LOGGING_WHERE,
905 gettext_noop("Start a subprocess to capture stderr output into log files."),
912 {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
913 gettext_noop("Truncate existing log files of same name during log rotation."),
916 &Log_truncate_on_rotation,
922 {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
923 gettext_noop("Emit information about resource usage in sorting."),
934 {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
935 gettext_noop("Emit WAL-related debugging output."),
945 {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
946 gettext_noop("Datetimes are integer based."),
948 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
951 #ifdef HAVE_INT64_TIMESTAMP
959 {"krb_caseins_users", PGC_POSTMASTER, CONN_AUTH_SECURITY,
960 gettext_noop("Sets whether Kerberos user names should be treated as case-insensitive."),
963 &pg_krb_caseins_users,
968 {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
969 gettext_noop("Warn about backslash escapes in ordinary string literals."),
972 &escape_string_warning,
977 {"standard_conforming_strings", PGC_INTERNAL, PRESET_OPTIONS,
978 gettext_noop("'...' strings treat backslashes literally."),
980 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
982 &standard_conforming_strings,
987 {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
988 gettext_noop("Allows modifications of the structure of system tables."),
992 &allowSystemTableMods,
997 {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
998 gettext_noop("Disabled reading from system indexes."),
999 gettext_noop("It does not prevent updating the indexes, so it is safe "
1000 "to use. The worst consequence is slowness."),
1003 &IgnoreSystemIndexes,
1007 /* End-of-list marker */
1009 {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
1014 static struct config_int ConfigureNamesInt[] =
1017 {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1018 gettext_noop("Waits N seconds on connection startup after authentication."),
1019 gettext_noop("This allows attaching a debugger to the process."),
1023 0, 0, INT_MAX, NULL, NULL
1026 {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1027 gettext_noop("Sets the default statistics target."),
1028 gettext_noop("This applies to table columns that have not had a "
1029 "column-specific target set via ALTER TABLE SET STATISTICS.")
1031 &default_statistics_target,
1032 10, 1, 1000, NULL, NULL
1035 {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1036 gettext_noop("Sets the FROM-list size beyond which subqueries are not "
1038 gettext_noop("The planner will merge subqueries into upper "
1039 "queries if the resulting FROM list would have no more than "
1042 &from_collapse_limit,
1043 8, 1, INT_MAX, NULL, NULL
1046 {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1047 gettext_noop("Sets the FROM-list size beyond which JOIN constructs are not "
1049 gettext_noop("The planner will flatten explicit JOIN "
1050 "constructs into lists of FROM items whenever a list of no more "
1051 "than this many items would result.")
1053 &join_collapse_limit,
1054 8, 1, INT_MAX, NULL, NULL
1057 {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1058 gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1062 12, 2, INT_MAX, NULL, NULL
1065 {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1066 gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1070 DEFAULT_GEQO_EFFORT, MIN_GEQO_EFFORT, MAX_GEQO_EFFORT, NULL, NULL
1073 {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1074 gettext_noop("GEQO: number of individuals in the population."),
1075 gettext_noop("Zero selects a suitable default value.")
1078 0, 0, INT_MAX, NULL, NULL
1081 {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1082 gettext_noop("GEQO: number of iterations of the algorithm."),
1083 gettext_noop("Zero selects a suitable default value.")
1086 0, 0, INT_MAX, NULL, NULL
1090 {"deadlock_timeout", PGC_SIGHUP, LOCK_MANAGEMENT,
1091 gettext_noop("The time in milliseconds to wait on lock before checking for deadlock."),
1095 1000, 0, INT_MAX, NULL, NULL
1099 * Note: There is some postprocessing done in PostmasterMain() to make
1100 * sure the buffers are at least twice the number of backends, so the
1101 * constraints here are partially unused. Similarly, the superuser
1102 * reserved number is checked to ensure it is less than the max backends
1105 * MaxBackends is limited to INT_MAX/4 because some places compute
1106 * 4*MaxBackends without any overflow check. Likewise we have to limit
1107 * NBuffers to INT_MAX/2.
1110 {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1111 gettext_noop("Sets the maximum number of concurrent connections."),
1115 100, 1, INT_MAX / 4, NULL, NULL
1119 {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1120 gettext_noop("Sets the number of connection slots reserved for superusers."),
1124 2, 0, INT_MAX / 4, NULL, NULL
1128 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1129 gettext_noop("Sets the number of shared memory buffers used by the server."),
1133 1000, 16, INT_MAX / 2, NULL, NULL
1137 {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1138 gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1142 1000, 100, INT_MAX / 2, NULL, show_num_temp_buffers
1146 {"port", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1147 gettext_noop("Sets the TCP port the server listens on."),
1151 DEF_PGPORT, 1, 65535, NULL, NULL
1155 {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1156 gettext_noop("Sets the access permissions of the Unix-domain socket."),
1157 gettext_noop("Unix-domain sockets use the usual Unix file system "
1158 "permission set. The parameter value is expected to be an numeric mode "
1159 "specification in the form accepted by the chmod and umask system "
1160 "calls. (To use the customary octal format the number must start with "
1163 &Unix_socket_permissions,
1164 0777, 0000, 0777, NULL, NULL
1168 {"work_mem", PGC_USERSET, RESOURCES_MEM,
1169 gettext_noop("Sets the maximum memory to be used for query workspaces."),
1170 gettext_noop("This much memory may be used by each internal "
1171 "sort operation and hash table before switching to "
1172 "temporary disk files.")
1175 1024, 8 * BLCKSZ / 1024, MAX_KILOBYTES, NULL, NULL
1179 {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1180 gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1181 gettext_noop("This includes operations such as VACUUM and CREATE INDEX.")
1183 &maintenance_work_mem,
1184 16384, 1024, MAX_KILOBYTES, NULL, NULL
1188 {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1189 gettext_noop("Sets the maximum stack depth, in kilobytes."),
1193 2048, 100, MAX_KILOBYTES, assign_max_stack_depth, NULL
1197 {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
1198 gettext_noop("Vacuum cost for a page found in the buffer cache."),
1202 1, 0, 10000, NULL, NULL
1206 {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
1207 gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1210 &VacuumCostPageMiss,
1211 10, 0, 10000, NULL, NULL
1215 {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
1216 gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1219 &VacuumCostPageDirty,
1220 20, 0, 10000, NULL, NULL
1224 {"vacuum_cost_limit", PGC_USERSET, RESOURCES,
1225 gettext_noop("Vacuum cost amount available before napping."),
1229 200, 1, 10000, NULL, NULL
1233 {"vacuum_cost_delay", PGC_USERSET, RESOURCES,
1234 gettext_noop("Vacuum cost delay in milliseconds."),
1238 0, 0, 1000, NULL, NULL
1242 {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
1243 gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
1246 &autovacuum_vac_cost_delay,
1247 -1, -1, 1000, NULL, NULL
1251 {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
1252 gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
1255 &autovacuum_vac_cost_limit,
1256 -1, -1, 10000, NULL, NULL
1260 {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
1261 gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
1264 &max_files_per_process,
1265 1000, 25, INT_MAX, NULL, NULL
1269 {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
1270 gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
1273 &max_prepared_xacts,
1274 5, 0, INT_MAX, NULL, NULL
1279 {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
1280 gettext_noop("no description available"),
1285 FirstNormalObjectId, 0, INT_MAX, NULL, NULL
1288 {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
1289 gettext_noop("no description available"),
1294 0, 0, INT_MAX, NULL, NULL
1299 {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
1300 gettext_noop("Sets the maximum allowed duration (in milliseconds) of any statement."),
1301 gettext_noop("A value of 0 turns off the timeout.")
1304 0, 0, INT_MAX, NULL, NULL
1308 {"max_fsm_relations", PGC_POSTMASTER, RESOURCES_FSM,
1309 gettext_noop("Sets the maximum number of tables and indexes for which free space is tracked."),
1313 1000, 100, INT_MAX, NULL, NULL
1316 {"max_fsm_pages", PGC_POSTMASTER, RESOURCES_FSM,
1317 gettext_noop("Sets the maximum number of disk pages for which free space is tracked."),
1321 20000, 1000, INT_MAX, NULL, NULL
1325 {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
1326 gettext_noop("Sets the maximum number of locks per transaction."),
1327 gettext_noop("The shared lock table is sized on the assumption that "
1328 "at most max_locks_per_transaction * max_connections distinct "
1329 "objects will need to be locked at any one time.")
1331 &max_locks_per_xact,
1332 64, 10, INT_MAX, NULL, NULL
1336 {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
1337 gettext_noop("Sets the maximum time in seconds to complete client authentication."),
1340 &AuthenticationTimeout,
1341 60, 1, 600, NULL, NULL
1345 /* Not for general use */
1346 {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
1347 gettext_noop("no description available"),
1352 0, 0, 60, NULL, NULL
1356 {"checkpoint_segments", PGC_SIGHUP, WAL_CHECKPOINTS,
1357 gettext_noop("Sets the maximum distance in log segments between automatic WAL checkpoints."),
1360 &CheckPointSegments,
1361 3, 1, INT_MAX, NULL, NULL
1365 {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
1366 gettext_noop("Sets the maximum time in seconds between automatic WAL checkpoints."),
1370 300, 30, 3600, NULL, NULL
1374 {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
1375 gettext_noop("Logs if filling of checkpoint segments happens more "
1376 "frequently than this (in seconds)."),
1377 gettext_noop("Write a message to the server log if checkpoints "
1378 "caused by the filling of checkpoint segment files happens more "
1379 "frequently than this number of seconds. Zero turns off the warning.")
1382 30, 0, INT_MAX, NULL, NULL
1386 {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
1387 gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
1391 8, 4, INT_MAX, NULL, NULL
1395 {"commit_delay", PGC_USERSET, WAL_CHECKPOINTS,
1396 gettext_noop("Sets the delay in microseconds between transaction commit and "
1397 "flushing WAL to disk."),
1401 0, 0, 100000, NULL, NULL
1405 {"commit_siblings", PGC_USERSET, WAL_CHECKPOINTS,
1406 gettext_noop("Sets the minimum concurrent open transactions before performing "
1411 5, 1, 1000, NULL, NULL
1415 {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
1416 gettext_noop("Sets the number of digits displayed for floating-point values."),
1417 gettext_noop("This affects real, double precision, and geometric data types. "
1418 "The parameter value is added to the standard number of digits "
1419 "(FLT_DIG or DBL_DIG as appropriate).")
1421 &extra_float_digits,
1422 0, -15, 2, NULL, NULL
1426 {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
1427 gettext_noop("Sets the minimum execution time in milliseconds above which statements will "
1429 gettext_noop("Zero prints all queries. The default is -1 (turning this feature off).")
1431 &log_min_duration_statement,
1432 -1, -1, INT_MAX / 1000, NULL, NULL
1436 {"bgwriter_delay", PGC_SIGHUP, RESOURCES,
1437 gettext_noop("Background writer sleep time between rounds in milliseconds"),
1441 200, 10, 10000, NULL, NULL
1445 {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
1446 gettext_noop("Background writer maximum number of LRU pages to flush per round"),
1449 &bgwriter_lru_maxpages,
1450 5, 0, 1000, NULL, NULL
1454 {"bgwriter_all_maxpages", PGC_SIGHUP, RESOURCES,
1455 gettext_noop("Background writer maximum number of all pages to flush per round"),
1458 &bgwriter_all_maxpages,
1459 5, 0, 1000, NULL, NULL
1463 {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
1464 gettext_noop("Automatic log file rotation will occur after N minutes"),
1468 HOURS_PER_DAY * MINS_PER_HOUR, 0, INT_MAX / MINS_PER_HOUR, NULL, NULL
1472 {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
1473 gettext_noop("Automatic log file rotation will occur after N kilobytes"),
1477 10 * 1024, 0, INT_MAX / 1024, NULL, NULL
1481 {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
1482 gettext_noop("Shows the maximum number of function arguments."),
1484 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1487 FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
1491 {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
1492 gettext_noop("Shows the maximum number of index keys."),
1494 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1497 INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
1501 {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
1502 gettext_noop("Shows the maximum identifier length"),
1504 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1506 &max_identifier_length,
1507 NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
1511 {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
1512 gettext_noop("Shows size of a disk block"),
1514 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1517 BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
1521 {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
1522 gettext_noop("Time to sleep between autovacuum runs, in seconds."),
1525 &autovacuum_naptime,
1526 60, 1, INT_MAX, NULL, NULL
1529 {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
1530 gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
1533 &autovacuum_vac_thresh,
1534 1000, 0, INT_MAX, NULL, NULL
1537 {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
1538 gettext_noop("Minimum number of tuple inserts, updates or deletes prior to analyze."),
1541 &autovacuum_anl_thresh,
1542 500, 0, INT_MAX, NULL, NULL
1546 {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
1547 gettext_noop("Seconds between issuing TCP keepalives."),
1548 gettext_noop("A value of 0 uses the system default."),
1550 &tcp_keepalives_idle,
1551 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle
1555 {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
1556 gettext_noop("Seconds between TCP keepalive retransmits."),
1557 gettext_noop("A value of 0 uses the system default."),
1559 &tcp_keepalives_interval,
1560 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
1564 {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
1565 gettext_noop("Maximum number of TCP keepalive retransmits."),
1566 gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
1567 "lost before a connection is considered dead. A value of 0 uses the "
1570 &tcp_keepalives_count,
1571 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count
1574 /* End-of-list marker */
1576 {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
1581 static struct config_real ConfigureNamesReal[] =
1584 {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
1585 gettext_noop("Sets the planner's assumption about size of the disk cache."),
1586 gettext_noop("That is, the portion of the kernel's disk cache that "
1587 "will be used for PostgreSQL data files. This is measured in disk "
1588 "pages, which are normally 8 kB each.")
1590 &effective_cache_size,
1591 DEFAULT_EFFECTIVE_CACHE_SIZE, 1, DBL_MAX, NULL, NULL
1594 {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1595 gettext_noop("Sets the planner's estimate of the cost of a nonsequentially "
1596 "fetched disk page."),
1597 gettext_noop("This is measured as a multiple of the cost of a "
1598 "sequential page fetch. A higher value makes it more likely a "
1599 "sequential scan will be used, a lower value makes it more likely an "
1600 "index scan will be used.")
1603 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
1606 {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1607 gettext_noop("Sets the planner's estimate of the cost of processing each tuple (row)."),
1608 gettext_noop("This is measured as a fraction of the cost of a "
1609 "sequential page fetch.")
1612 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1615 {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1616 gettext_noop("Sets the planner's estimate of processing cost for each "
1617 "index tuple (row) during index scan."),
1618 gettext_noop("This is measured as a fraction of the cost of a "
1619 "sequential page fetch.")
1621 &cpu_index_tuple_cost,
1622 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1625 {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
1626 gettext_noop("Sets the planner's estimate of processing cost of each operator in WHERE."),
1627 gettext_noop("This is measured as a fraction of the cost of a sequential "
1631 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
1635 {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
1636 gettext_noop("GEQO: selective pressure within the population."),
1639 &Geqo_selection_bias,
1640 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
1641 MAX_GEQO_SELECTION_BIAS, NULL, NULL
1645 {"bgwriter_lru_percent", PGC_SIGHUP, RESOURCES,
1646 gettext_noop("Background writer percentage of LRU buffers to flush per round"),
1649 &bgwriter_lru_percent,
1650 1.0, 0.0, 100.0, NULL, NULL
1654 {"bgwriter_all_percent", PGC_SIGHUP, RESOURCES,
1655 gettext_noop("Background writer percentage of all buffers to flush per round"),
1658 &bgwriter_all_percent,
1659 0.333, 0.0, 100.0, NULL, NULL
1663 {"seed", PGC_USERSET, UNGROUPED,
1664 gettext_noop("Sets the seed for random-number generation."),
1666 GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1669 0.5, 0.0, 1.0, assign_random_seed, show_random_seed
1673 {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1674 gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
1677 &autovacuum_vac_scale,
1678 0.4, 0.0, 100.0, NULL, NULL
1681 {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1682 gettext_noop("Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples."),
1685 &autovacuum_anl_scale,
1686 0.2, 0.0, 100.0, NULL, NULL
1689 /* End-of-list marker */
1691 {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL
1696 static struct config_string ConfigureNamesString[] =
1699 {"archive_command", PGC_SIGHUP, WAL_SETTINGS,
1700 gettext_noop("WAL archiving command."),
1701 gettext_noop("The shell command that will be called to archive a WAL file.")
1703 &XLogArchiveCommand,
1708 {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
1709 gettext_noop("Sets the client's character set encoding."),
1711 GUC_IS_NAME | GUC_REPORT
1713 &client_encoding_string,
1714 "SQL_ASCII", assign_client_encoding, NULL
1718 {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
1719 gettext_noop("Sets the message levels that are sent to the client."),
1720 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, "
1721 "DEBUG1, LOG, NOTICE, WARNING, and ERROR. Each level includes all the "
1722 "levels that follow it. The later the level, the fewer messages are "
1725 &client_min_messages_str,
1726 "notice", assign_client_min_messages, NULL
1730 {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
1731 gettext_noop("Sets the message levels that are logged."),
1732 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, "
1733 "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level "
1734 "includes all the levels that follow it.")
1736 &log_min_messages_str,
1737 "notice", assign_log_min_messages, NULL
1741 {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
1742 gettext_noop("Sets the verbosity of logged messages."),
1743 gettext_noop("Valid values are \"terse\", \"default\", and \"verbose\".")
1745 &log_error_verbosity_str,
1746 "default", assign_log_error_verbosity, NULL
1749 {"log_statement", PGC_SUSET, LOGGING_WHAT,
1750 gettext_noop("Sets the type of statements logged."),
1751 gettext_noop("Valid values are \"none\", \"ddl\", \"mod\", and \"all\".")
1754 "none", assign_log_statement, NULL
1758 {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
1759 gettext_noop("Causes all statements generating error at or above this level to be logged."),
1760 gettext_noop("All SQL statements that cause an error of the "
1761 "specified level or a higher level are logged.")
1763 &log_min_error_statement_str,
1764 "panic", assign_min_error_statement, NULL
1768 {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
1769 gettext_noop("Controls information prefixed to each log line"),
1770 gettext_noop("if blank no prefix is used")
1778 {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
1779 gettext_noop("Sets the display format for date and time values."),
1780 gettext_noop("Also controls interpretation of ambiguous "
1782 GUC_LIST_INPUT | GUC_REPORT
1785 "ISO, MDY", assign_datestyle, NULL
1789 {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
1790 gettext_noop("Sets the default tablespace to create tables and indexes in."),
1791 gettext_noop("An empty string selects the database's default tablespace."),
1794 &default_tablespace,
1795 "", assign_default_tablespace, NULL
1799 {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
1800 gettext_noop("Sets the transaction isolation level of each new transaction."),
1801 gettext_noop("Each SQL transaction has an isolation level, which "
1802 "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
1804 &default_iso_level_string,
1805 "read committed", assign_defaultxactisolevel, NULL
1809 {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
1810 gettext_noop("Sets the path for dynamically loadable modules."),
1811 gettext_noop("If a dynamically loadable module needs to be opened and "
1812 "the specified name does not have a directory component (i.e., the "
1813 "name does not contain a slash), the system will search this path for "
1814 "the specified file."),
1817 &Dynamic_library_path,
1818 "$libdir", NULL, NULL
1822 {"krb_server_keyfile", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1823 gettext_noop("Sets the location of the Kerberos server key file."),
1827 &pg_krb_server_keyfile,
1828 PG_KRB_SRVTAB, NULL, NULL
1832 {"krb_srvname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1833 gettext_noop("Sets the name of the Kerberos service."),
1837 PG_KRB_SRVNAM, NULL, NULL
1841 {"krb_server_hostname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1842 gettext_noop("Sets the hostname of the Kerberos server."),
1845 &pg_krb_server_hostname,
1850 {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1851 gettext_noop("Sets the Bonjour broadcast service name."),
1858 /* See main.c about why defaults for LC_foo are not all alike */
1861 {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1862 gettext_noop("Shows the collation order locale."),
1864 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1871 {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1872 gettext_noop("Shows the character classification and case conversion locale."),
1874 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1881 {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
1882 gettext_noop("Sets the language in which messages are displayed."),
1886 "", locale_messages_assign, NULL
1890 {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
1891 gettext_noop("Sets the locale for formatting monetary amounts."),
1895 "C", locale_monetary_assign, NULL
1899 {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
1900 gettext_noop("Sets the locale for formatting numbers."),
1904 "C", locale_numeric_assign, NULL
1908 {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
1909 gettext_noop("Sets the locale for formatting date and time values."),
1913 "C", locale_time_assign, NULL
1917 {"preload_libraries", PGC_POSTMASTER, RESOURCES_KERNEL,
1918 gettext_noop("Lists shared libraries to preload into server."),
1920 GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
1922 &preload_libraries_string,
1927 {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1928 gettext_noop("Sets the regular expression \"flavor\"."),
1929 gettext_noop("This can be set to advanced, extended, or basic.")
1931 ®ex_flavor_string,
1932 "advanced", assign_regex_flavor, NULL
1936 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
1937 gettext_noop("Sets the schema search order for names that are not schema-qualified."),
1939 GUC_LIST_INPUT | GUC_LIST_QUOTE
1941 &namespace_search_path,
1942 "\"$user\",public", assign_search_path, NULL
1946 /* Can't be set in postgresql.conf */
1947 {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1948 gettext_noop("Sets the server (database) character set encoding."),
1950 GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1952 &server_encoding_string,
1953 "SQL_ASCII", NULL, NULL
1957 /* Can't be set in postgresql.conf */
1958 {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
1959 gettext_noop("Shows the server version."),
1961 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1963 &server_version_string,
1964 PG_VERSION, NULL, NULL
1968 /* Not for general use --- used by SET ROLE */
1969 {"role", PGC_USERSET, UNGROUPED,
1970 gettext_noop("Sets the current role."),
1972 GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1975 "none", assign_role, show_role
1979 /* Not for general use --- used by SET SESSION AUTHORIZATION */
1980 {"session_authorization", PGC_USERSET, UNGROUPED,
1981 gettext_noop("Sets the session user name."),
1983 GUC_IS_NAME | GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1985 &session_authorization_string,
1986 NULL, assign_session_authorization, show_session_authorization
1990 {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
1991 gettext_noop("Sets the destination for server log output."),
1992 gettext_noop("Valid values are combinations of \"stderr\", \"syslog\", "
1993 "and \"eventlog\", depending on the platform."),
1996 &log_destination_string,
1997 "stderr", assign_log_destination, NULL
2000 {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
2001 gettext_noop("Sets the destination directory for log files."),
2002 gettext_noop("May be specified as relative to the data directory "
2003 "or as absolute path."),
2007 "pg_log", assign_canonical_path, NULL
2010 {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
2011 gettext_noop("Sets the file name pattern for log files."),
2016 "postgresql-%Y-%m-%d_%H%M%S.log", NULL, NULL
2021 {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2022 gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2023 gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2024 "LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2026 &syslog_facility_str,
2027 "LOCAL0", assign_syslog_facility, NULL
2030 {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
2031 gettext_noop("Sets the program name used to identify PostgreSQL "
2032 "messages in syslog."),
2036 "postgres", assign_syslog_ident, NULL
2041 {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
2042 gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
2047 "UNKNOWN", assign_timezone, show_timezone
2051 {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2052 gettext_noop("Sets the current transaction's isolation level."),
2054 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2056 &XactIsoLevel_string,
2057 NULL, assign_XactIsoLevel, show_XactIsoLevel
2061 {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2062 gettext_noop("Sets the owning group of the Unix-domain socket."),
2063 gettext_noop("(The owning user of the socket is always the user "
2064 "that starts the server.)")
2071 {"unix_socket_directory", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2072 gettext_noop("Sets the directory where the Unix-domain socket will be created."),
2077 "", assign_canonical_path, NULL
2081 {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2082 gettext_noop("Sets the host name or IP address(es) to listen to."),
2087 "localhost", NULL, NULL
2091 {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
2092 gettext_noop("Selects the method used for forcing WAL updates out to disk."),
2096 XLOG_sync_method_default, assign_xlog_sync_method, NULL
2100 {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
2101 gettext_noop("Sets the list of known custom variable classes."),
2103 GUC_LIST_INPUT | GUC_LIST_QUOTE
2105 &custom_variable_classes,
2106 NULL, assign_custom_variable_classes, NULL
2110 {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
2111 gettext_noop("Sets the server's data directory."),
2120 {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
2121 gettext_noop("Sets the server's main configuration file."),
2123 GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
2130 {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
2131 gettext_noop("Sets the server's \"hba\" configuration file"),
2140 {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
2141 gettext_noop("Sets the server's \"ident\" configuration file"),
2150 {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
2151 gettext_noop("Writes the postmaster PID to the specified file."),
2156 NULL, assign_canonical_path, NULL
2159 /* End-of-list marker */
2161 {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
2166 /******** end of options list ********/
2170 * To allow continued support of obsolete names for GUC variables, we apply
2171 * the following mappings to any unrecognized name. Note that an old name
2172 * should be mapped to a new one only if the new variable has very similar
2173 * semantics to the old.
2175 static const char *const map_old_guc_names[] = {
2176 "sort_mem", "work_mem",
2177 "vacuum_mem", "maintenance_work_mem",
2183 * Actual lookup of variables is done through this single, sorted array.
2185 static struct config_generic **guc_variables;
2187 /* Current number of variables contained in the vector */
2188 static int num_guc_variables;
2190 /* Vector capacity */
2191 static int size_guc_variables;
2194 static bool guc_dirty; /* TRUE if need to do commit/abort work */
2196 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
2199 static int guc_var_compare(const void *a, const void *b);
2200 static int guc_name_compare(const char *namea, const char *nameb);
2201 static void push_old_value(struct config_generic * gconf);
2202 static void ReportGUCOption(struct config_generic * record);
2203 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
2204 static void ShowAllGUCConfig(DestReceiver *dest);
2205 static char *_ShowOption(struct config_generic * record);
2206 static bool is_newvalue_equal(struct config_generic *record, const char *newvalue);
2210 * Some infrastructure for checking malloc/strdup/realloc calls
2213 guc_malloc(int elevel, size_t size)
2217 data = malloc(size);
2220 (errcode(ERRCODE_OUT_OF_MEMORY),
2221 errmsg("out of memory")));
2226 guc_realloc(int elevel, void *old, size_t size)
2230 data = realloc(old, size);
2233 (errcode(ERRCODE_OUT_OF_MEMORY),
2234 errmsg("out of memory")));
2239 guc_strdup(int elevel, const char *src)
2246 (errcode(ERRCODE_OUT_OF_MEMORY),
2247 errmsg("out of memory")));
2253 * Support for assigning to a field of a string GUC item. Free the prior
2254 * value if it's not referenced anywhere else in the item (including stacked
2258 set_string_field(struct config_string * conf, char **field, char *newval)
2260 char *oldval = *field;
2263 /* Do the assignment */
2266 /* Exit if any duplicate references, or if old value was NULL anyway */
2267 if (oldval == NULL ||
2268 oldval == *(conf->variable) ||
2269 oldval == conf->reset_val ||
2270 oldval == conf->tentative_val)
2272 for (stack = conf->gen.stack; stack; stack = stack->prev)
2274 if (oldval == stack->tentative_val.stringval ||
2275 oldval == stack->value.stringval)
2279 /* Not used anymore, so free it */
2284 * Detect whether strval is referenced anywhere in a GUC string item
2287 string_field_used(struct config_string * conf, char *strval)
2291 if (strval == *(conf->variable) ||
2292 strval == conf->reset_val ||
2293 strval == conf->tentative_val)
2295 for (stack = conf->gen.stack; stack; stack = stack->prev)
2297 if (strval == stack->tentative_val.stringval ||
2298 strval == stack->value.stringval)
2305 struct config_generic **
2306 get_guc_variables(void)
2308 return guc_variables;
2313 * Build the sorted array. This is split out so that it could be
2314 * re-executed after startup (eg, we could allow loadable modules to
2315 * add vars, and then we'd need to re-sort).
2318 build_guc_variables(void)
2322 struct config_generic **guc_vars;
2325 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2327 struct config_bool *conf = &ConfigureNamesBool[i];
2329 /* Rather than requiring vartype to be filled in by hand, do this: */
2330 conf->gen.vartype = PGC_BOOL;
2334 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2336 struct config_int *conf = &ConfigureNamesInt[i];
2338 conf->gen.vartype = PGC_INT;
2342 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2344 struct config_real *conf = &ConfigureNamesReal[i];
2346 conf->gen.vartype = PGC_REAL;
2350 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2352 struct config_string *conf = &ConfigureNamesString[i];
2354 conf->gen.vartype = PGC_STRING;
2359 * Create table with 20% slack
2361 size_vars = num_vars + num_vars / 4;
2363 guc_vars = (struct config_generic **)
2364 guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
2368 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2369 guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
2371 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2372 guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
2374 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2375 guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
2377 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2378 guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
2381 free(guc_variables);
2382 guc_variables = guc_vars;
2383 num_guc_variables = num_vars;
2384 size_guc_variables = size_vars;
2385 qsort((void *) guc_variables, num_guc_variables,
2386 sizeof(struct config_generic *), guc_var_compare);
2390 is_custom_class(const char *name, int dotPos)
2393 * assign_custom_variable_classes() has made sure no empty identifiers or
2394 * whitespace exists in the variable
2396 bool result = false;
2397 const char *ccs = GetConfigOption("custom_variable_classes");
2401 const char *start = ccs;
2407 if (c == 0 || c == ',')
2409 if (dotPos == ccs - start && strncmp(start, name, dotPos) == 0)
2424 * Add a new GUC variable to the list of known variables. The
2425 * list is expanded if needed.
2428 add_guc_variable(struct config_generic * var, int elevel)
2430 if (num_guc_variables + 1 >= size_guc_variables)
2433 * Increase the vector by 25%
2435 int size_vars = size_guc_variables + size_guc_variables / 4;
2436 struct config_generic **guc_vars;
2441 guc_vars = (struct config_generic **)
2442 guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
2446 guc_vars = (struct config_generic **)
2447 guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
2450 if (guc_vars == NULL)
2451 return false; /* out of memory */
2453 guc_variables = guc_vars;
2454 size_guc_variables = size_vars;
2456 guc_variables[num_guc_variables++] = var;
2457 qsort((void *) guc_variables, num_guc_variables,
2458 sizeof(struct config_generic *), guc_var_compare);
2463 * Create and add a placeholder variable. It's presumed to belong
2464 * to a valid custom variable class at this point.
2466 static struct config_string *
2467 add_placeholder_variable(const char *name, int elevel)
2469 size_t sz = sizeof(struct config_string) + sizeof(char *);
2470 struct config_string *var;
2471 struct config_generic *gen;
2473 var = (struct config_string *) guc_malloc(elevel, sz);
2480 gen->name = guc_strdup(elevel, name);
2481 if (gen->name == NULL)
2487 gen->context = PGC_USERSET;
2488 gen->group = CUSTOM_OPTIONS;
2489 gen->short_desc = "GUC placeholder variable";
2490 gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
2491 gen->vartype = PGC_STRING;
2494 * The char* is allocated at the end of the struct since we have no
2495 * 'static' place to point to.
2497 var->variable = (char **) (var + 1);
2499 if (!add_guc_variable((struct config_generic *) var, elevel))
2501 free((void *) gen->name);
2510 * Look up option NAME. If it exists, return a pointer to its record,
2513 static struct config_generic *
2514 find_option(const char *name, int elevel)
2517 const char **key = &name;
2518 struct config_generic **res;
2524 * By equating const char ** with struct config_generic *, we are assuming
2525 * the name field is first in config_generic.
2527 res = (struct config_generic **) bsearch((void *) &key,
2528 (void *) guc_variables,
2530 sizeof(struct config_generic *),
2536 * See if the name is an obsolete name for a variable. We assume that the
2537 * set of supported old names is short enough that a brute-force search is
2540 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
2542 if (guc_name_compare(name, map_old_guc_names[i]) == 0)
2543 return find_option(map_old_guc_names[i + 1], elevel);
2547 * Check if the name is qualified, and if so, check if the qualifier maps
2548 * to a custom variable class.
2550 dot = strchr(name, GUC_QUALIFIER_SEPARATOR);
2551 if (dot != NULL && is_custom_class(name, dot - name))
2552 /* Add a placeholder variable for this name */
2553 return (struct config_generic *) add_placeholder_variable(name, elevel);
2561 * comparator for qsorting and bsearching guc_variables array
2564 guc_var_compare(const void *a, const void *b)
2566 struct config_generic *confa = *(struct config_generic **) a;
2567 struct config_generic *confb = *(struct config_generic **) b;
2569 return guc_name_compare(confa->name, confb->name);
2574 guc_name_compare(const char *namea, const char *nameb)
2577 * The temptation to use strcasecmp() here must be resisted, because the
2578 * array ordering has to remain stable across setlocale() calls. So, build
2579 * our own with a simple ASCII-only downcasing.
2581 while (*namea && *nameb)
2583 char cha = *namea++;
2584 char chb = *nameb++;
2586 if (cha >= 'A' && cha <= 'Z')
2588 if (chb >= 'A' && chb <= 'Z')
2594 return 1; /* a is longer */
2596 return -1; /* b is longer */
2602 * Initialize GUC options during program startup.
2604 * Note that we cannot read the config file yet, since we have not yet
2605 * processed command-line switches.
2608 InitializeGUCOptions(void)
2614 * Build sorted array of all GUC variables.
2616 build_guc_variables();
2619 * Load all variables with their compiled-in defaults, and initialize
2620 * status fields as needed.
2622 for (i = 0; i < num_guc_variables; i++)
2624 struct config_generic *gconf = guc_variables[i];
2627 gconf->reset_source = PGC_S_DEFAULT;
2628 gconf->tentative_source = PGC_S_DEFAULT;
2629 gconf->source = PGC_S_DEFAULT;
2630 gconf->stack = NULL;
2632 switch (gconf->vartype)
2636 struct config_bool *conf = (struct config_bool *) gconf;
2638 if (conf->assign_hook)
2639 if (!(*conf->assign_hook) (conf->reset_val, true,
2641 elog(FATAL, "failed to initialize %s to %d",
2642 conf->gen.name, (int) conf->reset_val);
2643 *conf->variable = conf->reset_val;
2648 struct config_int *conf = (struct config_int *) gconf;
2650 Assert(conf->reset_val >= conf->min);
2651 Assert(conf->reset_val <= conf->max);
2652 if (conf->assign_hook)
2653 if (!(*conf->assign_hook) (conf->reset_val, true,
2655 elog(FATAL, "failed to initialize %s to %d",
2656 conf->gen.name, conf->reset_val);
2657 *conf->variable = conf->reset_val;
2662 struct config_real *conf = (struct config_real *) gconf;
2664 Assert(conf->reset_val >= conf->min);
2665 Assert(conf->reset_val <= conf->max);
2666 if (conf->assign_hook)
2667 if (!(*conf->assign_hook) (conf->reset_val, true,
2669 elog(FATAL, "failed to initialize %s to %g",
2670 conf->gen.name, conf->reset_val);
2671 *conf->variable = conf->reset_val;
2676 struct config_string *conf = (struct config_string *) gconf;
2679 *conf->variable = NULL;
2680 conf->reset_val = NULL;
2681 conf->tentative_val = NULL;
2683 if (conf->boot_val == NULL)
2685 /* Cannot set value yet */
2689 str = guc_strdup(FATAL, conf->boot_val);
2690 conf->reset_val = str;
2692 if (conf->assign_hook)
2696 newstr = (*conf->assign_hook) (str, true,
2700 elog(FATAL, "failed to initialize %s to \"%s\"",
2701 conf->gen.name, str);
2703 else if (newstr != str)
2708 * See notes in set_config_option about casting
2710 str = (char *) newstr;
2711 conf->reset_val = str;
2714 *conf->variable = str;
2722 reporting_enabled = false;
2725 * Prevent any attempt to override the transaction modes from
2726 * non-interactive sources.
2728 SetConfigOption("transaction_isolation", "default",
2729 PGC_POSTMASTER, PGC_S_OVERRIDE);
2730 SetConfigOption("transaction_read_only", "no",
2731 PGC_POSTMASTER, PGC_S_OVERRIDE);
2734 * For historical reasons, some GUC parameters can receive defaults from
2735 * environment variables. Process those settings.
2738 env = getenv("PGPORT");
2740 SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2742 env = getenv("PGDATESTYLE");
2744 SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2746 env = getenv("PGCLIENTENCODING");
2748 SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2753 * Select the configuration files and data directory to be used, and
2754 * do the initial read of postgresql.conf.
2756 * This is called after processing command-line switches.
2757 * userDoption is the -D switch value if any (NULL if unspecified).
2758 * progname is just for use in error messages.
2760 * Returns true on success; on failure, prints a suitable error message
2761 * to stderr and returns false.
2764 SelectConfigFiles(const char *userDoption, const char *progname)
2768 struct stat stat_buf;
2770 /* configdir is -D option, or $PGDATA if no -D */
2772 configdir = make_absolute_path(userDoption);
2774 configdir = make_absolute_path(getenv("PGDATA"));
2777 * Find the configuration file: if config_file was specified on the
2778 * command line, use it, else use configdir/postgresql.conf. In any case
2779 * ensure the result is an absolute path, so that it will be interpreted
2780 * the same way by future backends.
2783 fname = make_absolute_path(ConfigFileName);
2786 fname = guc_malloc(FATAL,
2787 strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
2788 sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
2792 write_stderr("%s does not know where to find the server configuration file.\n"
2793 "You must specify the --config-file or -D invocation "
2794 "option or set the PGDATA environment variable.\n",
2800 * Set the ConfigFileName GUC variable to its final value, ensuring that
2801 * it can't be overridden later.
2803 SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2807 * Now read the config file for the first time.
2809 if (stat(ConfigFileName, &stat_buf) != 0)
2811 write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
2812 progname, ConfigFileName, strerror(errno));
2816 ProcessConfigFile(PGC_POSTMASTER);
2819 * If the data_directory GUC variable has been set, use that as DataDir;
2820 * otherwise use configdir if set; else punt.
2822 * Note: SetDataDir will copy and absolute-ize its argument, so we don't
2826 SetDataDir(data_directory);
2828 SetDataDir(configdir);
2831 write_stderr("%s does not know where to find the database system data.\n"
2832 "This can be specified as \"data_directory\" in \"%s\", "
2833 "or by the -D invocation option, or by the "
2834 "PGDATA environment variable.\n",
2835 progname, ConfigFileName);
2840 * Reflect the final DataDir value back into the data_directory GUC var.
2841 * (If you are wondering why we don't just make them a single variable,
2842 * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
2843 * child backends specially. XXX is that still true? Given that we now
2844 * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
2845 * DataDir in advance.)
2847 SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
2850 * Figure out where pg_hba.conf is, and make sure the path is absolute.
2853 fname = make_absolute_path(HbaFileName);
2856 fname = guc_malloc(FATAL,
2857 strlen(configdir) + strlen(HBA_FILENAME) + 2);
2858 sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
2862 write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
2863 "This can be specified as \"hba_file\" in \"%s\", "
2864 "or by the -D invocation option, or by the "
2865 "PGDATA environment variable.\n",
2866 progname, ConfigFileName);
2869 SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2873 * Likewise for pg_ident.conf.
2876 fname = make_absolute_path(IdentFileName);
2879 fname = guc_malloc(FATAL,
2880 strlen(configdir) + strlen(IDENT_FILENAME) + 2);
2881 sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
2885 write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
2886 "This can be specified as \"ident_file\" in \"%s\", "
2887 "or by the -D invocation option, or by the "
2888 "PGDATA environment variable.\n",
2889 progname, ConfigFileName);
2892 SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2902 * Reset all options to their saved default values (implements RESET ALL)
2905 ResetAllOptions(void)
2909 for (i = 0; i < num_guc_variables; i++)
2911 struct config_generic *gconf = guc_variables[i];
2913 /* Don't reset non-SET-able values */
2914 if (gconf->context != PGC_SUSET &&
2915 gconf->context != PGC_USERSET)
2917 /* Don't reset if special exclusion from RESET ALL */
2918 if (gconf->flags & GUC_NO_RESET_ALL)
2920 /* No need to reset if wasn't SET */
2921 if (gconf->source <= PGC_S_OVERRIDE)
2924 /* Save old value to support transaction abort */
2925 push_old_value(gconf);
2927 switch (gconf->vartype)
2931 struct config_bool *conf = (struct config_bool *) gconf;
2933 if (conf->assign_hook)
2934 if (!(*conf->assign_hook) (conf->reset_val, true,
2936 elog(ERROR, "failed to reset %s", conf->gen.name);
2937 *conf->variable = conf->reset_val;
2938 conf->tentative_val = conf->reset_val;
2939 conf->gen.source = conf->gen.reset_source;
2940 conf->gen.tentative_source = conf->gen.reset_source;
2941 conf->gen.status |= GUC_HAVE_TENTATIVE;
2947 struct config_int *conf = (struct config_int *) gconf;
2949 if (conf->assign_hook)
2950 if (!(*conf->assign_hook) (conf->reset_val, true,
2952 elog(ERROR, "failed to reset %s", conf->gen.name);
2953 *conf->variable = conf->reset_val;
2954 conf->tentative_val = conf->reset_val;
2955 conf->gen.source = conf->gen.reset_source;
2956 conf->gen.tentative_source = conf->gen.reset_source;
2957 conf->gen.status |= GUC_HAVE_TENTATIVE;
2963 struct config_real *conf = (struct config_real *) gconf;
2965 if (conf->assign_hook)
2966 if (!(*conf->assign_hook) (conf->reset_val, true,
2968 elog(ERROR, "failed to reset %s", conf->gen.name);
2969 *conf->variable = conf->reset_val;
2970 conf->tentative_val = conf->reset_val;
2971 conf->gen.source = conf->gen.reset_source;
2972 conf->gen.tentative_source = conf->gen.reset_source;
2973 conf->gen.status |= GUC_HAVE_TENTATIVE;
2979 struct config_string *conf = (struct config_string *) gconf;
2982 if (conf->reset_val == NULL)
2984 /* Nothing to reset to, as yet; so do nothing */
2988 /* We need not strdup here */
2989 str = conf->reset_val;
2991 if (conf->assign_hook)
2995 newstr = (*conf->assign_hook) (str, true,
2998 elog(ERROR, "failed to reset %s", conf->gen.name);
2999 else if (newstr != str)
3002 * See notes in set_config_option about casting
3004 str = (char *) newstr;
3008 set_string_field(conf, conf->variable, str);
3009 set_string_field(conf, &conf->tentative_val, str);
3010 conf->gen.source = conf->gen.reset_source;
3011 conf->gen.tentative_source = conf->gen.reset_source;
3012 conf->gen.status |= GUC_HAVE_TENTATIVE;
3018 if (gconf->flags & GUC_REPORT)
3019 ReportGUCOption(gconf);
3026 * Push previous state during first assignment to a GUC variable
3027 * within a particular transaction.
3029 * We have to be willing to "back-fill" the state stack if the first
3030 * assignment occurs within a subtransaction nested several levels deep.
3031 * This ensures that if an intermediate transaction aborts, it will have
3032 * the proper value available to restore the setting to.
3035 push_old_value(struct config_generic * gconf)
3037 int my_level = GetCurrentTransactionNestLevel();
3040 /* If we're not inside a transaction, do nothing */
3046 /* Done if we already pushed it at this nesting depth */
3047 if (gconf->stack && gconf->stack->nest_level >= my_level)
3051 * We keep all the stack entries in TopTransactionContext so as to
3052 * avoid allocation problems when a subtransaction back-fills stack
3053 * entries for upper transaction levels.
3055 stack = (GucStack *) MemoryContextAlloc(TopTransactionContext,
3058 stack->prev = gconf->stack;
3059 stack->nest_level = stack->prev ? stack->prev->nest_level + 1 : 1;
3060 stack->status = gconf->status;
3061 stack->tentative_source = gconf->tentative_source;
3062 stack->source = gconf->source;
3064 switch (gconf->vartype)
3067 stack->tentative_val.boolval =
3068 ((struct config_bool *) gconf)->tentative_val;
3069 stack->value.boolval =
3070 *((struct config_bool *) gconf)->variable;
3074 stack->tentative_val.intval =
3075 ((struct config_int *) gconf)->tentative_val;
3076 stack->value.intval =
3077 *((struct config_int *) gconf)->variable;
3081 stack->tentative_val.realval =
3082 ((struct config_real *) gconf)->tentative_val;
3083 stack->value.realval =
3084 *((struct config_real *) gconf)->variable;
3088 stack->tentative_val.stringval =
3089 ((struct config_string *) gconf)->tentative_val;
3090 stack->value.stringval =
3091 *((struct config_string *) gconf)->variable;
3095 gconf->stack = stack;
3097 /* Set state to indicate nothing happened yet within this level */
3098 gconf->status = GUC_HAVE_STACK;
3100 /* Ensure we remember to pop at end of xact */
3106 * Do GUC processing at transaction or subtransaction commit or abort.
3109 AtEOXact_GUC(bool isCommit, bool isSubXact)
3114 /* Quick exit if nothing's changed in this transaction */
3118 my_level = GetCurrentTransactionNestLevel();
3119 Assert(isSubXact ? (my_level > 1) : (my_level == 1));
3121 for (i = 0; i < num_guc_variables; i++)
3123 struct config_generic *gconf = guc_variables[i];
3124 int my_status = gconf->status;
3125 GucStack *stack = gconf->stack;
3130 * Skip if nothing's happened to this var in this transaction
3134 Assert(stack == NULL);
3137 /* Assert that we stacked old value before changing it */
3138 Assert(stack != NULL && (my_status & GUC_HAVE_STACK));
3139 /* However, the last change may have been at an outer xact level */
3140 if (stack->nest_level < my_level)
3142 Assert(stack->nest_level == my_level);
3145 * We will pop the stack entry. Start by restoring outer xact status
3146 * (since we may want to modify it below). Be careful to use
3147 * my_status to reference the inner xact status below this point...
3149 gconf->status = stack->status;
3152 * We have two cases:
3154 * If commit and HAVE_TENTATIVE, set actual value to tentative (this
3155 * is to override a SET LOCAL if one occurred later than SET). We keep
3156 * the tentative value and propagate HAVE_TENTATIVE to the parent
3157 * status, allowing the SET's effect to percolate up. (But if we're
3158 * exiting the outermost transaction, we'll drop the HAVE_TENTATIVE
3161 * Otherwise, we have a transaction that aborted or executed only SET
3162 * LOCAL (or no SET at all). In either case it should have no further
3163 * effect, so restore both tentative and actual values from the stack
3167 useTentative = isCommit && (my_status & GUC_HAVE_TENTATIVE) != 0;
3170 switch (gconf->vartype)
3174 struct config_bool *conf = (struct config_bool *) gconf;
3176 GucSource newsource;
3180 newval = conf->tentative_val;
3181 newsource = conf->gen.tentative_source;
3182 conf->gen.status |= GUC_HAVE_TENTATIVE;
3186 newval = stack->value.boolval;
3187 newsource = stack->source;
3188 conf->tentative_val = stack->tentative_val.boolval;
3189 conf->gen.tentative_source = stack->tentative_source;
3192 if (*conf->variable != newval)
3194 if (conf->assign_hook)
3195 if (!(*conf->assign_hook) (newval,
3196 true, PGC_S_OVERRIDE))
3197 elog(LOG, "failed to commit %s",
3199 *conf->variable = newval;
3202 conf->gen.source = newsource;
3207 struct config_int *conf = (struct config_int *) gconf;
3209 GucSource newsource;
3213 newval = conf->tentative_val;
3214 newsource = conf->gen.tentative_source;
3215 conf->gen.status |= GUC_HAVE_TENTATIVE;
3219 newval = stack->value.intval;
3220 newsource = stack->source;
3221 conf->tentative_val = stack->tentative_val.intval;
3222 conf->gen.tentative_source = stack->tentative_source;
3225 if (*conf->variable != newval)
3227 if (conf->assign_hook)
3228 if (!(*conf->assign_hook) (newval,
3229 true, PGC_S_OVERRIDE))
3230 elog(LOG, "failed to commit %s",
3232 *conf->variable = newval;
3235 conf->gen.source = newsource;
3240 struct config_real *conf = (struct config_real *) gconf;
3242 GucSource newsource;
3246 newval = conf->tentative_val;
3247 newsource = conf->gen.tentative_source;
3248 conf->gen.status |= GUC_HAVE_TENTATIVE;
3252 newval = stack->value.realval;
3253 newsource = stack->source;
3254 conf->tentative_val = stack->tentative_val.realval;
3255 conf->gen.tentative_source = stack->tentative_source;
3258 if (*conf->variable != newval)
3260 if (conf->assign_hook)
3261 if (!(*conf->assign_hook) (newval,
3262 true, PGC_S_OVERRIDE))
3263 elog(LOG, "failed to commit %s",
3265 *conf->variable = newval;
3268 conf->gen.source = newsource;
3273 struct config_string *conf = (struct config_string *) gconf;
3275 GucSource newsource;
3279 newval = conf->tentative_val;
3280 newsource = conf->gen.tentative_source;
3281 conf->gen.status |= GUC_HAVE_TENTATIVE;
3285 newval = stack->value.stringval;
3286 newsource = stack->source;
3287 set_string_field(conf, &conf->tentative_val,
3288 stack->tentative_val.stringval);
3289 conf->gen.tentative_source = stack->tentative_source;
3292 if (*conf->variable != newval)
3294 if (conf->assign_hook)
3298 newstr = (*conf->assign_hook) (newval, true,
3301 elog(LOG, "failed to commit %s",
3303 else if (newstr != newval)
3306 * If newval should now be freed, it'll be
3307 * taken care of below.
3309 * See notes in set_config_option about
3312 newval = (char *) newstr;
3316 set_string_field(conf, conf->variable, newval);
3319 conf->gen.source = newsource;
3320 /* Release stacked values if not used anymore */
3321 set_string_field(conf, &stack->value.stringval,
3323 set_string_field(conf, &stack->tentative_val.stringval,
3325 /* Don't store tentative value separately after commit */
3327 set_string_field(conf, &conf->tentative_val, NULL);
3332 /* Finish popping the state stack */
3333 gconf->stack = stack->prev;
3337 * If we're now out of all xact levels, forget TENTATIVE status bit;
3338 * there's nothing tentative about the value anymore.
3342 Assert(gconf->stack == NULL);
3346 /* Report new value if we changed it */
3347 if (changed && (gconf->flags & GUC_REPORT))
3348 ReportGUCOption(gconf);
3352 * If we're now out of all xact levels, we can clear guc_dirty. (Note: we
3353 * cannot reset guc_dirty when exiting a subtransaction, because we know
3354 * that all outer transaction levels will have stacked values to deal
3363 * Start up automatic reporting of changes to variables marked GUC_REPORT.
3364 * This is executed at completion of backend startup.
3367 BeginReportingGUCOptions(void)
3372 * Don't do anything unless talking to an interactive frontend of protocol
3375 if (whereToSendOutput != DestRemote ||
3376 PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
3379 reporting_enabled = true;
3381 /* Transmit initial values of interesting variables */
3382 for (i = 0; i < num_guc_variables; i++)
3384 struct config_generic *conf = guc_variables[i];
3386 if (conf->flags & GUC_REPORT)
3387 ReportGUCOption(conf);
3392 * ReportGUCOption: if appropriate, transmit option value to frontend
3395 ReportGUCOption(struct config_generic * record)
3397 if (reporting_enabled && (record->flags & GUC_REPORT))
3399 char *val = _ShowOption(record);
3400 StringInfoData msgbuf;
3402 pq_beginmessage(&msgbuf, 'S');
3403 pq_sendstring(&msgbuf, record->name);
3404 pq_sendstring(&msgbuf, val);
3405 pq_endmessage(&msgbuf);
3413 * Try to interpret value as boolean value. Valid values are: true,
3414 * false, yes, no, on, off, 1, 0. If the string parses okay, return
3415 * true, else false. If result is not NULL, return the parsing result
3419 parse_bool(const char *value, bool *result)
3421 size_t len = strlen(value);
3423 if (pg_strncasecmp(value, "true", len) == 0)
3428 else if (pg_strncasecmp(value, "false", len) == 0)
3434 else if (pg_strncasecmp(value, "yes", len) == 0)
3439 else if (pg_strncasecmp(value, "no", len) == 0)
3445 else if (pg_strcasecmp(value, "on") == 0)
3450 else if (pg_strcasecmp(value, "off") == 0)
3456 else if (pg_strcasecmp(value, "1") == 0)
3461 else if (pg_strcasecmp(value, "0") == 0)
3470 *result = false; /* suppress compiler warning */
3479 * Try to parse value as an integer. The accepted formats are the
3480 * usual decimal, octal, or hexadecimal formats. If the string parses
3481 * okay, return true, else false. If result is not NULL, return the
3485 parse_int(const char *value, int *result)
3491 val = strtol(value, &endptr, 0);
3492 if (endptr == value || *endptr != '\0' || errno == ERANGE
3493 #ifdef HAVE_LONG_INT_64
3494 /* if long > 32 bits, check for overflow of int4 */
3495 || val != (long) ((int32) val)
3500 *result = 0; /* suppress compiler warning */
3504 *result = (int) val;
3511 * Try to parse value as a floating point constant in the usual
3512 * format. If the value parsed okay return true, else false. If
3513 * result is not NULL, return the semantic value there.
3516 parse_real(const char *value, double *result)
3522 val = strtod(value, &endptr);
3523 if (endptr == value || *endptr != '\0' || errno == ERANGE)
3526 *result = 0; /* suppress compiler warning */
3536 * Call a GucStringAssignHook function, being careful to free the
3537 * "newval" string if the hook ereports.
3539 * This is split out of set_config_option just to avoid the "volatile"
3540 * qualifiers that would otherwise have to be plastered all over.
3543 call_string_assign_hook(GucStringAssignHook assign_hook,
3544 char *newval, bool doit, GucSource source)
3550 result = (*assign_hook) (newval, doit, source);
3564 * Sets option `name' to given value. The value should be a string
3565 * which is going to be parsed and converted to the appropriate data
3566 * type. The context and source parameters indicate in which context this
3567 * function is being called so it can apply the access restrictions
3570 * If value is NULL, set the option to its default value. If the
3571 * parameter changeVal is false then don't really set the option but do all
3572 * the checks to see if it would work.
3574 * If there is an error (non-existing option, invalid value) then an
3575 * ereport(ERROR) is thrown *unless* this is called in a context where we
3576 * don't want to ereport (currently, startup or SIGHUP config file reread).
3577 * In that case we write a suitable error message via ereport(DEBUG) and
3578 * return false. This is working around the deficiencies in the ereport
3579 * mechanism, so don't blame me. In all other cases, the function
3580 * returns true, including cases where the input is valid but we chose
3581 * not to apply it because of context or source-priority considerations.
3583 * See also SetConfigOption for an external interface.
3586 set_config_option(const char *name, const char *value,
3587 GucContext context, GucSource source,
3588 bool isLocal, bool changeVal)
3590 struct config_generic *record;
3594 if (context == PGC_SIGHUP || source == PGC_S_DEFAULT)
3597 * To avoid cluttering the log, only the postmaster bleats loudly
3598 * about problems with the config file.
3600 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
3602 else if (source == PGC_S_DATABASE || source == PGC_S_USER)
3607 record = find_option(name, elevel);
3611 (errcode(ERRCODE_UNDEFINED_OBJECT),
3612 errmsg("unrecognized configuration parameter \"%s\"", name)));
3617 * Check if the option can be set at this time. See guc.h for the precise
3618 * rules. Note that we don't want to throw errors if we're in the SIGHUP
3619 * context. In that case we just ignore the attempt and return true.
3621 switch (record->context)
3624 if (context == PGC_SIGHUP)
3626 if (context != PGC_INTERNAL)
3629 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3630 errmsg("parameter \"%s\" cannot be changed",
3635 case PGC_POSTMASTER:
3636 if (context == PGC_SIGHUP)
3638 if (changeVal && !is_newvalue_equal(record, value))
3640 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3641 errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
3646 if (context != PGC_POSTMASTER)
3649 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3650 errmsg("parameter \"%s\" cannot be changed after server start",
3656 if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
3659 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3660 errmsg("parameter \"%s\" cannot be changed now",
3666 * Hmm, the idea of the SIGHUP context is "ought to be global, but
3667 * can be changed after postmaster start". But there's nothing
3668 * that prevents a crafty administrator from sending SIGHUP
3669 * signals to individual backends only.
3673 if (context == PGC_SIGHUP)
3676 * If a PGC_BACKEND parameter is changed in the config file,
3677 * we want to accept the new value in the postmaster (whence
3678 * it will propagate to subsequently-started backends), but
3679 * ignore it in existing backends. This is a tad klugy, but
3680 * necessary because we don't re-read the config file during
3683 if (IsUnderPostmaster)
3686 else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
3689 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3690 errmsg("parameter \"%s\" cannot be set after connection start",
3696 if (context == PGC_USERSET || context == PGC_BACKEND)
3699 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3700 errmsg("permission denied to set parameter \"%s\"",
3711 * Should we set reset/stacked values? (If so, the behavior is not
3714 makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL);
3717 * Ignore attempted set if overridden by previously processed setting.
3718 * However, if changeVal is false then plow ahead anyway since we are
3719 * trying to find out if the value is potentially good, not actually use
3720 * it. Also keep going if makeDefault is true, since we may want to set
3721 * the reset/stacked values even if we can't set the variable itself.
3723 if (record->source > source)
3725 if (changeVal && !makeDefault)
3727 elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
3735 * Evaluate value and set variable.
3737 switch (record->vartype)
3741 struct config_bool *conf = (struct config_bool *) record;
3746 if (!parse_bool(value, &newval))
3749 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3750 errmsg("parameter \"%s\" requires a Boolean value",
3757 newval = conf->reset_val;
3758 source = conf->gen.reset_source;
3761 if (conf->assign_hook)
3762 if (!(*conf->assign_hook) (newval, changeVal, source))
3765 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3766 errmsg("invalid value for parameter \"%s\": %d",
3767 name, (int) newval)));
3771 if (changeVal || makeDefault)
3773 /* Save old value to support transaction abort */
3775 push_old_value(&conf->gen);
3778 *conf->variable = newval;
3779 conf->gen.source = source;
3785 if (conf->gen.reset_source <= source)
3787 conf->reset_val = newval;
3788 conf->gen.reset_source = source;
3790 for (stack = conf->gen.stack; stack; stack = stack->prev)
3792 if (stack->source <= source)
3794 stack->value.boolval = newval;
3795 stack->source = source;
3801 conf->gen.status |= GUC_HAVE_LOCAL;
3806 conf->tentative_val = newval;
3807 conf->gen.tentative_source = source;
3808 conf->gen.status |= GUC_HAVE_TENTATIVE;
3817 struct config_int *conf = (struct config_int *) record;
3822 if (!parse_int(value, &newval))
3825 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3826 errmsg("parameter \"%s\" requires an integer value",
3830 if (newval < conf->min || newval > conf->max)
3833 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3834 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
3835 newval, name, conf->min, conf->max)));
3841 newval = conf->reset_val;
3842 source = conf->gen.reset_source;
3845 if (conf->assign_hook)
3846 if (!(*conf->assign_hook) (newval, changeVal, source))
3849 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3850 errmsg("invalid value for parameter \"%s\": %d",
3855 if (changeVal || makeDefault)
3857 /* Save old value to support transaction abort */
3859 push_old_value(&conf->gen);
3862 *conf->variable = newval;
3863 conf->gen.source = source;
3869 if (conf->gen.reset_source <= source)
3871 conf->reset_val = newval;
3872 conf->gen.reset_source = source;
3874 for (stack = conf->gen.stack; stack; stack = stack->prev)
3876 if (stack->source <= source)
3878 stack->value.intval = newval;
3879 stack->source = source;
3885 conf->gen.status |= GUC_HAVE_LOCAL;
3890 conf->tentative_val = newval;
3891 conf->gen.tentative_source = source;
3892 conf->gen.status |= GUC_HAVE_TENTATIVE;
3901 struct config_real *conf = (struct config_real *) record;
3906 if (!parse_real(value, &newval))
3909 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3910 errmsg("parameter \"%s\" requires a numeric value",
3914 if (newval < conf->min || newval > conf->max)
3917 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3918 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
3919 newval, name, conf->min, conf->max)));
3925 newval = conf->reset_val;
3926 source = conf->gen.reset_source;
3929 if (conf->assign_hook)
3930 if (!(*conf->assign_hook) (newval, changeVal, source))
3933 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3934 errmsg("invalid value for parameter \"%s\": %g",
3939 if (changeVal || makeDefault)
3941 /* Save old value to support transaction abort */
3943 push_old_value(&conf->gen);
3946 *conf->variable = newval;
3947 conf->gen.source = source;
3953 if (conf->gen.reset_source <= source)
3955 conf->reset_val = newval;
3956 conf->gen.reset_source = source;
3958 for (stack = conf->gen.stack; stack; stack = stack->prev)
3960 if (stack->source <= source)
3962 stack->value.realval = newval;
3963 stack->source = source;
3969 conf->gen.status |= GUC_HAVE_LOCAL;
3974 conf->tentative_val = newval;
3975 conf->gen.tentative_source = source;
3976 conf->gen.status |= GUC_HAVE_TENTATIVE;
3985 struct config_string *conf = (struct config_string *) record;
3990 newval = guc_strdup(elevel, value);
3994 * The only sort of "parsing" check we need to do is
3995 * apply truncation if GUC_IS_NAME.
3997 if (conf->gen.flags & GUC_IS_NAME)
3998 truncate_identifier(newval, strlen(newval), true);
4000 else if (conf->reset_val)
4003 * We could possibly avoid strdup here, but easier to make
4004 * this case work the same as the normal assignment case.
4006 newval = guc_strdup(elevel, conf->reset_val);
4009 source = conf->gen.reset_source;
4013 /* Nothing to reset to, as yet; so do nothing */
4017 if (conf->assign_hook)
4019 const char *hookresult;
4022 * If the hook ereports, we have to make sure we free
4023 * newval, else it will be a permanent memory leak.
4025 hookresult = call_string_assign_hook(conf->assign_hook,
4029 if (hookresult == NULL)
4033 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4034 errmsg("invalid value for parameter \"%s\": \"%s\"",
4035 name, value ? value : "")));
4038 else if (hookresult != newval)
4043 * Having to cast away const here is annoying, but the
4044 * alternative is to declare assign_hooks as returning
4045 * char*, which would mean they'd have to cast away
4046 * const, or as both taking and returning char*, which
4047 * doesn't seem attractive either --- we don't want
4048 * them to scribble on the passed str.
4050 newval = (char *) hookresult;
4054 if (changeVal || makeDefault)
4056 /* Save old value to support transaction abort */
4058 push_old_value(&conf->gen);
4061 set_string_field(conf, conf->variable, newval);
4062 conf->gen.source = source;
4068 if (conf->gen.reset_source <= source)
4070 set_string_field(conf, &conf->reset_val, newval);
4071 conf->gen.reset_source = source;
4073 for (stack = conf->gen.stack; stack; stack = stack->prev)
4075 if (stack->source <= source)
4077 set_string_field(conf, &stack->value.stringval,
4079 stack->source = source;
4082 /* Perhaps we didn't install newval anywhere */
4083 if (!string_field_used(conf, newval))
4088 conf->gen.status |= GUC_HAVE_LOCAL;
4093 set_string_field(conf, &conf->tentative_val, newval);
4094 conf->gen.tentative_source = source;
4095 conf->gen.status |= GUC_HAVE_TENTATIVE;
4105 if (changeVal && (record->flags & GUC_REPORT))
4106 ReportGUCOption(record);
4113 * Set a config option to the given value. See also set_config_option,
4114 * this is just the wrapper to be called from outside GUC. NB: this
4115 * is used only for non-transactional operations.
4118 SetConfigOption(const char *name, const char *value,
4119 GucContext context, GucSource source)
4121 (void) set_config_option(name, value, context, source, false, true);
4127 * Fetch the current value of the option `name'. If the option doesn't exist,
4128 * throw an ereport and don't return.
4130 * The string is *not* allocated for modification and is really only
4131 * valid until the next call to configuration related functions.
4134 GetConfigOption(const char *name)
4136 struct config_generic *record;
4137 static char buffer[256];
4139 record = find_option(name, ERROR);
4142 (errcode(ERRCODE_UNDEFINED_OBJECT),
4143 errmsg("unrecognized configuration parameter \"%s\"", name)));
4144 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4146 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4147 errmsg("must be superuser to examine \"%s\"", name)));
4149 switch (record->vartype)
4152 return *((struct config_bool *) record)->variable ? "on" : "off";
4155 snprintf(buffer, sizeof(buffer), "%d",
4156 *((struct config_int *) record)->variable);
4160 snprintf(buffer, sizeof(buffer), "%g",
4161 *((struct config_real *) record)->variable);
4165 return *((struct config_string *) record)->variable;
4171 * Get the RESET value associated with the given option.
4174 GetConfigOptionResetString(const char *name)
4176 struct config_generic *record;
4177 static char buffer[256];
4179 record = find_option(name, ERROR);
4182 (errcode(ERRCODE_UNDEFINED_OBJECT),
4183 errmsg("unrecognized configuration parameter \"%s\"", name)));
4184 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4186 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4187 errmsg("must be superuser to examine \"%s\"", name)));
4189 switch (record->vartype)
4192 return ((struct config_bool *) record)->reset_val ? "on" : "off";
4195 snprintf(buffer, sizeof(buffer), "%d",
4196 ((struct config_int *) record)->reset_val);
4200 snprintf(buffer, sizeof(buffer), "%g",
4201 ((struct config_real *) record)->reset_val);
4205 return ((struct config_string *) record)->reset_val;
4211 * Detect whether the given configuration option can only be set by
4215 IsSuperuserConfigOption(const char *name)
4217 struct config_generic *record;
4219 record = find_option(name, ERROR);
4220 /* On an unrecognized name, don't error, just return false. */
4223 return (record->context == PGC_SUSET);
4228 * flatten_set_variable_args
4229 * Given a parsenode List as emitted by the grammar for SET,
4230 * convert to the flat string representation used by GUC.
4232 * We need to be told the name of the variable the args are for, because
4233 * the flattening rules vary (ugh).
4235 * The result is NULL if input is NIL (ie, SET ... TO DEFAULT), otherwise
4236 * a palloc'd string.
4239 flatten_set_variable_args(const char *name, List *args)
4241 struct config_generic *record;
4247 * Fast path if just DEFAULT. We do not check the variable name in this
4248 * case --- necessary for RESET ALL to work correctly.
4253 /* Else get flags for the variable */
4254 record = find_option(name, ERROR);
4257 (errcode(ERRCODE_UNDEFINED_OBJECT),
4258 errmsg("unrecognized configuration parameter \"%s\"", name)));
4260 flags = record->flags;
4262 /* Complain if list input and non-list variable */
4263 if ((flags & GUC_LIST_INPUT) == 0 &&
4264 list_length(args) != 1)
4266 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4267 errmsg("SET %s takes only one argument", name)));
4269 initStringInfo(&buf);
4273 A_Const *arg = (A_Const *) lfirst(l);
4276 if (l != list_head(args))
4277 appendStringInfo(&buf, ", ");
4279 if (!IsA(arg, A_Const))
4280 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
4282 switch (nodeTag(&arg->val))
4285 appendStringInfo(&buf, "%ld", intVal(&arg->val));
4288 /* represented as a string, so just copy it */
4289 appendStringInfoString(&buf, strVal(&arg->val));
4292 val = strVal(&arg->val);
4293 if (arg->typename != NULL)
4296 * Must be a ConstInterval argument for TIME ZONE. Coerce
4297 * to interval and back to normalize the value and account
4304 DirectFunctionCall3(interval_in,
4305 CStringGetDatum(val),
4306 ObjectIdGetDatum(InvalidOid),
4307 Int32GetDatum(arg->typename->typmod));
4310 DatumGetCString(DirectFunctionCall1(interval_out,
4312 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
4317 * Plain string literal or identifier. For quote mode,
4318 * quote it if it's not a vanilla identifier.
4320 if (flags & GUC_LIST_QUOTE)
4321 appendStringInfoString(&buf, quote_identifier(val));
4323 appendStringInfoString(&buf, val);
4327 elog(ERROR, "unrecognized node type: %d",
4328 (int) nodeTag(&arg->val));
4341 SetPGVariable(const char *name, List *args, bool is_local)
4343 char *argstring = flatten_set_variable_args(name, args);
4345 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4346 set_config_option(name,
4348 (superuser() ? PGC_SUSET : PGC_USERSET),
4355 * SET command wrapped as a SQL callable function.
4358 set_config_by_name(PG_FUNCTION_ARGS)
4366 if (PG_ARGISNULL(0))
4368 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
4369 errmsg("SET requires parameter name")));
4371 /* Get the GUC variable name */
4372 name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4374 /* Get the desired value or set to NULL for a reset request */
4375 if (PG_ARGISNULL(1))
4378 value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
4381 * Get the desired state of is_local. Default to false if provided value
4384 if (PG_ARGISNULL(2))
4387 is_local = PG_GETARG_BOOL(2);
4389 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4390 set_config_option(name,
4392 (superuser() ? PGC_SUSET : PGC_USERSET),
4397 /* get the new current value */
4398 new_value = GetConfigOptionByName(name, NULL);
4400 /* Convert return string to text */
4401 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
4404 PG_RETURN_TEXT_P(result_text);
4408 define_custom_variable(struct config_generic * variable)
4410 const char *name = variable->name;
4411 const char **nameAddr = &name;
4413 struct config_string *pHolder;
4414 struct config_generic **res = (struct config_generic **) bsearch(
4416 (void *) guc_variables,
4418 sizeof(struct config_generic *),
4423 add_guc_variable(variable, ERROR);
4428 * This better be a placeholder
4430 if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
4432 (errcode(ERRCODE_INTERNAL_ERROR),
4433 errmsg("attempt to redefine parameter \"%s\"", name)));
4435 Assert((*res)->vartype == PGC_STRING);
4436 pHolder = (struct config_string *) * res;
4438 /* We have the same name, no sorting is necessary */
4441 value = *pHolder->variable;
4444 * Assign the string value stored in the placeholder to the real variable.
4446 * XXX this is not really good enough --- it should be a nontransactional
4447 * assignment, since we don't want it to roll back if the current xact
4450 set_config_option(name, value,
4451 pHolder->gen.context, pHolder->gen.source,
4455 * Free up as much as we conveniently can of the placeholder structure
4456 * (this neglects any stack items...)
4458 set_string_field(pHolder, pHolder->variable, NULL);
4459 set_string_field(pHolder, &pHolder->reset_val, NULL);
4460 set_string_field(pHolder, &pHolder->tentative_val, NULL);
4466 init_custom_variable(struct config_generic * gen,
4468 const char *short_desc,
4469 const char *long_desc,
4471 enum config_type type)
4473 gen->name = guc_strdup(ERROR, name);
4474 gen->context = context;
4475 gen->group = CUSTOM_OPTIONS;
4476 gen->short_desc = short_desc;
4477 gen->long_desc = long_desc;
4478 gen->vartype = type;
4482 DefineCustomBoolVariable(const char *name,
4483 const char *short_desc,
4484 const char *long_desc,
4487 GucBoolAssignHook assign_hook,
4488 GucShowHook show_hook)
4490 size_t sz = sizeof(struct config_bool);
4491 struct config_bool *var = (struct config_bool *) guc_malloc(ERROR, sz);
4494 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_BOOL);
4496 var->variable = valueAddr;
4497 var->reset_val = *valueAddr;
4498 var->assign_hook = assign_hook;
4499 var->show_hook = show_hook;
4500 define_custom_variable(&var->gen);
4504 DefineCustomIntVariable(const char *name,
4505 const char *short_desc,
4506 const char *long_desc,
4511 GucIntAssignHook assign_hook,
4512 GucShowHook show_hook)
4514 size_t sz = sizeof(struct config_int);
4515 struct config_int *var = (struct config_int *) guc_malloc(ERROR, sz);
4518 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_INT);
4520 var->variable = valueAddr;
4521 var->reset_val = *valueAddr;
4522 var->min = minValue;
4523 var->max = maxValue;
4524 var->assign_hook = assign_hook;
4525 var->show_hook = show_hook;
4526 define_custom_variable(&var->gen);
4530 DefineCustomRealVariable(const char *name,
4531 const char *short_desc,
4532 const char *long_desc,
4537 GucRealAssignHook assign_hook,
4538 GucShowHook show_hook)
4540 size_t sz = sizeof(struct config_real);
4541 struct config_real *var = (struct config_real *) guc_malloc(ERROR, sz);
4544 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_REAL);
4546 var->variable = valueAddr;
4547 var->reset_val = *valueAddr;
4548 var->min = minValue;
4549 var->max = maxValue;
4550 var->assign_hook = assign_hook;
4551 var->show_hook = show_hook;
4552 define_custom_variable(&var->gen);
4556 DefineCustomStringVariable(const char *name,
4557 const char *short_desc,
4558 const char *long_desc,
4561 GucStringAssignHook assign_hook,
4562 GucShowHook show_hook)
4564 size_t sz = sizeof(struct config_string);
4565 struct config_string *var = (struct config_string *) guc_malloc(ERROR, sz);
4568 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_STRING);
4570 var->variable = valueAddr;
4571 var->reset_val = *valueAddr;
4572 var->assign_hook = assign_hook;
4573 var->show_hook = show_hook;
4574 define_custom_variable(&var->gen);
4578 EmitWarningsOnPlaceholders(const char *className)
4580 struct config_generic **vars = guc_variables;
4581 struct config_generic **last = vars + num_guc_variables;
4583 int nameLen = strlen(className);
4587 struct config_generic *var = *vars++;
4589 if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
4590 strncmp(className, var->name, nameLen) == 0 &&
4591 var->name[nameLen] == GUC_QUALIFIER_SEPARATOR)
4594 (errcode(ERRCODE_UNDEFINED_OBJECT),
4595 errmsg("unrecognized configuration parameter \"%s\"", var->name)));
4605 GetPGVariable(const char *name, DestReceiver *dest)
4607 if (pg_strcasecmp(name, "all") == 0)
4608 ShowAllGUCConfig(dest);
4610 ShowGUCConfigOption(name, dest);
4614 GetPGVariableResultDesc(const char *name)
4618 if (pg_strcasecmp(name, "all") == 0)
4620 /* need a tuple descriptor representing three TEXT columns */
4621 tupdesc = CreateTemplateTupleDesc(3, false);
4622 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4624 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4626 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4632 const char *varname;
4634 /* Get the canonical spelling of name */
4635 (void) GetConfigOptionByName(name, &varname);
4637 /* need a tuple descriptor representing a single TEXT column */
4638 tupdesc = CreateTemplateTupleDesc(1, false);
4639 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4649 ResetPGVariable(const char *name)
4651 if (pg_strcasecmp(name, "all") == 0)
4654 set_config_option(name,
4656 (superuser() ? PGC_SUSET : PGC_USERSET),
4667 ShowGUCConfigOption(const char *name, DestReceiver *dest)
4669 TupOutputState *tstate;
4671 const char *varname;
4674 /* Get the value and canonical spelling of name */
4675 value = GetConfigOptionByName(name, &varname);
4677 /* need a tuple descriptor representing a single TEXT column */
4678 tupdesc = CreateTemplateTupleDesc(1, false);
4679 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4682 /* prepare for projection of tuples */
4683 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4686 do_text_output_oneline(tstate, value);
4688 end_tup_output(tstate);
4695 ShowAllGUCConfig(DestReceiver *dest)
4697 bool am_superuser = superuser();
4699 TupOutputState *tstate;
4703 /* need a tuple descriptor representing three TEXT columns */
4704 tupdesc = CreateTemplateTupleDesc(3, false);
4705 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4707 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4709 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4713 /* prepare for projection of tuples */
4714 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4716 for (i = 0; i < num_guc_variables; i++)
4718 struct config_generic *conf = guc_variables[i];
4720 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4721 ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
4724 /* assign to the values array */
4725 values[0] = (char *) conf->name;
4726 values[1] = _ShowOption(conf);
4727 values[2] = (char *) conf->short_desc;
4729 /* send it to dest */
4730 do_tup_output(tstate, values);
4733 if (values[1] != NULL)
4737 end_tup_output(tstate);
4741 * Return GUC variable value by name; optionally return canonical
4742 * form of name. Return value is palloc'd.
4745 GetConfigOptionByName(const char *name, const char **varname)
4747 struct config_generic *record;
4749 record = find_option(name, ERROR);
4752 (errcode(ERRCODE_UNDEFINED_OBJECT),
4753 errmsg("unrecognized configuration parameter \"%s\"", name)));
4754 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4756 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4757 errmsg("must be superuser to examine \"%s\"", name)));
4760 *varname = record->name;
4762 return _ShowOption(record);
4766 * Return GUC variable value by variable number; optionally return canonical
4767 * form of name. Return value is palloc'd.
4770 GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
4773 struct config_generic *conf;
4775 /* check requested variable number valid */
4776 Assert((varnum >= 0) && (varnum < num_guc_variables));
4778 conf = guc_variables[varnum];
4782 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4783 ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
4789 /* first get the generic attributes */
4792 values[0] = conf->name;
4794 /* setting : use _ShowOption in order to avoid duplicating the logic */
4795 values[1] = _ShowOption(conf);
4798 values[2] = config_group_names[conf->group];
4801 values[3] = conf->short_desc;
4804 values[4] = conf->long_desc;
4807 values[5] = GucContext_Names[conf->context];
4810 values[6] = config_type_names[conf->vartype];
4813 values[7] = GucSource_Names[conf->source];
4815 /* now get the type specifc attributes */
4816 switch (conf->vartype)
4830 struct config_int *lconf = (struct config_int *) conf;
4833 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
4834 values[8] = pstrdup(buffer);
4837 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
4838 values[9] = pstrdup(buffer);
4844 struct config_real *lconf = (struct config_real *) conf;
4847 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
4848 values[8] = pstrdup(buffer);
4851 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
4852 values[9] = pstrdup(buffer);
4869 * should never get here, but in case we do, set 'em to NULL
4883 * Return the total number of GUC variables
4886 GetNumConfigOptions(void)
4888 return num_guc_variables;
4892 * show_config_by_name - equiv to SHOW X command but implemented as
4896 show_config_by_name(PG_FUNCTION_ARGS)
4902 /* Get the GUC variable name */
4903 varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4906 varval = GetConfigOptionByName(varname, NULL);
4908 /* Convert to text */
4909 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));
4912 PG_RETURN_TEXT_P(result_text);
4916 * show_all_settings - equiv to SHOW ALL command but implemented as
4919 #define NUM_PG_SETTINGS_ATTS 10
4922 show_all_settings(PG_FUNCTION_ARGS)
4924 FuncCallContext *funcctx;
4928 AttInMetadata *attinmeta;
4929 MemoryContext oldcontext;
4931 /* stuff done only on the first call of the function */
4932 if (SRF_IS_FIRSTCALL())
4934 /* create a function context for cross-call persistence */
4935 funcctx = SRF_FIRSTCALL_INIT();
4938 * switch to memory context appropriate for multiple function calls
4940 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
4943 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
4944 * of the appropriate types
4946 tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
4947 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4949 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4951 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "category",
4953 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "short_desc",
4955 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "extra_desc",
4957 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "context",
4959 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "vartype",
4961 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "source",
4963 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "min_val",
4965 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "max_val",
4969 * Generate attribute metadata needed later to produce tuples from raw
4972 attinmeta = TupleDescGetAttInMetadata(tupdesc);
4973 funcctx->attinmeta = attinmeta;
4975 /* total number of tuples to be returned */
4976 funcctx->max_calls = GetNumConfigOptions();
4978 MemoryContextSwitchTo(oldcontext);
4981 /* stuff done on every call of the function */
4982 funcctx = SRF_PERCALL_SETUP();
4984 call_cntr = funcctx->call_cntr;
4985 max_calls = funcctx->max_calls;
4986 attinmeta = funcctx->attinmeta;
4988 if (call_cntr < max_calls) /* do when there is more left to send */
4990 char *values[NUM_PG_SETTINGS_ATTS];
4996 * Get the next visible GUC variable name and value
5000 GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
5003 /* bump the counter and get the next config setting */
5004 call_cntr = ++funcctx->call_cntr;
5006 /* make sure we haven't gone too far now */
5007 if (call_cntr >= max_calls)
5008 SRF_RETURN_DONE(funcctx);
5013 tuple = BuildTupleFromCStrings(attinmeta, values);
5015 /* make the tuple into a datum */
5016 result = HeapTupleGetDatum(tuple);
5018 SRF_RETURN_NEXT(funcctx, result);
5022 /* do when there is no more left */
5023 SRF_RETURN_DONE(funcctx);
5028 _ShowOption(struct config_generic * record)
5033 switch (record->vartype)
5037 struct config_bool *conf = (struct config_bool *) record;
5039 if (conf->show_hook)
5040 val = (*conf->show_hook) ();
5042 val = *conf->variable ? "on" : "off";
5048 struct config_int *conf = (struct config_int *) record;
5050 if (conf->show_hook)
5051 val = (*conf->show_hook) ();
5054 snprintf(buffer, sizeof(buffer), "%d",
5063 struct config_real *conf = (struct config_real *) record;
5065 if (conf->show_hook)
5066 val = (*conf->show_hook) ();
5069 snprintf(buffer, sizeof(buffer), "%g",
5078 struct config_string *conf = (struct config_string *) record;
5080 if (conf->show_hook)
5081 val = (*conf->show_hook) ();
5082 else if (*conf->variable && **conf->variable)
5083 val = *conf->variable;
5090 /* just to keep compiler quiet */
5095 return pstrdup(val);
5100 is_newvalue_equal(struct config_generic *record, const char *newvalue)
5102 switch (record->vartype)
5106 struct config_bool *conf = (struct config_bool *) record;
5109 return parse_bool(newvalue, &newval) && *conf->variable == newval;
5113 struct config_int *conf = (struct config_int *) record;
5116 return parse_int(newvalue, &newval) && *conf->variable == newval;
5120 struct config_real *conf = (struct config_real *) record;
5123 return parse_real(newvalue, &newval) && *conf->variable == newval;
5127 struct config_string *conf = (struct config_string *) record;
5129 return strcmp(*conf->variable, newvalue) == 0;
5140 * This routine dumps out all non-default GUC options into a binary
5141 * file that is read by all exec'ed backends. The format is:
5143 * variable name, string, null terminated
5144 * variable value, string, null terminated
5145 * variable source, integer
5148 write_nondefault_variables(GucContext context)
5154 Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
5156 elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
5161 fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
5165 (errcode_for_file_access(),
5166 errmsg("could not write to file \"%s\": %m",
5167 CONFIG_EXEC_PARAMS_NEW)));
5171 for (i = 0; i < num_guc_variables; i++)
5173 struct config_generic *gconf = guc_variables[i];
5175 if (gconf->source != PGC_S_DEFAULT)
5177 fprintf(fp, "%s", gconf->name);
5180 switch (gconf->vartype)
5184 struct config_bool *conf = (struct config_bool *) gconf;
5186 if (*conf->variable == 0)
5187 fprintf(fp, "false");
5189 fprintf(fp, "true");
5195 struct config_int *conf = (struct config_int *) gconf;
5197 fprintf(fp, "%d", *conf->variable);
5203 struct config_real *conf = (struct config_real *) gconf;
5205 /* Could lose precision here? */
5206 fprintf(fp, "%f", *conf->variable);
5212 struct config_string *conf = (struct config_string *) gconf;
5214 fprintf(fp, "%s", *conf->variable);
5221 fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
5228 (errcode_for_file_access(),
5229 errmsg("could not write to file \"%s\": %m",
5230 CONFIG_EXEC_PARAMS_NEW)));
5235 * Put new file in place. This could delay on Win32, but we don't hold
5236 * any exclusive locks.
5238 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5243 * Read string, including null byte from file
5245 * Return NULL on EOF and nothing read
5248 read_string_with_null(FILE *fp)
5257 if ((ch = fgetc(fp)) == EOF)
5262 elog(FATAL, "invalid format of exec config params file");
5265 str = guc_malloc(FATAL, maxlen);
5266 else if (i == maxlen)
5267 str = guc_realloc(FATAL, str, maxlen *= 2);
5276 * This routine loads a previous postmaster dump of its non-default
5280 read_nondefault_variables(void)
5290 fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
5293 /* File not found is fine */
5294 if (errno != ENOENT)
5296 (errcode_for_file_access(),
5297 errmsg("could not read from file \"%s\": %m",
5298 CONFIG_EXEC_PARAMS)));
5304 struct config_generic *record;
5306 if ((varname = read_string_with_null(fp)) == NULL)
5309 if ((record = find_option(varname, FATAL)) == NULL)
5310 elog(FATAL, "failed to locate variable %s in exec config params file", varname);
5311 if ((varvalue = read_string_with_null(fp)) == NULL)
5312 elog(FATAL, "invalid format of exec config params file");
5313 if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
5314 elog(FATAL, "invalid format of exec config params file");
5316 (void) set_config_option(varname, varvalue, record->context,
5317 varsource, false, true);
5324 #endif /* EXEC_BACKEND */
5328 * A little "long argument" simulation, although not quite GNU
5329 * compliant. Takes a string of the form "some-option=some value" and
5330 * returns name = "some_option" and value = "some value" in malloc'ed
5331 * storage. Note that '-' is converted to '_' in the option name. If
5332 * there is no '=' in the input string then value will be NULL.
5335 ParseLongOption(const char *string, char **name, char **value)
5344 equal_pos = strcspn(string, "=");
5346 if (string[equal_pos] == '=')
5348 *name = guc_malloc(FATAL, equal_pos + 1);
5349 strncpy(*name, string, equal_pos);
5350 (*name)[equal_pos] = '\0';
5352 *value = guc_strdup(FATAL, &string[equal_pos + 1]);
5356 /* no equal sign in string */
5357 *name = guc_strdup(FATAL, string);
5361 for (cp = *name; *cp; cp++)
5368 * Handle options fetched from pg_database.datconfig or pg_authid.rolconfig.
5369 * The array parameter must be an array of TEXT (it must not be NULL).
5372 ProcessGUCArray(ArrayType *array, GucSource source)
5376 Assert(array != NULL);
5377 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5378 Assert(ARR_NDIM(array) == 1);
5379 Assert(ARR_LBOUND(array)[0] == 1);
5380 Assert(source == PGC_S_DATABASE || source == PGC_S_USER);
5382 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5390 d = array_ref(array, 1, &i,
5391 -1 /* varlenarray */ ,
5392 -1 /* TEXT's typlen */ ,
5393 false /* TEXT's typbyval */ ,
5394 'i' /* TEXT's typalign */ ,
5400 s = DatumGetCString(DirectFunctionCall1(textout, d));
5402 ParseLongOption(s, &name, &value);
5406 (errcode(ERRCODE_SYNTAX_ERROR),
5407 errmsg("could not parse setting for parameter \"%s\"", name)));
5413 * We process all these options at SUSET level. We assume that the
5414 * right to insert an option into pg_database or pg_authid was checked
5415 * when it was inserted.
5417 SetConfigOption(name, value, PGC_SUSET, source);
5427 * Add an entry to an option array. The array parameter may be NULL
5428 * to indicate the current table entry is NULL.
5431 GUCArrayAdd(ArrayType *array, const char *name, const char *value)
5433 const char *varname;
5441 /* test if the option is valid */
5442 set_config_option(name, value,
5443 superuser() ? PGC_SUSET : PGC_USERSET,
5444 PGC_S_TEST, false, false);
5446 /* convert name to canonical spelling, so we can use plain strcmp */
5447 (void) GetConfigOptionByName(name, &varname);
5450 newval = palloc(strlen(name) + 1 + strlen(value) + 1);
5451 sprintf(newval, "%s=%s", name, value);
5452 datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
5460 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5461 Assert(ARR_NDIM(array) == 1);
5462 Assert(ARR_LBOUND(array)[0] == 1);
5464 index = ARR_DIMS(array)[0] + 1; /* add after end */
5466 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5471 d = array_ref(array, 1, &i,
5472 -1 /* varlenarray */ ,
5473 -1 /* TEXT's typlen */ ,
5474 false /* TEXT's typbyval */ ,
5475 'i' /* TEXT's typalign */ ,
5479 current = DatumGetCString(DirectFunctionCall1(textout, d));
5480 if (strncmp(current, newval, strlen(name) + 1) == 0)
5487 a = array_set(array, 1, &index,
5490 -1 /* varlena array */ ,
5491 -1 /* TEXT's typlen */ ,
5492 false /* TEXT's typbyval */ ,
5493 'i' /* TEXT's typalign */ );
5496 a = construct_array(&datum, 1,
5505 * Delete an entry from an option array. The array parameter may be NULL
5506 * to indicate the current table entry is NULL. Also, if the return value
5507 * is NULL then a null should be stored.
5510 GUCArrayDelete(ArrayType *array, const char *name)
5512 const char *varname;
5513 ArrayType *newarray;
5519 /* test if the option is valid */
5520 set_config_option(name, NULL,
5521 superuser() ? PGC_SUSET : PGC_USERSET,
5522 PGC_S_TEST, false, false);
5524 /* convert name to canonical spelling, so we can use plain strcmp */
5525 (void) GetConfigOptionByName(name, &varname);
5528 /* if array is currently null, then surely nothing to delete */
5535 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5541 d = array_ref(array, 1, &i,
5542 -1 /* varlenarray */ ,
5543 -1 /* TEXT's typlen */ ,
5544 false /* TEXT's typbyval */ ,
5545 'i' /* TEXT's typalign */ ,
5549 val = DatumGetCString(DirectFunctionCall1(textout, d));
5551 /* ignore entry if it's what we want to delete */
5552 if (strncmp(val, name, strlen(name)) == 0
5553 && val[strlen(name)] == '=')
5556 /* else add it to the output array */
5559 newarray = array_set(newarray, 1, &index,
5562 -1 /* varlenarray */ ,
5563 -1 /* TEXT's typlen */ ,
5564 false /* TEXT's typbyval */ ,
5565 'i' /* TEXT's typalign */ );
5568 newarray = construct_array(&d, 1,
5580 * assign_hook subroutines
5584 assign_log_destination(const char *value, bool doit, GucSource source)
5591 /* Need a modifiable copy of string */
5592 rawstring = pstrdup(value);
5594 /* Parse string into list of identifiers */
5595 if (!SplitIdentifierString(rawstring, ',', &elemlist))
5597 /* syntax error in list */
5599 list_free(elemlist);
5600 if (source >= PGC_S_INTERACTIVE)
5602 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5603 errmsg("invalid list syntax for parameter \"log_destination\"")));
5607 foreach(l, elemlist)
5609 char *tok = (char *) lfirst(l);
5611 if (pg_strcasecmp(tok, "stderr") == 0)
5612 newlogdest |= LOG_DESTINATION_STDERR;
5614 else if (pg_strcasecmp(tok, "syslog") == 0)
5615 newlogdest |= LOG_DESTINATION_SYSLOG;
5618 else if (pg_strcasecmp(tok, "eventlog") == 0)
5619 newlogdest |= LOG_DESTINATION_EVENTLOG;
5623 if (source >= PGC_S_INTERACTIVE)
5625 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5626 errmsg("unrecognized \"log_destination\" key word: \"%s\"",
5629 list_free(elemlist);
5635 Log_destination = newlogdest;
5638 list_free(elemlist);
5646 assign_syslog_facility(const char *facility, bool doit, GucSource source)
5650 if (pg_strcasecmp(facility, "LOCAL0") == 0)
5651 syslog_fac = LOG_LOCAL0;
5652 else if (pg_strcasecmp(facility, "LOCAL1") == 0)
5653 syslog_fac = LOG_LOCAL1;
5654 else if (pg_strcasecmp(facility, "LOCAL2") == 0)
5655 syslog_fac = LOG_LOCAL2;
5656 else if (pg_strcasecmp(facility, "LOCAL3") == 0)
5657 syslog_fac = LOG_LOCAL3;
5658 else if (pg_strcasecmp(facility, "LOCAL4") == 0)
5659 syslog_fac = LOG_LOCAL4;
5660 else if (pg_strcasecmp(facility, "LOCAL5") == 0)
5661 syslog_fac = LOG_LOCAL5;
5662 else if (pg_strcasecmp(facility, "LOCAL6") == 0)
5663 syslog_fac = LOG_LOCAL6;
5664 else if (pg_strcasecmp(facility, "LOCAL7") == 0)
5665 syslog_fac = LOG_LOCAL7;
5667 return NULL; /* reject */
5671 syslog_facility = syslog_fac;
5672 set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
5680 assign_syslog_ident(const char *ident, bool doit, GucSource source)
5683 set_syslog_parameters(ident, syslog_facility);
5687 #endif /* HAVE_SYSLOG */
5691 assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
5693 if (pg_strcasecmp(newval, "serializable") == 0)
5696 DefaultXactIsoLevel = XACT_SERIALIZABLE;
5698 else if (pg_strcasecmp(newval, "repeatable read") == 0)
5701 DefaultXactIsoLevel = XACT_REPEATABLE_READ;
5703 else if (pg_strcasecmp(newval, "read committed") == 0)
5706 DefaultXactIsoLevel = XACT_READ_COMMITTED;
5708 else if (pg_strcasecmp(newval, "read uncommitted") == 0)
5711 DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
5719 assign_log_min_messages(const char *newval,
5720 bool doit, GucSource source)
5722 return (assign_msglvl(&log_min_messages, newval, doit, source));
5726 assign_client_min_messages(const char *newval, bool doit, GucSource source)
5728 return (assign_msglvl(&client_min_messages, newval, doit, source));
5732 assign_min_error_statement(const char *newval, bool doit, GucSource source)
5734 return (assign_msglvl(&log_min_error_statement, newval, doit, source));
5738 assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
5740 if (pg_strcasecmp(newval, "debug") == 0)
5745 else if (pg_strcasecmp(newval, "debug5") == 0)
5750 else if (pg_strcasecmp(newval, "debug4") == 0)
5755 else if (pg_strcasecmp(newval, "debug3") == 0)
5760 else if (pg_strcasecmp(newval, "debug2") == 0)
5765 else if (pg_strcasecmp(newval, "debug1") == 0)
5770 else if (pg_strcasecmp(newval, "log") == 0)
5777 * Client_min_messages always prints 'info', but we allow it as a value
5780 else if (pg_strcasecmp(newval, "info") == 0)
5785 else if (pg_strcasecmp(newval, "notice") == 0)
5790 else if (pg_strcasecmp(newval, "warning") == 0)
5795 else if (pg_strcasecmp(newval, "error") == 0)
5800 /* We allow FATAL/PANIC for client-side messages too. */
5801 else if (pg_strcasecmp(newval, "fatal") == 0)
5806 else if (pg_strcasecmp(newval, "panic") == 0)
5812 return NULL; /* fail */
5813 return newval; /* OK */
5817 assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
5819 if (pg_strcasecmp(newval, "terse") == 0)
5822 Log_error_verbosity = PGERROR_TERSE;
5824 else if (pg_strcasecmp(newval, "default") == 0)
5827 Log_error_verbosity = PGERROR_DEFAULT;
5829 else if (pg_strcasecmp(newval, "verbose") == 0)
5832 Log_error_verbosity = PGERROR_VERBOSE;
5835 return NULL; /* fail */
5836 return newval; /* OK */
5840 assign_log_statement(const char *newval, bool doit, GucSource source)
5842 if (pg_strcasecmp(newval, "none") == 0)
5845 log_statement = LOGSTMT_NONE;
5847 else if (pg_strcasecmp(newval, "ddl") == 0)
5850 log_statement = LOGSTMT_DDL;
5852 else if (pg_strcasecmp(newval, "mod") == 0)
5855 log_statement = LOGSTMT_MOD;
5857 else if (pg_strcasecmp(newval, "all") == 0)
5860 log_statement = LOGSTMT_ALL;
5863 return NULL; /* fail */
5864 return newval; /* OK */
5868 show_num_temp_buffers(void)
5871 * We show the GUC var until local buffers have been initialized, and
5872 * NLocBuffer afterwards.
5874 static char nbuf[32];
5876 sprintf(nbuf, "%d", NLocBuffer ? NLocBuffer : num_temp_buffers);
5881 assign_phony_autocommit(bool newval, bool doit, GucSource source)
5885 if (doit && source >= PGC_S_INTERACTIVE)
5887 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5888 errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
5895 assign_custom_variable_classes(const char *newval, bool doit, GucSource source)
5898 * Check syntax. newval must be a comma separated list of identifiers.
5899 * Whitespace is allowed but skipped.
5901 bool hasSpaceAfterToken = false;
5902 const char *cp = newval;
5907 initStringInfo(&buf);
5908 while ((c = *cp++) != 0)
5913 hasSpaceAfterToken = true;
5919 hasSpaceAfterToken = false;
5923 appendStringInfoChar(&buf, ',');
5928 if (hasSpaceAfterToken || !isalnum(c))
5931 * Syntax error due to token following space after token or non
5932 * alpha numeric character
5935 (errcode(ERRCODE_SYNTAX_ERROR),
5936 errmsg("invalid syntax for \"custom_variable_classes\": \"%s\"", newval)));
5941 appendStringInfoChar(&buf, (char) c);
5944 /* Remove stray ',' at end */
5945 if (symLen == 0 && buf.len > 0)
5946 buf.data[--buf.len] = '\0';
5951 newval = strdup(buf.data);
5958 assign_debug_assertions(bool newval, bool doit, GucSource source)
5960 #ifndef USE_ASSERT_CHECKING
5963 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5964 errmsg("assertion checking is not supported by this build")));
5970 assign_ssl(bool newval, bool doit, GucSource source)
5975 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5976 errmsg("SSL is not supported by this build")));
5982 assign_stage_log_stats(bool newval, bool doit, GucSource source)
5984 if (newval && log_statement_stats)
5986 if (source >= PGC_S_INTERACTIVE)
5988 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5989 errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
5990 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
5991 else if (source != PGC_S_OVERRIDE)
5998 assign_log_stats(bool newval, bool doit, GucSource source)
6001 (log_parser_stats || log_planner_stats || log_executor_stats))
6003 if (source >= PGC_S_INTERACTIVE)
6005 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6006 errmsg("cannot enable \"log_statement_stats\" when "
6007 "\"log_parser_stats\", \"log_planner_stats\", "
6008 "or \"log_executor_stats\" is true")));
6009 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6010 else if (source != PGC_S_OVERRIDE)
6017 assign_transaction_read_only(bool newval, bool doit, GucSource source)
6019 /* Can't go to r/w mode inside a r/o transaction */
6020 if (newval == false && XactReadOnly && IsSubTransaction())
6022 if (source >= PGC_S_INTERACTIVE)
6024 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6025 errmsg("cannot set transaction read-write mode inside a read-only transaction")));
6026 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6027 else if (source != PGC_S_OVERRIDE)
6034 assign_canonical_path(const char *newval, bool doit, GucSource source)
6038 char *canon_val = guc_strdup(ERROR, newval);
6040 canonicalize_path(canon_val);
6048 assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
6051 return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
6057 show_tcp_keepalives_idle(void)
6059 static char nbuf[16];
6061 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
6066 assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
6069 return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
6075 show_tcp_keepalives_interval(void)
6077 static char nbuf[16];
6079 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
6084 assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
6087 return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
6093 show_tcp_keepalives_count(void)
6095 static char nbuf[16];
6097 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
6102 #include "guc-file.c"