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-2007, PostgreSQL Global Development Group
10 * Written by Peter Eisentraut <peter_e@gmx.net>.
13 * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.416 2007/09/03 18:46:30 tgl Exp $
15 *--------------------------------------------------------------------
28 #include "access/gin.h"
29 #include "access/transam.h"
30 #include "access/twophase.h"
31 #include "access/xact.h"
32 #include "catalog/namespace.h"
33 #include "commands/async.h"
34 #include "commands/prepare.h"
35 #include "commands/vacuum.h"
36 #include "commands/variable.h"
37 #include "commands/trigger.h"
39 #include "libpq/auth.h"
40 #include "libpq/pqformat.h"
41 #include "miscadmin.h"
42 #include "optimizer/cost.h"
43 #include "optimizer/geqo.h"
44 #include "optimizer/paths.h"
45 #include "optimizer/planmain.h"
46 #include "parser/gramparse.h"
47 #include "parser/parse_expr.h"
48 #include "parser/parse_relation.h"
49 #include "parser/parse_type.h"
50 #include "parser/scansup.h"
52 #include "postmaster/autovacuum.h"
53 #include "postmaster/bgwriter.h"
54 #include "postmaster/postmaster.h"
55 #include "postmaster/syslogger.h"
56 #include "postmaster/walwriter.h"
57 #include "storage/fd.h"
58 #include "storage/freespace.h"
59 #include "tcop/tcopprot.h"
60 #include "tsearch/ts_cache.h"
61 #include "utils/builtins.h"
62 #include "utils/guc_tables.h"
63 #include "utils/memutils.h"
64 #include "utils/pg_locale.h"
65 #include "utils/plancache.h"
66 #include "utils/portal.h"
67 #include "utils/ps_status.h"
68 #include "utils/tzparser.h"
69 #include "utils/xml.h"
72 #define PG_KRB_SRVTAB ""
75 #define PG_KRB_SRVNAM ""
78 #define CONFIG_FILENAME "postgresql.conf"
79 #define HBA_FILENAME "pg_hba.conf"
80 #define IDENT_FILENAME "pg_ident.conf"
83 #define CONFIG_EXEC_PARAMS "global/config_exec_params"
84 #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
87 /* upper limit for GUC variables measured in kilobytes of memory */
89 #define MAX_KILOBYTES INT_MAX
91 #define MAX_KILOBYTES (INT_MAX / 1024)
94 #define KB_PER_MB (1024)
95 #define KB_PER_GB (1024*1024)
99 #define MS_PER_MIN (1000 * 60)
101 #define S_PER_H (60 * 60)
102 #define MS_PER_H (1000 * 60 * 60)
103 #define MIN_PER_D (60 * 24)
104 #define S_PER_D (60 * 60 * 24)
105 #define MS_PER_D (1000 * 60 * 60 * 24)
107 /* XXX these should appear in other modules' header files */
108 extern bool Log_disconnections;
109 extern int CommitDelay;
110 extern int CommitSiblings;
111 extern char *default_tablespace;
112 extern char *temp_tablespaces;
113 extern bool fullPageWrites;
116 extern bool trace_sort;
118 #ifdef TRACE_SYNCSCAN
119 extern bool trace_syncscan;
121 #ifdef DEBUG_BOUNDED_SORT
122 extern bool optimize_bounded_sort;
126 extern char *SSLCipherSuites;
130 static const char *assign_log_destination(const char *value,
131 bool doit, GucSource source);
134 static int syslog_facility = LOG_LOCAL0;
136 static const char *assign_syslog_facility(const char *facility,
137 bool doit, GucSource source);
138 static const char *assign_syslog_ident(const char *ident,
139 bool doit, GucSource source);
142 static const char *assign_defaultxactisolevel(const char *newval, bool doit,
144 static const char *assign_session_replication_role(const char *newval, bool doit,
146 static const char *assign_log_min_messages(const char *newval, bool doit,
148 static const char *assign_client_min_messages(const char *newval,
149 bool doit, GucSource source);
150 static const char *assign_min_error_statement(const char *newval, bool doit,
152 static const char *assign_msglvl(int *var, const char *newval, bool doit,
154 static const char *assign_log_error_verbosity(const char *newval, bool doit,
156 static const char *assign_log_statement(const char *newval, bool doit,
158 static const char *show_num_temp_buffers(void);
159 static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
160 static const char *assign_custom_variable_classes(const char *newval, bool doit,
162 static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
163 static bool assign_ssl(bool newval, bool doit, GucSource source);
164 static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
165 static bool assign_log_stats(bool newval, bool doit, GucSource source);
166 static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
167 static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
168 static const char *assign_backslash_quote(const char *newval, bool doit, GucSource source);
169 static const char *assign_timezone_abbreviations(const char *newval, bool doit, GucSource source);
170 static const char *assign_xmlbinary(const char *newval, bool doit, GucSource source);
171 static const char *assign_xmloption(const char *newval, bool doit, GucSource source);
173 static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
174 static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);
175 static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source);
176 static const char *show_tcp_keepalives_idle(void);
177 static const char *show_tcp_keepalives_interval(void);
178 static const char *show_tcp_keepalives_count(void);
179 static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);
180 static bool assign_maxconnections(int newval, bool doit, GucSource source);
183 * GUC option variables that are exported from this module
185 #ifdef USE_ASSERT_CHECKING
186 bool assert_enabled = true;
188 bool assert_enabled = false;
190 bool log_duration = false;
191 bool Debug_print_plan = false;
192 bool Debug_print_parse = false;
193 bool Debug_print_rewritten = false;
194 bool Debug_pretty_print = false;
195 bool Explain_pretty_print = true;
197 bool log_parser_stats = false;
198 bool log_planner_stats = false;
199 bool log_executor_stats = false;
200 bool log_statement_stats = false; /* this is sort of all three
202 bool log_btree_build_stats = false;
204 bool check_function_bodies = true;
205 bool default_with_oids = false;
206 bool SQL_inheritance = true;
208 bool Password_encryption = true;
210 int log_min_error_statement = ERROR;
211 int log_min_messages = NOTICE;
212 int client_min_messages = NOTICE;
213 int log_min_duration_statement = -1;
214 int log_temp_files = -1;
216 int num_temp_buffers = 1000;
218 char *ConfigFileName;
221 char *external_pid_file;
223 int tcp_keepalives_idle;
224 int tcp_keepalives_interval;
225 int tcp_keepalives_count;
228 * These variables are all dummies that don't do anything, except in some
229 * cases provide the value for SHOW to display. The real state is elsewhere
230 * and is kept in sync by assign_hooks.
232 static char *client_min_messages_str;
233 static char *log_min_messages_str;
234 static char *log_error_verbosity_str;
235 static char *log_statement_str;
236 static char *log_min_error_statement_str;
237 static char *log_destination_string;
240 static char *syslog_facility_str;
241 static char *syslog_ident_str;
243 static bool phony_autocommit;
244 static bool session_auth_is_superuser;
245 static double phony_random_seed;
246 static char *backslash_quote_string;
247 static char *client_encoding_string;
248 static char *datestyle_string;
249 static char *default_iso_level_string;
250 static char *session_replication_role_string;
251 static char *locale_collate;
252 static char *locale_ctype;
253 static char *regex_flavor_string;
254 static char *server_encoding_string;
255 static char *server_version_string;
256 static int server_version_num;
257 static char *timezone_string;
258 static char *log_timezone_string;
259 static char *timezone_abbreviations_string;
260 static char *XactIsoLevel_string;
261 static char *data_directory;
262 static char *custom_variable_classes;
263 static char *xmlbinary_string;
264 static char *xmloption_string;
265 static int max_function_args;
266 static int max_index_keys;
267 static int max_identifier_length;
268 static int block_size;
269 static bool integer_datetimes;
271 /* should be static, but commands/variable.c needs to get at these */
273 char *session_authorization_string;
277 * Displayable names for context types (enum GucContext)
279 * Note: these strings are deliberately not localized.
281 const char *const GucContext_Names[] =
283 /* PGC_INTERNAL */ "internal",
284 /* PGC_POSTMASTER */ "postmaster",
285 /* PGC_SIGHUP */ "sighup",
286 /* PGC_BACKEND */ "backend",
287 /* PGC_SUSET */ "superuser",
288 /* PGC_USERSET */ "user"
292 * Displayable names for source types (enum GucSource)
294 * Note: these strings are deliberately not localized.
296 const char *const GucSource_Names[] =
298 /* PGC_S_DEFAULT */ "default",
299 /* PGC_S_ENV_VAR */ "environment variable",
300 /* PGC_S_FILE */ "configuration file",
301 /* PGC_S_ARGV */ "command line",
302 /* PGC_S_DATABASE */ "database",
303 /* PGC_S_USER */ "user",
304 /* PGC_S_CLIENT */ "client",
305 /* PGC_S_OVERRIDE */ "override",
306 /* PGC_S_INTERACTIVE */ "interactive",
307 /* PGC_S_TEST */ "test",
308 /* PGC_S_SESSION */ "session"
312 * Displayable names for the groupings defined in enum config_group
314 const char *const config_group_names[] =
317 gettext_noop("Ungrouped"),
319 gettext_noop("File Locations"),
321 gettext_noop("Connections and Authentication"),
322 /* CONN_AUTH_SETTINGS */
323 gettext_noop("Connections and Authentication / Connection Settings"),
324 /* CONN_AUTH_SECURITY */
325 gettext_noop("Connections and Authentication / Security and Authentication"),
327 gettext_noop("Resource Usage"),
329 gettext_noop("Resource Usage / Memory"),
331 gettext_noop("Resource Usage / Free Space Map"),
332 /* RESOURCES_KERNEL */
333 gettext_noop("Resource Usage / Kernel Resources"),
335 gettext_noop("Write-Ahead Log"),
337 gettext_noop("Write-Ahead Log / Settings"),
338 /* WAL_CHECKPOINTS */
339 gettext_noop("Write-Ahead Log / Checkpoints"),
341 gettext_noop("Query Tuning"),
342 /* QUERY_TUNING_METHOD */
343 gettext_noop("Query Tuning / Planner Method Configuration"),
344 /* QUERY_TUNING_COST */
345 gettext_noop("Query Tuning / Planner Cost Constants"),
346 /* QUERY_TUNING_GEQO */
347 gettext_noop("Query Tuning / Genetic Query Optimizer"),
348 /* QUERY_TUNING_OTHER */
349 gettext_noop("Query Tuning / Other Planner Options"),
351 gettext_noop("Reporting and Logging"),
353 gettext_noop("Reporting and Logging / Where to Log"),
355 gettext_noop("Reporting and Logging / When to Log"),
357 gettext_noop("Reporting and Logging / What to Log"),
359 gettext_noop("Statistics"),
360 /* STATS_MONITORING */
361 gettext_noop("Statistics / Monitoring"),
362 /* STATS_COLLECTOR */
363 gettext_noop("Statistics / Query and Index Statistics Collector"),
365 gettext_noop("Autovacuum"),
367 gettext_noop("Client Connection Defaults"),
368 /* CLIENT_CONN_STATEMENT */
369 gettext_noop("Client Connection Defaults / Statement Behavior"),
370 /* CLIENT_CONN_LOCALE */
371 gettext_noop("Client Connection Defaults / Locale and Formatting"),
372 /* CLIENT_CONN_OTHER */
373 gettext_noop("Client Connection Defaults / Other Defaults"),
374 /* LOCK_MANAGEMENT */
375 gettext_noop("Lock Management"),
377 gettext_noop("Version and Platform Compatibility"),
378 /* COMPAT_OPTIONS_PREVIOUS */
379 gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
380 /* COMPAT_OPTIONS_CLIENT */
381 gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
383 gettext_noop("Preset Options"),
385 gettext_noop("Customized Options"),
386 /* DEVELOPER_OPTIONS */
387 gettext_noop("Developer Options"),
388 /* help_config wants this array to be null-terminated */
393 * Displayable names for GUC variable types (enum config_type)
395 * Note: these strings are deliberately not localized.
397 const char *const config_type_names[] =
399 /* PGC_BOOL */ "bool",
400 /* PGC_INT */ "integer",
401 /* PGC_REAL */ "real",
402 /* PGC_STRING */ "string"
407 * Contents of GUC tables
409 * See src/backend/utils/misc/README for design notes.
413 * 1. Declare a global variable of type bool, int, double, or char*
414 * and make use of it.
416 * 2. Decide at what times it's safe to set the option. See guc.h for
419 * 3. Decide on a name, a default value, upper and lower bounds (if
422 * 4. Add a record below.
424 * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
427 * 6. Don't forget to document the option.
429 * 7. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
430 * it is not single quoted at dump time.
434 /******** option records follow ********/
436 static struct config_bool ConfigureNamesBool[] =
439 {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
440 gettext_noop("Enables the planner's use of sequential-scan plans."),
447 {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
448 gettext_noop("Enables the planner's use of index-scan plans."),
455 {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
456 gettext_noop("Enables the planner's use of bitmap-scan plans."),
463 {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
464 gettext_noop("Enables the planner's use of TID scan plans."),
471 {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
472 gettext_noop("Enables the planner's use of explicit sort steps."),
479 {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
480 gettext_noop("Enables the planner's use of hashed aggregation plans."),
487 {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
488 gettext_noop("Enables the planner's use of nested-loop join plans."),
495 {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
496 gettext_noop("Enables the planner's use of merge join plans."),
503 {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
504 gettext_noop("Enables the planner's use of hash join plans."),
511 {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
512 gettext_noop("Enables the planner to use constraints to optimize queries."),
513 gettext_noop("Child table scans will be skipped if their "
514 "constraints guarantee that no rows match the query.")
516 &constraint_exclusion,
520 {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
521 gettext_noop("Enables genetic query optimization."),
522 gettext_noop("This algorithm attempts to do planning without "
523 "exhaustive searching.")
529 /* Not for general use --- used by SET SESSION AUTHORIZATION */
530 {"is_superuser", PGC_INTERNAL, UNGROUPED,
531 gettext_noop("Shows whether the current user is a superuser."),
533 GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
535 &session_auth_is_superuser,
539 {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
540 gettext_noop("Enables SSL connections."),
544 false, assign_ssl, NULL
547 {"fsync", PGC_SIGHUP, WAL_SETTINGS,
548 gettext_noop("Forces synchronization of updates to disk."),
549 gettext_noop("The server will use the fsync() system call in several places to make "
550 "sure that updates are physically written to disk. This insures "
551 "that a database cluster will recover to a consistent state after "
552 "an operating system or hardware crash.")
558 {"synchronous_commit", PGC_USERSET, WAL_SETTINGS,
559 gettext_noop("Sets immediate fsync at commit."),
563 /* XXX TEMPORARY FOR TESTING: sync commit should default to TRUE! */
567 {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
568 gettext_noop("Continues processing past damaged page headers."),
569 gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
570 "report an error, aborting the current transaction. Setting "
571 "zero_damaged_pages to true causes the system to instead report a "
572 "warning, zero out the damaged page, and continue processing. This "
573 "behavior will destroy data, namely all the rows on the damaged page."),
580 {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
581 gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
582 gettext_noop("A page write in process during an operating system crash might be "
583 "only partially written to disk. During recovery, the row changes "
584 "stored in WAL are not enough to recover. This option writes "
585 "pages when first modified after a checkpoint to WAL so full recovery "
592 {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
593 gettext_noop("Runs the server silently."),
594 gettext_noop("If this parameter is set, the server will automatically run in the "
595 "background and any controlling terminals are dissociated.")
601 {"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
602 gettext_noop("Logs each checkpoint."),
609 {"log_connections", PGC_BACKEND, LOGGING_WHAT,
610 gettext_noop("Logs each successful connection."),
617 {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
618 gettext_noop("Logs end of a session, including duration."),
625 {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
626 gettext_noop("Turns on various assertion checks."),
627 gettext_noop("This is a debugging aid."),
631 #ifdef USE_ASSERT_CHECKING
636 assign_debug_assertions, NULL
639 /* currently undocumented, so don't show in SHOW ALL */
640 {"exit_on_error", PGC_USERSET, UNGROUPED,
641 gettext_noop("No description available."),
643 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
649 {"log_duration", PGC_SUSET, LOGGING_WHAT,
650 gettext_noop("Logs the duration of each completed SQL statement."),
657 {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
658 gettext_noop("Prints the parse tree to the server log."),
665 {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
666 gettext_noop("Prints the parse tree after rewriting to server log."),
669 &Debug_print_rewritten,
673 {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
674 gettext_noop("Prints the execution plan to server log."),
681 {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
682 gettext_noop("Indents parse and plan tree displays."),
689 {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
690 gettext_noop("Writes parser performance statistics to the server log."),
694 false, assign_stage_log_stats, NULL
697 {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
698 gettext_noop("Writes planner performance statistics to the server log."),
702 false, assign_stage_log_stats, NULL
705 {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
706 gettext_noop("Writes executor performance statistics to the server log."),
710 false, assign_stage_log_stats, NULL
713 {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
714 gettext_noop("Writes cumulative performance statistics to the server log."),
717 &log_statement_stats,
718 false, assign_log_stats, NULL
720 #ifdef BTREE_BUILD_STATS
722 {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
723 gettext_noop("No description available."),
727 &log_btree_build_stats,
733 {"explain_pretty_print", PGC_USERSET, CLIENT_CONN_OTHER,
734 gettext_noop("Uses the indented output format for EXPLAIN VERBOSE."),
737 &Explain_pretty_print,
741 {"stats_start_collector", PGC_POSTMASTER, STATS_COLLECTOR,
742 gettext_noop("Starts the server statistics-collection subprocess."),
745 &pgstat_collect_startcollector,
749 {"stats_reset_on_server_start", PGC_POSTMASTER, STATS_COLLECTOR,
750 gettext_noop("Zeroes collected statistics on server restart."),
753 &pgstat_collect_resetonpmstart,
757 {"stats_row_level", PGC_SUSET, STATS_COLLECTOR,
758 gettext_noop("Collects row-level statistics on database activity."),
761 &pgstat_collect_tuplelevel,
765 {"stats_block_level", PGC_SUSET, STATS_COLLECTOR,
766 gettext_noop("Collects block-level statistics on database activity."),
769 &pgstat_collect_blocklevel,
774 {"stats_command_string", PGC_SUSET, STATS_COLLECTOR,
775 gettext_noop("Collects information about executing commands."),
776 gettext_noop("Enables the collection of information on the currently "
777 "executing command of each session, along with the time "
778 "at which that command began execution.")
780 &pgstat_collect_querystring,
785 {"update_process_title", PGC_SUSET, STATS_COLLECTOR,
786 gettext_noop("Updates the process title to show the active SQL command."),
787 gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.")
789 &update_process_title,
794 {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
795 gettext_noop("Starts the autovacuum subprocess."),
798 &autovacuum_start_daemon,
803 {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
804 gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
814 {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
815 gettext_noop("No description available."),
823 {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
824 gettext_noop("No description available."),
832 {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
833 gettext_noop("No description available."),
841 {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
842 gettext_noop("No description available."),
852 {"log_lock_waits", PGC_SUSET, LOGGING_WHAT,
853 gettext_noop("Logs long lock waits."),
861 {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
862 gettext_noop("Logs the host name in the connection logs."),
863 gettext_noop("By default, connection logs only show the IP address "
864 "of the connecting host. If you want them to show the host name you "
865 "can turn this on, but depending on your host name resolution "
866 "setup it might impose a non-negligible performance penalty.")
872 {"sql_inheritance", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
873 gettext_noop("Causes subtables to be included by default in various commands."),
880 {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
881 gettext_noop("Encrypt passwords."),
882 gettext_noop("When a password is specified in CREATE USER or "
883 "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
884 "this parameter determines whether the password is to be encrypted.")
886 &Password_encryption,
890 {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
891 gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
892 gettext_noop("When turned on, expressions of the form expr = NULL "
893 "(or NULL = expr) are treated as expr IS NULL, that is, they "
894 "return true if expr evaluates to the null value, and false "
895 "otherwise. The correct behavior of expr = NULL is to always "
896 "return null (unknown).")
898 &Transform_null_equals,
902 {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
903 gettext_noop("Enables per-database user names."),
910 /* only here for backwards compatibility */
911 {"autocommit", PGC_USERSET, CLIENT_CONN_STATEMENT,
912 gettext_noop("This parameter doesn't do anything."),
913 gettext_noop("It's just here so that we won't choke on SET AUTOCOMMIT TO ON from 7.3-vintage clients."),
914 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
917 true, assign_phony_autocommit, NULL
920 {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
921 gettext_noop("Sets the default read-only status of new transactions."),
924 &DefaultXactReadOnly,
928 {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
929 gettext_noop("Sets the current transaction's read-only status."),
931 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
934 false, assign_transaction_read_only, NULL
937 {"add_missing_from", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
938 gettext_noop("Automatically adds missing table references to FROM clauses."),
945 {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
946 gettext_noop("Check function bodies during CREATE FUNCTION."),
949 &check_function_bodies,
953 {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
954 gettext_noop("Enable input of NULL elements in arrays."),
955 gettext_noop("When turned on, unquoted NULL in an array input "
956 "value means a null value; "
957 "otherwise it is taken literally.")
963 {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
964 gettext_noop("Create new tables with OIDs by default."),
971 {"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
972 gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
979 {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
980 gettext_noop("Truncate existing log files of same name during log rotation."),
983 &Log_truncate_on_rotation,
989 {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
990 gettext_noop("Emit information about resource usage in sorting."),
999 #ifdef TRACE_SYNCSCAN
1000 /* this is undocumented because not exposed in a standard build */
1002 {"trace_syncscan", PGC_USERSET, DEVELOPER_OPTIONS,
1003 gettext_noop("Generate debugging output for synchronized scanning."),
1012 #ifdef DEBUG_BOUNDED_SORT
1013 /* this is undocumented because not exposed in a standard build */
1016 "optimize_bounded_sort", PGC_USERSET, QUERY_TUNING_METHOD,
1017 gettext_noop("Enable bounded sorting using heap sort."),
1021 &optimize_bounded_sort,
1028 {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
1029 gettext_noop("Emit WAL-related debugging output."),
1039 {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
1040 gettext_noop("Datetimes are integer based."),
1042 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1045 #ifdef HAVE_INT64_TIMESTAMP
1053 {"krb_caseins_users", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1054 gettext_noop("Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive."),
1057 &pg_krb_caseins_users,
1062 {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1063 gettext_noop("Warn about backslash escapes in ordinary string literals."),
1066 &escape_string_warning,
1071 {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1072 gettext_noop("Causes '...' strings to treat backslashes literally."),
1076 &standard_conforming_strings,
1081 {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
1082 gettext_noop("Allows modifications of the structure of system tables."),
1086 &allowSystemTableMods,
1091 {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
1092 gettext_noop("Disables reading from system indexes."),
1093 gettext_noop("It does not prevent updating the indexes, so it is safe "
1094 "to use. The worst consequence is slowness."),
1097 &IgnoreSystemIndexes,
1101 /* End-of-list marker */
1103 {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
1108 static struct config_int ConfigureNamesInt[] =
1111 {"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
1112 gettext_noop("Forces a switch to the next xlog file if a "
1113 "new file has not been started within N seconds."),
1117 &XLogArchiveTimeout,
1118 0, 0, INT_MAX, NULL, NULL
1121 {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1122 gettext_noop("Waits N seconds on connection startup after authentication."),
1123 gettext_noop("This allows attaching a debugger to the process."),
1124 GUC_NOT_IN_SAMPLE | GUC_UNIT_S
1127 0, 0, INT_MAX, NULL, NULL
1130 {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1131 gettext_noop("Sets the default statistics target."),
1132 gettext_noop("This applies to table columns that have not had a "
1133 "column-specific target set via ALTER TABLE SET STATISTICS.")
1135 &default_statistics_target,
1136 10, 1, 1000, NULL, NULL
1139 {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1140 gettext_noop("Sets the FROM-list size beyond which subqueries "
1141 "are not collapsed."),
1142 gettext_noop("The planner will merge subqueries into upper "
1143 "queries if the resulting FROM list would have no more than "
1146 &from_collapse_limit,
1147 8, 1, INT_MAX, NULL, NULL
1150 {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1151 gettext_noop("Sets the FROM-list size beyond which JOIN "
1152 "constructs are not flattened."),
1153 gettext_noop("The planner will flatten explicit JOIN "
1154 "constructs into lists of FROM items whenever a "
1155 "list of no more than this many items would result.")
1157 &join_collapse_limit,
1158 8, 1, INT_MAX, NULL, NULL
1161 {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1162 gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1166 12, 2, INT_MAX, NULL, NULL
1169 {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1170 gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1174 DEFAULT_GEQO_EFFORT, MIN_GEQO_EFFORT, MAX_GEQO_EFFORT, NULL, NULL
1177 {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1178 gettext_noop("GEQO: number of individuals in the population."),
1179 gettext_noop("Zero selects a suitable default value.")
1182 0, 0, INT_MAX, NULL, NULL
1185 {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1186 gettext_noop("GEQO: number of iterations of the algorithm."),
1187 gettext_noop("Zero selects a suitable default value.")
1190 0, 0, INT_MAX, NULL, NULL
1194 {"deadlock_timeout", PGC_SIGHUP, LOCK_MANAGEMENT,
1195 gettext_noop("Sets the time to wait on a lock before checking for deadlock."),
1200 1000, 1, INT_MAX/1000, NULL, NULL
1204 * Note: There is some postprocessing done in PostmasterMain() to make
1205 * sure the buffers are at least twice the number of backends, so the
1206 * constraints here are partially unused. Similarly, the superuser
1207 * reserved number is checked to ensure it is less than the max backends
1210 * MaxBackends is limited to INT_MAX/4 because some places compute
1211 * 4*MaxBackends without any overflow check. This check is made on
1212 * assign_maxconnections, since MaxBackends is computed as MaxConnections +
1213 * autovacuum_max_workers.
1215 * Likewise we have to limit NBuffers to INT_MAX/2.
1218 {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1219 gettext_noop("Sets the maximum number of concurrent connections."),
1223 100, 1, INT_MAX / 4, assign_maxconnections, NULL
1227 {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1228 gettext_noop("Sets the number of connection slots reserved for superusers."),
1232 3, 0, INT_MAX / 4, NULL, NULL
1236 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1237 gettext_noop("Sets the number of shared memory buffers used by the server."),
1242 1024, 16, INT_MAX / 2, NULL, NULL
1246 {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1247 gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1252 1024, 100, INT_MAX / 2, NULL, show_num_temp_buffers
1256 {"port", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1257 gettext_noop("Sets the TCP port the server listens on."),
1261 DEF_PGPORT, 1, 65535, NULL, NULL
1265 {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1266 gettext_noop("Sets the access permissions of the Unix-domain socket."),
1267 gettext_noop("Unix-domain sockets use the usual Unix file system "
1268 "permission set. The parameter value is expected to be an numeric mode "
1269 "specification in the form accepted by the chmod and umask system "
1270 "calls. (To use the customary octal format the number must start with "
1273 &Unix_socket_permissions,
1274 0777, 0000, 0777, NULL, NULL
1278 {"work_mem", PGC_USERSET, RESOURCES_MEM,
1279 gettext_noop("Sets the maximum memory to be used for query workspaces."),
1280 gettext_noop("This much memory can be used by each internal "
1281 "sort operation and hash table before switching to "
1282 "temporary disk files."),
1286 1024, 8 * BLCKSZ / 1024, MAX_KILOBYTES, NULL, NULL
1290 {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1291 gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1292 gettext_noop("This includes operations such as VACUUM and CREATE INDEX."),
1295 &maintenance_work_mem,
1296 16384, 1024, MAX_KILOBYTES, NULL, NULL
1300 {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1301 gettext_noop("Sets the maximum stack depth, in kilobytes."),
1306 100, 100, MAX_KILOBYTES, assign_max_stack_depth, NULL
1310 {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
1311 gettext_noop("Vacuum cost for a page found in the buffer cache."),
1315 1, 0, 10000, NULL, NULL
1319 {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
1320 gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1323 &VacuumCostPageMiss,
1324 10, 0, 10000, NULL, NULL
1328 {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
1329 gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1332 &VacuumCostPageDirty,
1333 20, 0, 10000, NULL, NULL
1337 {"vacuum_cost_limit", PGC_USERSET, RESOURCES,
1338 gettext_noop("Vacuum cost amount available before napping."),
1342 200, 1, 10000, NULL, NULL
1346 {"vacuum_cost_delay", PGC_USERSET, RESOURCES,
1347 gettext_noop("Vacuum cost delay in milliseconds."),
1352 0, 0, 1000, NULL, NULL
1356 {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
1357 gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
1361 &autovacuum_vac_cost_delay,
1362 20, -1, 1000, NULL, NULL
1366 {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
1367 gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
1370 &autovacuum_vac_cost_limit,
1371 -1, -1, 10000, NULL, NULL
1375 {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
1376 gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
1379 &max_files_per_process,
1380 1000, 25, INT_MAX, NULL, NULL
1384 {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
1385 gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
1388 &max_prepared_xacts,
1389 5, 0, INT_MAX, NULL, NULL
1394 {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
1395 gettext_noop("No description available."),
1400 FirstNormalObjectId, 0, INT_MAX, NULL, NULL
1403 {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
1404 gettext_noop("No description available."),
1409 0, 0, INT_MAX, NULL, NULL
1414 {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
1415 gettext_noop("Sets the maximum allowed duration of any statement."),
1416 gettext_noop("A value of 0 turns off the timeout."),
1420 0, 0, INT_MAX, NULL, NULL
1424 {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
1425 gettext_noop("Minimum age at which VACUUM should freeze a table row."),
1428 &vacuum_freeze_min_age,
1429 100000000, 0, 1000000000, NULL, NULL
1433 {"max_fsm_relations", PGC_POSTMASTER, RESOURCES_FSM,
1434 gettext_noop("Sets the maximum number of tables and indexes for which free space is tracked."),
1438 1000, 100, INT_MAX, NULL, NULL
1441 {"max_fsm_pages", PGC_POSTMASTER, RESOURCES_FSM,
1442 gettext_noop("Sets the maximum number of disk pages for which free space is tracked."),
1446 20000, 1000, INT_MAX, NULL, NULL
1450 {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
1451 gettext_noop("Sets the maximum number of locks per transaction."),
1452 gettext_noop("The shared lock table is sized on the assumption that "
1453 "at most max_locks_per_transaction * max_connections distinct "
1454 "objects will need to be locked at any one time.")
1456 &max_locks_per_xact,
1457 64, 10, INT_MAX, NULL, NULL
1461 {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
1462 gettext_noop("Sets the maximum allowed time to complete client authentication."),
1466 &AuthenticationTimeout,
1467 60, 1, 600, NULL, NULL
1471 /* Not for general use */
1472 {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
1473 gettext_noop("Waits N seconds on connection startup before authentication."),
1474 gettext_noop("This allows attaching a debugger to the process."),
1475 GUC_NOT_IN_SAMPLE | GUC_UNIT_S
1478 0, 0, 60, NULL, NULL
1482 {"checkpoint_segments", PGC_SIGHUP, WAL_CHECKPOINTS,
1483 gettext_noop("Sets the maximum distance in log segments between automatic WAL checkpoints."),
1486 &CheckPointSegments,
1487 3, 1, INT_MAX, NULL, NULL
1491 {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
1492 gettext_noop("Sets the maximum time between automatic WAL checkpoints."),
1497 300, 30, 3600, NULL, NULL
1501 {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
1502 gettext_noop("Enables warnings if checkpoint segments are filled more "
1503 "frequently than this."),
1504 gettext_noop("Write a message to the server log if checkpoints "
1505 "caused by the filling of checkpoint segment files happens more "
1506 "frequently than this number of seconds. Zero turns off the warning."),
1510 30, 0, INT_MAX, NULL, NULL
1514 {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
1515 gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
1520 8, 4, INT_MAX, NULL, NULL
1524 {"wal_writer_delay", PGC_SIGHUP, WAL_SETTINGS,
1525 gettext_noop("WAL writer sleep time between WAL flushes."),
1530 200, 1, 10000, NULL, NULL
1534 {"commit_delay", PGC_USERSET, WAL_SETTINGS,
1535 gettext_noop("Sets the delay in microseconds between transaction commit and "
1536 "flushing WAL to disk."),
1540 0, 0, 100000, NULL, NULL
1544 {"commit_siblings", PGC_USERSET, WAL_SETTINGS,
1545 gettext_noop("Sets the minimum concurrent open transactions before performing "
1550 5, 1, 1000, NULL, NULL
1554 {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
1555 gettext_noop("Sets the number of digits displayed for floating-point values."),
1556 gettext_noop("This affects real, double precision, and geometric data types. "
1557 "The parameter value is added to the standard number of digits "
1558 "(FLT_DIG or DBL_DIG as appropriate).")
1560 &extra_float_digits,
1561 0, -15, 2, NULL, NULL
1565 {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
1566 gettext_noop("Sets the minimum execution time above which statements will "
1568 gettext_noop("Zero prints all queries. The default is -1 (turning this feature off)."),
1571 &log_min_duration_statement,
1572 -1, -1, INT_MAX / 1000, NULL, NULL
1576 {"log_autovacuum", PGC_BACKEND, LOGGING_WHAT,
1577 gettext_noop("Sets the minimum execution time above which autovacuum actions "
1579 gettext_noop("Zero prints all actions. The default is -1 (turning this feature off)."),
1583 -1, -1, INT_MAX / 1000, NULL, NULL
1587 {"bgwriter_delay", PGC_SIGHUP, RESOURCES,
1588 gettext_noop("Background writer sleep time between rounds."),
1593 200, 10, 10000, NULL, NULL
1597 {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
1598 gettext_noop("Background writer maximum number of LRU pages to flush per round."),
1601 &bgwriter_lru_maxpages,
1602 5, 0, 1000, NULL, NULL
1606 {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
1607 gettext_noop("Automatic log file rotation will occur after N minutes."),
1612 HOURS_PER_DAY * MINS_PER_HOUR, 0, INT_MAX / MINS_PER_HOUR, NULL, NULL
1616 {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
1617 gettext_noop("Automatic log file rotation will occur after N kilobytes."),
1622 10 * 1024, 0, INT_MAX / 1024, NULL, NULL
1626 {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
1627 gettext_noop("Shows the maximum number of function arguments."),
1629 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1632 FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
1636 {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
1637 gettext_noop("Shows the maximum number of index keys."),
1639 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1642 INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
1646 {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
1647 gettext_noop("Shows the maximum identifier length."),
1649 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1651 &max_identifier_length,
1652 NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
1656 {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
1657 gettext_noop("Shows the size of a disk block."),
1659 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1662 BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
1666 {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
1667 gettext_noop("Time to sleep between autovacuum runs."),
1671 &autovacuum_naptime,
1672 60, 1, INT_MAX / 1000, NULL, NULL
1675 {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
1676 gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
1679 &autovacuum_vac_thresh,
1680 50, 0, INT_MAX, NULL, NULL
1683 {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
1684 gettext_noop("Minimum number of tuple inserts, updates or deletes prior to analyze."),
1687 &autovacuum_anl_thresh,
1688 50, 0, INT_MAX, NULL, NULL
1691 /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
1692 {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
1693 gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
1696 &autovacuum_freeze_max_age,
1697 200000000, 100000000, 2000000000, NULL, NULL
1700 /* see max_connections */
1701 {"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM,
1702 gettext_noop("Sets the maximum number of simultaneously running autovacuum worker processes."),
1705 &autovacuum_max_workers,
1706 3, 1, INT_MAX / 4, assign_autovacuum_max_workers, NULL
1710 {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
1711 gettext_noop("Time between issuing TCP keepalives."),
1712 gettext_noop("A value of 0 uses the system default."),
1715 &tcp_keepalives_idle,
1716 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle
1720 {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
1721 gettext_noop("Time between TCP keepalive retransmits."),
1722 gettext_noop("A value of 0 uses the system default."),
1725 &tcp_keepalives_interval,
1726 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
1730 {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
1731 gettext_noop("Maximum number of TCP keepalive retransmits."),
1732 gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
1733 "lost before a connection is considered dead. A value of 0 uses the "
1736 &tcp_keepalives_count,
1737 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count
1741 {"gin_fuzzy_search_limit", PGC_USERSET, CLIENT_CONN_OTHER,
1742 gettext_noop("Sets the maximum allowed result for exact search by GIN."),
1746 &GinFuzzySearchLimit,
1747 0, 0, INT_MAX, NULL, NULL
1751 {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
1752 gettext_noop("Sets the planner's assumption about the size of the disk cache."),
1753 gettext_noop("That is, the portion of the kernel's disk cache that "
1754 "will be used for PostgreSQL data files. This is measured in disk "
1755 "pages, which are normally 8 kB each."),
1758 &effective_cache_size,
1759 DEFAULT_EFFECTIVE_CACHE_SIZE, 1, INT_MAX, NULL, NULL
1763 /* Can't be set in postgresql.conf */
1764 {"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
1765 gettext_noop("Shows the server version as an integer."),
1767 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1769 &server_version_num,
1770 PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM, NULL, NULL
1774 {"log_temp_files", PGC_USERSET, LOGGING_WHAT,
1775 gettext_noop("Log the use of temporary files larger than this number of kilobytes."),
1776 gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
1780 -1, -1, INT_MAX, NULL, NULL
1783 /* End-of-list marker */
1785 {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
1790 static struct config_real ConfigureNamesReal[] =
1793 {"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1794 gettext_noop("Sets the planner's estimate of the cost of a "
1795 "sequentially fetched disk page."),
1799 DEFAULT_SEQ_PAGE_COST, 0, DBL_MAX, NULL, NULL
1802 {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1803 gettext_noop("Sets the planner's estimate of the cost of a "
1804 "nonsequentially fetched disk page."),
1808 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
1811 {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1812 gettext_noop("Sets the planner's estimate of the cost of "
1813 "processing each tuple (row)."),
1817 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1820 {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1821 gettext_noop("Sets the planner's estimate of the cost of "
1822 "processing each index entry during an index scan."),
1825 &cpu_index_tuple_cost,
1826 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1829 {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
1830 gettext_noop("Sets the planner's estimate of the cost of "
1831 "processing each operator or function call."),
1835 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
1839 {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
1840 gettext_noop("GEQO: selective pressure within the population."),
1843 &Geqo_selection_bias,
1844 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
1845 MAX_GEQO_SELECTION_BIAS, NULL, NULL
1849 {"bgwriter_lru_percent", PGC_SIGHUP, RESOURCES,
1850 gettext_noop("Background writer percentage of LRU buffers to flush per round."),
1853 &bgwriter_lru_percent,
1854 1.0, 0.0, 100.0, NULL, NULL
1858 {"seed", PGC_USERSET, UNGROUPED,
1859 gettext_noop("Sets the seed for random-number generation."),
1861 GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1864 0.5, 0.0, 1.0, assign_random_seed, show_random_seed
1868 {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1869 gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
1872 &autovacuum_vac_scale,
1873 0.2, 0.0, 100.0, NULL, NULL
1876 {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1877 gettext_noop("Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples."),
1880 &autovacuum_anl_scale,
1881 0.1, 0.0, 100.0, NULL, NULL
1885 {"checkpoint_completion_target", PGC_SIGHUP, WAL_CHECKPOINTS,
1886 gettext_noop("Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval."),
1889 &CheckPointCompletionTarget,
1890 0.5, 0.0, 1.0, NULL, NULL
1893 /* End-of-list marker */
1895 {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL
1900 static struct config_string ConfigureNamesString[] =
1903 {"archive_command", PGC_SIGHUP, WAL_SETTINGS,
1904 gettext_noop("Sets the shell command that will be called to archive a WAL file."),
1907 &XLogArchiveCommand,
1912 {"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1913 gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
1914 gettext_noop("Valid values are ON, OFF, and SAFE_ENCODING.")
1916 &backslash_quote_string,
1917 "safe_encoding", assign_backslash_quote, NULL
1921 {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
1922 gettext_noop("Sets the client's character set encoding."),
1924 GUC_IS_NAME | GUC_REPORT
1926 &client_encoding_string,
1927 "SQL_ASCII", assign_client_encoding, NULL
1931 {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
1932 gettext_noop("Sets the message levels that are sent to the client."),
1933 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, "
1934 "DEBUG1, LOG, NOTICE, WARNING, and ERROR. Each level includes all the "
1935 "levels that follow it. The later the level, the fewer messages are "
1938 &client_min_messages_str,
1939 "notice", assign_client_min_messages, NULL
1943 {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
1944 gettext_noop("Sets the message levels that are logged."),
1945 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, "
1946 "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level "
1947 "includes all the levels that follow it.")
1949 &log_min_messages_str,
1950 "notice", assign_log_min_messages, NULL
1954 {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
1955 gettext_noop("Sets the verbosity of logged messages."),
1956 gettext_noop("Valid values are \"terse\", \"default\", and \"verbose\".")
1958 &log_error_verbosity_str,
1959 "default", assign_log_error_verbosity, NULL
1962 {"log_statement", PGC_SUSET, LOGGING_WHAT,
1963 gettext_noop("Sets the type of statements logged."),
1964 gettext_noop("Valid values are \"none\", \"ddl\", \"mod\", and \"all\".")
1967 "none", assign_log_statement, NULL
1971 {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
1972 gettext_noop("Causes all statements generating error at or above this level to be logged."),
1973 gettext_noop("All SQL statements that cause an error of the "
1974 "specified level or a higher level are logged.")
1976 &log_min_error_statement_str,
1977 "error", assign_min_error_statement, NULL
1981 {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
1982 gettext_noop("Controls information prefixed to each log line."),
1983 gettext_noop("If blank, no prefix is used.")
1990 {"log_timezone", PGC_SIGHUP, LOGGING_WHAT,
1991 gettext_noop("Sets the time zone to use in log messages."),
1994 &log_timezone_string,
1995 "UNKNOWN", assign_log_timezone, show_log_timezone
1999 {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
2000 gettext_noop("Sets the display format for date and time values."),
2001 gettext_noop("Also controls interpretation of ambiguous "
2003 GUC_LIST_INPUT | GUC_REPORT
2006 "ISO, MDY", assign_datestyle, NULL
2010 {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
2011 gettext_noop("Sets the default tablespace to create tables and indexes in."),
2012 gettext_noop("An empty string selects the database's default tablespace."),
2015 &default_tablespace,
2016 "", assign_default_tablespace, NULL
2020 {"temp_tablespaces", PGC_USERSET, CLIENT_CONN_STATEMENT,
2021 gettext_noop("Sets the tablespace(s) to use for temporary tables and sort files."),
2023 GUC_LIST_INPUT | GUC_LIST_QUOTE
2026 "", assign_temp_tablespaces, NULL
2030 {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2031 gettext_noop("Sets the transaction isolation level of each new transaction."),
2032 gettext_noop("Each SQL transaction has an isolation level, which "
2033 "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
2035 &default_iso_level_string,
2036 "read committed", assign_defaultxactisolevel, NULL
2040 {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
2041 gettext_noop("Sets the sessions behavior for triggers and rewrite rules."),
2042 gettext_noop("Each session can be either"
2043 " \"origin\", \"replica\" or \"local\".")
2045 &session_replication_role_string,
2046 "origin", assign_session_replication_role, NULL
2050 {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
2051 gettext_noop("Sets the path for dynamically loadable modules."),
2052 gettext_noop("If a dynamically loadable module needs to be opened and "
2053 "the specified name does not have a directory component (i.e., the "
2054 "name does not contain a slash), the system will search this path for "
2055 "the specified file."),
2058 &Dynamic_library_path,
2059 "$libdir", NULL, NULL
2063 {"krb_server_keyfile", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2064 gettext_noop("Sets the location of the Kerberos server key file."),
2068 &pg_krb_server_keyfile,
2069 PG_KRB_SRVTAB, NULL, NULL
2073 {"krb_srvname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2074 gettext_noop("Sets the name of the Kerberos service."),
2078 PG_KRB_SRVNAM, NULL, NULL
2082 {"krb_server_hostname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2083 gettext_noop("Sets the hostname of the Kerberos server."),
2086 &pg_krb_server_hostname,
2091 {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2092 gettext_noop("Sets the Bonjour broadcast service name."),
2099 /* See main.c about why defaults for LC_foo are not all alike */
2102 {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2103 gettext_noop("Shows the collation order locale."),
2105 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2112 {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2113 gettext_noop("Shows the character classification and case conversion locale."),
2115 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2122 {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
2123 gettext_noop("Sets the language in which messages are displayed."),
2127 "", locale_messages_assign, NULL
2131 {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
2132 gettext_noop("Sets the locale for formatting monetary amounts."),
2136 "C", locale_monetary_assign, NULL
2140 {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
2141 gettext_noop("Sets the locale for formatting numbers."),
2145 "C", locale_numeric_assign, NULL
2149 {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
2150 gettext_noop("Sets the locale for formatting date and time values."),
2154 "C", locale_time_assign, NULL
2158 {"shared_preload_libraries", PGC_POSTMASTER, RESOURCES_KERNEL,
2159 gettext_noop("Lists shared libraries to preload into server."),
2161 GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
2163 &shared_preload_libraries_string,
2168 {"local_preload_libraries", PGC_BACKEND, CLIENT_CONN_OTHER,
2169 gettext_noop("Lists shared libraries to preload into each backend."),
2171 GUC_LIST_INPUT | GUC_LIST_QUOTE
2173 &local_preload_libraries_string,
2178 {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
2179 gettext_noop("Sets the regular expression \"flavor\"."),
2180 gettext_noop("This can be set to advanced, extended, or basic.")
2182 ®ex_flavor_string,
2183 "advanced", assign_regex_flavor, NULL
2187 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
2188 gettext_noop("Sets the schema search order for names that are not schema-qualified."),
2190 GUC_LIST_INPUT | GUC_LIST_QUOTE
2192 &namespace_search_path,
2193 "\"$user\",public", assign_search_path, NULL
2197 /* Can't be set in postgresql.conf */
2198 {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2199 gettext_noop("Sets the server (database) character set encoding."),
2201 GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2203 &server_encoding_string,
2204 "SQL_ASCII", NULL, NULL
2208 /* Can't be set in postgresql.conf */
2209 {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
2210 gettext_noop("Shows the server version."),
2212 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2214 &server_version_string,
2215 PG_VERSION, NULL, NULL
2219 /* Not for general use --- used by SET ROLE */
2220 {"role", PGC_USERSET, UNGROUPED,
2221 gettext_noop("Sets the current role."),
2223 GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2226 "none", assign_role, show_role
2230 /* Not for general use --- used by SET SESSION AUTHORIZATION */
2231 {"session_authorization", PGC_USERSET, UNGROUPED,
2232 gettext_noop("Sets the session user name."),
2234 GUC_IS_NAME | GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2236 &session_authorization_string,
2237 NULL, assign_session_authorization, show_session_authorization
2241 {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
2242 gettext_noop("Sets the destination for server log output."),
2243 gettext_noop("Valid values are combinations of \"stderr\", "
2244 "\"syslog\", \"csvlog\", and \"eventlog\", "
2245 "depending on the platform."),
2248 &log_destination_string,
2249 "stderr", assign_log_destination, NULL
2252 {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
2253 gettext_noop("Sets the destination directory for log files."),
2254 gettext_noop("Can be specified as relative to the data directory "
2255 "or as absolute path."),
2259 "pg_log", assign_canonical_path, NULL
2262 {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
2263 gettext_noop("Sets the file name pattern for log files."),
2268 "postgresql-%Y-%m-%d_%H%M%S.log", NULL, NULL
2273 {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2274 gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2275 gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2276 "LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2278 &syslog_facility_str,
2279 "LOCAL0", assign_syslog_facility, NULL
2282 {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
2283 gettext_noop("Sets the program name used to identify PostgreSQL "
2284 "messages in syslog."),
2288 "postgres", assign_syslog_ident, NULL
2293 {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
2294 gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
2299 "UNKNOWN", assign_timezone, show_timezone
2302 {"timezone_abbreviations", PGC_USERSET, CLIENT_CONN_LOCALE,
2303 gettext_noop("Selects a file of time zone abbreviations."),
2306 &timezone_abbreviations_string,
2307 "UNKNOWN", assign_timezone_abbreviations, NULL
2311 {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2312 gettext_noop("Sets the current transaction's isolation level."),
2314 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2316 &XactIsoLevel_string,
2317 NULL, assign_XactIsoLevel, show_XactIsoLevel
2321 {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2322 gettext_noop("Sets the owning group of the Unix-domain socket."),
2323 gettext_noop("The owning user of the socket is always the user "
2324 "that starts the server.")
2331 {"unix_socket_directory", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2332 gettext_noop("Sets the directory where the Unix-domain socket will be created."),
2337 "", assign_canonical_path, NULL
2341 {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2342 gettext_noop("Sets the host name or IP address(es) to listen to."),
2347 "localhost", NULL, NULL
2351 {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
2352 gettext_noop("Selects the method used for forcing WAL updates to disk."),
2356 XLOG_sync_method_default, assign_xlog_sync_method, NULL
2360 {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
2361 gettext_noop("Sets the list of known custom variable classes."),
2363 GUC_LIST_INPUT | GUC_LIST_QUOTE
2365 &custom_variable_classes,
2366 NULL, assign_custom_variable_classes, NULL
2370 {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
2371 gettext_noop("Sets the server's data directory."),
2380 {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
2381 gettext_noop("Sets the server's main configuration file."),
2383 GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
2390 {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
2391 gettext_noop("Sets the server's \"hba\" configuration file."),
2400 {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
2401 gettext_noop("Sets the server's \"ident\" configuration file."),
2410 {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
2411 gettext_noop("Writes the postmaster PID to the specified file."),
2416 NULL, assign_canonical_path, NULL
2420 {"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
2421 gettext_noop("Sets how binary values are to be encoded in XML."),
2422 gettext_noop("Valid values are BASE64 and HEX.")
2425 "base64", assign_xmlbinary, NULL
2429 {"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
2430 gettext_noop("Sets whether XML data in implicit parsing and serialization "
2431 "operations is to be considered as documents or content fragments."),
2432 gettext_noop("Valid values are DOCUMENT and CONTENT.")
2435 "content", assign_xmloption, NULL
2439 {"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
2440 gettext_noop("Sets default text search configuration."),
2444 "pg_catalog.simple", assignTSCurrentConfig, NULL
2449 {"ssl_ciphers", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2450 gettext_noop("Sets the list of allowed SSL ciphers."),
2455 "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH", NULL, NULL
2457 #endif /* USE_SSL */
2459 /* End-of-list marker */
2461 {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
2466 /******** end of options list ********/
2470 * To allow continued support of obsolete names for GUC variables, we apply
2471 * the following mappings to any unrecognized name. Note that an old name
2472 * should be mapped to a new one only if the new variable has very similar
2473 * semantics to the old.
2475 static const char *const map_old_guc_names[] = {
2476 "sort_mem", "work_mem",
2477 "vacuum_mem", "maintenance_work_mem",
2483 * Actual lookup of variables is done through this single, sorted array.
2485 static struct config_generic **guc_variables;
2487 /* Current number of variables contained in the vector */
2488 static int num_guc_variables;
2490 /* Vector capacity */
2491 static int size_guc_variables;
2494 static bool guc_dirty; /* TRUE if need to do commit/abort work */
2496 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
2498 static int GUCNestLevel = 0; /* 1 when in main transaction */
2501 static int guc_var_compare(const void *a, const void *b);
2502 static int guc_name_compare(const char *namea, const char *nameb);
2503 static void push_old_value(struct config_generic * gconf);
2504 static void ReportGUCOption(struct config_generic * record);
2505 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
2506 static void ShowAllGUCConfig(DestReceiver *dest);
2507 static char *_ShowOption(struct config_generic * record, bool use_units);
2508 static bool is_newvalue_equal(struct config_generic * record, const char *newvalue);
2512 * Some infrastructure for checking malloc/strdup/realloc calls
2515 guc_malloc(int elevel, size_t size)
2519 data = malloc(size);
2522 (errcode(ERRCODE_OUT_OF_MEMORY),
2523 errmsg("out of memory")));
2528 guc_realloc(int elevel, void *old, size_t size)
2532 data = realloc(old, size);
2535 (errcode(ERRCODE_OUT_OF_MEMORY),
2536 errmsg("out of memory")));
2541 guc_strdup(int elevel, const char *src)
2548 (errcode(ERRCODE_OUT_OF_MEMORY),
2549 errmsg("out of memory")));
2555 * Support for assigning to a field of a string GUC item. Free the prior
2556 * value if it's not referenced anywhere else in the item (including stacked
2560 set_string_field(struct config_string * conf, char **field, char *newval)
2562 char *oldval = *field;
2565 /* Do the assignment */
2568 /* Exit if any duplicate references, or if old value was NULL anyway */
2569 if (oldval == NULL ||
2570 oldval == *(conf->variable) ||
2571 oldval == conf->reset_val ||
2572 oldval == conf->tentative_val ||
2573 oldval == conf->boot_val)
2575 for (stack = conf->gen.stack; stack; stack = stack->prev)
2577 if (oldval == stack->tentative_val.stringval ||
2578 oldval == stack->value.stringval)
2582 /* Not used anymore, so free it */
2587 * Detect whether strval is referenced anywhere in a GUC string item
2590 string_field_used(struct config_string * conf, char *strval)
2594 if (strval == *(conf->variable) ||
2595 strval == conf->reset_val ||
2596 strval == conf->tentative_val ||
2597 strval == conf->boot_val)
2599 for (stack = conf->gen.stack; stack; stack = stack->prev)
2601 if (strval == stack->tentative_val.stringval ||
2602 strval == stack->value.stringval)
2609 struct config_generic **
2610 get_guc_variables(void)
2612 return guc_variables;
2617 * Build the sorted array. This is split out so that it could be
2618 * re-executed after startup (eg, we could allow loadable modules to
2619 * add vars, and then we'd need to re-sort).
2622 build_guc_variables(void)
2626 struct config_generic **guc_vars;
2629 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2631 struct config_bool *conf = &ConfigureNamesBool[i];
2633 /* Rather than requiring vartype to be filled in by hand, do this: */
2634 conf->gen.vartype = PGC_BOOL;
2638 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2640 struct config_int *conf = &ConfigureNamesInt[i];
2642 conf->gen.vartype = PGC_INT;
2646 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2648 struct config_real *conf = &ConfigureNamesReal[i];
2650 conf->gen.vartype = PGC_REAL;
2654 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2656 struct config_string *conf = &ConfigureNamesString[i];
2658 conf->gen.vartype = PGC_STRING;
2663 * Create table with 20% slack
2665 size_vars = num_vars + num_vars / 4;
2667 guc_vars = (struct config_generic **)
2668 guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
2672 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2673 guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
2675 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2676 guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
2678 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2679 guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
2681 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2682 guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
2685 free(guc_variables);
2686 guc_variables = guc_vars;
2687 num_guc_variables = num_vars;
2688 size_guc_variables = size_vars;
2689 qsort((void *) guc_variables, num_guc_variables,
2690 sizeof(struct config_generic *), guc_var_compare);
2694 is_custom_class(const char *name, int dotPos)
2697 * assign_custom_variable_classes() has made sure no empty identifiers or
2698 * whitespace exists in the variable
2700 bool result = false;
2701 const char *ccs = GetConfigOption("custom_variable_classes");
2705 const char *start = ccs;
2711 if (c == 0 || c == ',')
2713 if (dotPos == ccs - start && strncmp(start, name, dotPos) == 0)
2728 * Add a new GUC variable to the list of known variables. The
2729 * list is expanded if needed.
2732 add_guc_variable(struct config_generic * var, int elevel)
2734 if (num_guc_variables + 1 >= size_guc_variables)
2737 * Increase the vector by 25%
2739 int size_vars = size_guc_variables + size_guc_variables / 4;
2740 struct config_generic **guc_vars;
2745 guc_vars = (struct config_generic **)
2746 guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
2750 guc_vars = (struct config_generic **)
2751 guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
2754 if (guc_vars == NULL)
2755 return false; /* out of memory */
2757 guc_variables = guc_vars;
2758 size_guc_variables = size_vars;
2760 guc_variables[num_guc_variables++] = var;
2761 qsort((void *) guc_variables, num_guc_variables,
2762 sizeof(struct config_generic *), guc_var_compare);
2767 * Create and add a placeholder variable. It's presumed to belong
2768 * to a valid custom variable class at this point.
2770 static struct config_string *
2771 add_placeholder_variable(const char *name, int elevel)
2773 size_t sz = sizeof(struct config_string) + sizeof(char *);
2774 struct config_string *var;
2775 struct config_generic *gen;
2777 var = (struct config_string *) guc_malloc(elevel, sz);
2784 gen->name = guc_strdup(elevel, name);
2785 if (gen->name == NULL)
2791 gen->context = PGC_USERSET;
2792 gen->group = CUSTOM_OPTIONS;
2793 gen->short_desc = "GUC placeholder variable";
2794 gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
2795 gen->vartype = PGC_STRING;
2798 * The char* is allocated at the end of the struct since we have no
2799 * 'static' place to point to.
2801 var->variable = (char **) (var + 1);
2803 if (!add_guc_variable((struct config_generic *) var, elevel))
2805 free((void *) gen->name);
2814 * Look up option NAME. If it exists, return a pointer to its record,
2817 static struct config_generic *
2818 find_option(const char *name, int elevel)
2821 const char **key = &name;
2822 struct config_generic **res;
2828 * By equating const char ** with struct config_generic *, we are assuming
2829 * the name field is first in config_generic.
2831 res = (struct config_generic **) bsearch((void *) &key,
2832 (void *) guc_variables,
2834 sizeof(struct config_generic *),
2840 * See if the name is an obsolete name for a variable. We assume that the
2841 * set of supported old names is short enough that a brute-force search is
2844 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
2846 if (guc_name_compare(name, map_old_guc_names[i]) == 0)
2847 return find_option(map_old_guc_names[i + 1], elevel);
2851 * Check if the name is qualified, and if so, check if the qualifier maps
2852 * to a custom variable class.
2854 dot = strchr(name, GUC_QUALIFIER_SEPARATOR);
2855 if (dot != NULL && is_custom_class(name, dot - name))
2856 /* Add a placeholder variable for this name */
2857 return (struct config_generic *) add_placeholder_variable(name, elevel);
2865 * comparator for qsorting and bsearching guc_variables array
2868 guc_var_compare(const void *a, const void *b)
2870 struct config_generic *confa = *(struct config_generic **) a;
2871 struct config_generic *confb = *(struct config_generic **) b;
2873 return guc_name_compare(confa->name, confb->name);
2878 guc_name_compare(const char *namea, const char *nameb)
2881 * The temptation to use strcasecmp() here must be resisted, because the
2882 * array ordering has to remain stable across setlocale() calls. So, build
2883 * our own with a simple ASCII-only downcasing.
2885 while (*namea && *nameb)
2887 char cha = *namea++;
2888 char chb = *nameb++;
2890 if (cha >= 'A' && cha <= 'Z')
2892 if (chb >= 'A' && chb <= 'Z')
2898 return 1; /* a is longer */
2900 return -1; /* b is longer */
2906 guc_get_index(const char *name)
2908 const char **key = &name;
2909 struct config_generic **res;
2914 * By equating const char ** with struct config_generic *, we are assuming
2915 * the name field is first in config_generic.
2917 res = (struct config_generic **) bsearch((void *) &key,
2918 (void *) guc_variables,
2920 sizeof(struct config_generic *),
2925 return res - guc_variables;
2930 * Initialize GUC options during program startup.
2932 * Note that we cannot read the config file yet, since we have not yet
2933 * processed command-line switches.
2936 InitializeGUCOptions(void)
2943 * Before log_line_prefix could possibly receive a nonempty setting,
2944 * make sure that timezone processing is minimally alive (see elog.c).
2946 pg_timezone_pre_initialize();
2949 * Build sorted array of all GUC variables.
2951 build_guc_variables();
2954 * Load all variables with their compiled-in defaults, and initialize
2955 * status fields as needed.
2957 for (i = 0; i < num_guc_variables; i++)
2959 struct config_generic *gconf = guc_variables[i];
2962 gconf->reset_source = PGC_S_DEFAULT;
2963 gconf->tentative_source = PGC_S_DEFAULT;
2964 gconf->source = PGC_S_DEFAULT;
2965 gconf->stack = NULL;
2967 switch (gconf->vartype)
2971 struct config_bool *conf = (struct config_bool *) gconf;
2973 if (conf->assign_hook)
2974 if (!(*conf->assign_hook) (conf->boot_val, true,
2976 elog(FATAL, "failed to initialize %s to %d",
2977 conf->gen.name, (int) conf->boot_val);
2978 *conf->variable = conf->reset_val = conf->boot_val;
2983 struct config_int *conf = (struct config_int *) gconf;
2985 Assert(conf->boot_val >= conf->min);
2986 Assert(conf->boot_val <= conf->max);
2987 if (conf->assign_hook)
2988 if (!(*conf->assign_hook) (conf->boot_val, true,
2990 elog(FATAL, "failed to initialize %s to %d",
2991 conf->gen.name, conf->boot_val);
2992 *conf->variable = conf->reset_val = conf->boot_val;
2997 struct config_real *conf = (struct config_real *) gconf;
2999 Assert(conf->boot_val >= conf->min);
3000 Assert(conf->boot_val <= conf->max);
3001 if (conf->assign_hook)
3002 if (!(*conf->assign_hook) (conf->boot_val, true,
3004 elog(FATAL, "failed to initialize %s to %g",
3005 conf->gen.name, conf->boot_val);
3006 *conf->variable = conf->reset_val = conf->boot_val;
3011 struct config_string *conf = (struct config_string *) gconf;
3014 *conf->variable = NULL;
3015 conf->reset_val = NULL;
3016 conf->tentative_val = NULL;
3018 if (conf->boot_val == NULL)
3020 /* Cannot set value yet */
3024 str = guc_strdup(FATAL, conf->boot_val);
3025 conf->reset_val = str;
3027 if (conf->assign_hook)
3031 newstr = (*conf->assign_hook) (str, true,
3035 elog(FATAL, "failed to initialize %s to \"%s\"",
3036 conf->gen.name, str);
3038 else if (newstr != str)
3043 * See notes in set_config_option about casting
3045 str = (char *) newstr;
3046 conf->reset_val = str;
3049 *conf->variable = str;
3057 reporting_enabled = false;
3060 * Prevent any attempt to override the transaction modes from
3061 * non-interactive sources.
3063 SetConfigOption("transaction_isolation", "default",
3064 PGC_POSTMASTER, PGC_S_OVERRIDE);
3065 SetConfigOption("transaction_read_only", "no",
3066 PGC_POSTMASTER, PGC_S_OVERRIDE);
3069 * For historical reasons, some GUC parameters can receive defaults from
3070 * environment variables. Process those settings.
3073 env = getenv("PGPORT");
3075 SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3077 env = getenv("PGDATESTYLE");
3079 SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3081 env = getenv("PGCLIENTENCODING");
3083 SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3086 * rlimit isn't exactly an "environment variable", but it behaves about
3087 * the same. If we can identify the platform stack depth rlimit, increase
3088 * default stack depth setting up to whatever is safe (but at most 2MB).
3090 stack_rlimit = get_stack_depth_rlimit();
3091 if (stack_rlimit > 0)
3093 int new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;
3095 if (new_limit > 100)
3099 new_limit = Min(new_limit, 2048);
3100 sprintf(limbuf, "%d", new_limit);
3101 SetConfigOption("max_stack_depth", limbuf,
3102 PGC_POSTMASTER, PGC_S_ENV_VAR);
3109 * Select the configuration files and data directory to be used, and
3110 * do the initial read of postgresql.conf.
3112 * This is called after processing command-line switches.
3113 * userDoption is the -D switch value if any (NULL if unspecified).
3114 * progname is just for use in error messages.
3116 * Returns true on success; on failure, prints a suitable error message
3117 * to stderr and returns false.
3120 SelectConfigFiles(const char *userDoption, const char *progname)
3124 struct stat stat_buf;
3126 /* configdir is -D option, or $PGDATA if no -D */
3128 configdir = make_absolute_path(userDoption);
3130 configdir = make_absolute_path(getenv("PGDATA"));
3133 * Find the configuration file: if config_file was specified on the
3134 * command line, use it, else use configdir/postgresql.conf. In any case
3135 * ensure the result is an absolute path, so that it will be interpreted
3136 * the same way by future backends.
3139 fname = make_absolute_path(ConfigFileName);
3142 fname = guc_malloc(FATAL,
3143 strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
3144 sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
3148 write_stderr("%s does not know where to find the server configuration file.\n"
3149 "You must specify the --config-file or -D invocation "
3150 "option or set the PGDATA environment variable.\n",
3156 * Set the ConfigFileName GUC variable to its final value, ensuring that
3157 * it can't be overridden later.
3159 SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3163 * Now read the config file for the first time.
3165 if (stat(ConfigFileName, &stat_buf) != 0)
3167 write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
3168 progname, ConfigFileName, strerror(errno));
3172 ProcessConfigFile(PGC_POSTMASTER);
3175 * If the data_directory GUC variable has been set, use that as DataDir;
3176 * otherwise use configdir if set; else punt.
3178 * Note: SetDataDir will copy and absolute-ize its argument, so we don't
3182 SetDataDir(data_directory);
3184 SetDataDir(configdir);
3187 write_stderr("%s does not know where to find the database system data.\n"
3188 "This can be specified as \"data_directory\" in \"%s\", "
3189 "or by the -D invocation option, or by the "
3190 "PGDATA environment variable.\n",
3191 progname, ConfigFileName);
3196 * Reflect the final DataDir value back into the data_directory GUC var.
3197 * (If you are wondering why we don't just make them a single variable,
3198 * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
3199 * child backends specially. XXX is that still true? Given that we now
3200 * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
3201 * DataDir in advance.)
3203 SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
3206 * Figure out where pg_hba.conf is, and make sure the path is absolute.
3209 fname = make_absolute_path(HbaFileName);
3212 fname = guc_malloc(FATAL,
3213 strlen(configdir) + strlen(HBA_FILENAME) + 2);
3214 sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
3218 write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
3219 "This can be specified as \"hba_file\" in \"%s\", "
3220 "or by the -D invocation option, or by the "
3221 "PGDATA environment variable.\n",
3222 progname, ConfigFileName);
3225 SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3229 * Likewise for pg_ident.conf.
3232 fname = make_absolute_path(IdentFileName);
3235 fname = guc_malloc(FATAL,
3236 strlen(configdir) + strlen(IDENT_FILENAME) + 2);
3237 sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
3241 write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
3242 "This can be specified as \"ident_file\" in \"%s\", "
3243 "or by the -D invocation option, or by the "
3244 "PGDATA environment variable.\n",
3245 progname, ConfigFileName);
3248 SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3258 * Reset all options to their saved default values (implements RESET ALL)
3261 ResetAllOptions(void)
3265 for (i = 0; i < num_guc_variables; i++)
3267 struct config_generic *gconf = guc_variables[i];
3269 /* Don't reset non-SET-able values */
3270 if (gconf->context != PGC_SUSET &&
3271 gconf->context != PGC_USERSET)
3273 /* Don't reset if special exclusion from RESET ALL */
3274 if (gconf->flags & GUC_NO_RESET_ALL)
3276 /* No need to reset if wasn't SET */
3277 if (gconf->source <= PGC_S_OVERRIDE)
3280 /* Save old value to support transaction abort */
3281 push_old_value(gconf);
3283 switch (gconf->vartype)
3287 struct config_bool *conf = (struct config_bool *) gconf;
3289 if (conf->assign_hook)
3290 if (!(*conf->assign_hook) (conf->reset_val, true,
3292 elog(ERROR, "failed to reset %s", conf->gen.name);
3293 *conf->variable = conf->reset_val;
3294 conf->tentative_val = conf->reset_val;
3295 conf->gen.source = conf->gen.reset_source;
3296 conf->gen.tentative_source = conf->gen.reset_source;
3297 conf->gen.status |= GUC_HAVE_TENTATIVE;
3303 struct config_int *conf = (struct config_int *) gconf;
3305 if (conf->assign_hook)
3306 if (!(*conf->assign_hook) (conf->reset_val, true,
3308 elog(ERROR, "failed to reset %s", conf->gen.name);
3309 *conf->variable = conf->reset_val;
3310 conf->tentative_val = conf->reset_val;
3311 conf->gen.source = conf->gen.reset_source;
3312 conf->gen.tentative_source = conf->gen.reset_source;
3313 conf->gen.status |= GUC_HAVE_TENTATIVE;
3319 struct config_real *conf = (struct config_real *) gconf;
3321 if (conf->assign_hook)
3322 if (!(*conf->assign_hook) (conf->reset_val, true,
3324 elog(ERROR, "failed to reset %s", conf->gen.name);
3325 *conf->variable = conf->reset_val;
3326 conf->tentative_val = conf->reset_val;
3327 conf->gen.source = conf->gen.reset_source;
3328 conf->gen.tentative_source = conf->gen.reset_source;
3329 conf->gen.status |= GUC_HAVE_TENTATIVE;
3335 struct config_string *conf = (struct config_string *) gconf;
3338 if (conf->reset_val == NULL)
3340 /* Nothing to reset to, as yet; so do nothing */
3344 /* We need not strdup here */
3345 str = conf->reset_val;
3347 if (conf->assign_hook)
3351 newstr = (*conf->assign_hook) (str, true,
3354 elog(ERROR, "failed to reset %s", conf->gen.name);
3355 else if (newstr != str)
3358 * See notes in set_config_option about casting
3360 str = (char *) newstr;
3364 set_string_field(conf, conf->variable, str);
3365 set_string_field(conf, &conf->tentative_val, str);
3366 conf->gen.source = conf->gen.reset_source;
3367 conf->gen.tentative_source = conf->gen.reset_source;
3368 conf->gen.status |= GUC_HAVE_TENTATIVE;
3374 if (gconf->flags & GUC_REPORT)
3375 ReportGUCOption(gconf);
3382 * Push previous state during first assignment to a GUC variable
3383 * within a particular transaction.
3385 * We have to be willing to "back-fill" the state stack if the first
3386 * assignment occurs within a subtransaction nested several levels deep.
3387 * This ensures that if an intermediate transaction aborts, it will have
3388 * the proper value available to restore the setting to.
3391 push_old_value(struct config_generic * gconf)
3395 /* If we're not inside a transaction, do nothing */
3396 if (GUCNestLevel == 0)
3401 /* Done if we already pushed it at this nesting depth */
3402 if (gconf->stack && gconf->stack->nest_level >= GUCNestLevel)
3406 * We keep all the stack entries in TopTransactionContext so as to
3407 * avoid allocation problems when a subtransaction back-fills stack
3408 * entries for upper transaction levels.
3410 stack = (GucStack *) MemoryContextAlloc(TopTransactionContext,
3413 stack->prev = gconf->stack;
3414 stack->nest_level = stack->prev ? stack->prev->nest_level + 1 : 1;
3415 stack->status = gconf->status;
3416 stack->tentative_source = gconf->tentative_source;
3417 stack->source = gconf->source;
3419 switch (gconf->vartype)
3422 stack->tentative_val.boolval =
3423 ((struct config_bool *) gconf)->tentative_val;
3424 stack->value.boolval =
3425 *((struct config_bool *) gconf)->variable;
3429 stack->tentative_val.intval =
3430 ((struct config_int *) gconf)->tentative_val;
3431 stack->value.intval =
3432 *((struct config_int *) gconf)->variable;
3436 stack->tentative_val.realval =
3437 ((struct config_real *) gconf)->tentative_val;
3438 stack->value.realval =
3439 *((struct config_real *) gconf)->variable;
3443 stack->tentative_val.stringval =
3444 ((struct config_string *) gconf)->tentative_val;
3445 stack->value.stringval =
3446 *((struct config_string *) gconf)->variable;
3450 gconf->stack = stack;
3452 /* Set state to indicate nothing happened yet within this level */
3453 gconf->status = GUC_HAVE_STACK;
3455 /* Ensure we remember to pop at end of xact */
3461 * Do GUC processing at main transaction start.
3467 * The nest level should be 0 between transactions; if it isn't,
3468 * somebody didn't call AtEOXact_GUC, or called it with the wrong
3469 * nestLevel. We throw a warning but make no other effort to clean up.
3471 if (GUCNestLevel != 0)
3472 elog(WARNING, "GUC nest level = %d at transaction start",
3478 * Enter a new nesting level for GUC values. This is called at subtransaction
3479 * start and when entering a function that has proconfig settings. NOTE that
3480 * we must not risk error here, else subtransaction start will be unhappy.
3483 NewGUCNestLevel(void)
3485 return ++GUCNestLevel;
3489 * Do GUC processing at transaction or subtransaction commit or abort, or
3490 * when exiting a function that has proconfig settings. (The name is thus
3491 * a bit of a misnomer; perhaps it should be ExitGUCNestLevel or some such.)
3492 * During abort, we discard all GUC settings that were applied at nesting
3493 * levels >= nestLevel. nestLevel == 1 corresponds to the main transaction.
3496 AtEOXact_GUC(bool isCommit, int nestLevel)
3500 Assert(nestLevel > 0 && nestLevel <= GUCNestLevel);
3502 /* Quick exit if nothing's changed in this transaction */
3505 GUCNestLevel = nestLevel - 1;
3509 for (i = 0; i < num_guc_variables; i++)
3511 struct config_generic *gconf = guc_variables[i];
3512 int my_status = gconf->status;
3513 GucStack *stack = gconf->stack;
3518 * Skip if nothing's happened to this var in this transaction
3522 Assert(stack == NULL);
3525 /* Assert that we stacked old value before changing it */
3526 Assert(stack != NULL && (my_status & GUC_HAVE_STACK));
3527 /* However, the last change may have been at an outer xact level */
3528 if (stack->nest_level < nestLevel)
3530 Assert(stack->nest_level == nestLevel);
3533 * We will pop the stack entry. Start by restoring outer xact status
3534 * (since we may want to modify it below). Be careful to use
3535 * my_status to reference the inner xact status below this point...
3537 gconf->status = stack->status;
3540 * We have two cases:
3542 * If commit and HAVE_TENTATIVE, set actual value to tentative (this
3543 * is to override a SET LOCAL if one occurred later than SET). We keep
3544 * the tentative value and propagate HAVE_TENTATIVE to the parent
3545 * status, allowing the SET's effect to percolate up. (But if we're
3546 * exiting the outermost transaction, we'll drop the HAVE_TENTATIVE
3549 * Otherwise, we have a transaction that aborted or executed only SET
3550 * LOCAL (or no SET at all). In either case it should have no further
3551 * effect, so restore both tentative and actual values from the stack
3555 useTentative = isCommit && (my_status & GUC_HAVE_TENTATIVE) != 0;
3558 switch (gconf->vartype)
3562 struct config_bool *conf = (struct config_bool *) gconf;
3564 GucSource newsource;
3568 newval = conf->tentative_val;
3569 newsource = conf->gen.tentative_source;
3570 conf->gen.status |= GUC_HAVE_TENTATIVE;
3574 newval = stack->value.boolval;
3575 newsource = stack->source;
3576 conf->tentative_val = stack->tentative_val.boolval;
3577 conf->gen.tentative_source = stack->tentative_source;
3580 if (*conf->variable != newval)
3582 if (conf->assign_hook)
3583 if (!(*conf->assign_hook) (newval,
3584 true, PGC_S_OVERRIDE))
3585 elog(LOG, "failed to commit %s",
3587 *conf->variable = newval;
3590 conf->gen.source = newsource;
3595 struct config_int *conf = (struct config_int *) gconf;
3597 GucSource newsource;
3601 newval = conf->tentative_val;
3602 newsource = conf->gen.tentative_source;
3603 conf->gen.status |= GUC_HAVE_TENTATIVE;
3607 newval = stack->value.intval;
3608 newsource = stack->source;
3609 conf->tentative_val = stack->tentative_val.intval;
3610 conf->gen.tentative_source = stack->tentative_source;
3613 if (*conf->variable != newval)
3615 if (conf->assign_hook)
3616 if (!(*conf->assign_hook) (newval,
3617 true, PGC_S_OVERRIDE))
3618 elog(LOG, "failed to commit %s",
3620 *conf->variable = newval;
3623 conf->gen.source = newsource;
3628 struct config_real *conf = (struct config_real *) gconf;
3630 GucSource newsource;
3634 newval = conf->tentative_val;
3635 newsource = conf->gen.tentative_source;
3636 conf->gen.status |= GUC_HAVE_TENTATIVE;
3640 newval = stack->value.realval;
3641 newsource = stack->source;
3642 conf->tentative_val = stack->tentative_val.realval;
3643 conf->gen.tentative_source = stack->tentative_source;
3646 if (*conf->variable != newval)
3648 if (conf->assign_hook)
3649 if (!(*conf->assign_hook) (newval,
3650 true, PGC_S_OVERRIDE))
3651 elog(LOG, "failed to commit %s",
3653 *conf->variable = newval;
3656 conf->gen.source = newsource;
3661 struct config_string *conf = (struct config_string *) gconf;
3663 GucSource newsource;
3667 newval = conf->tentative_val;
3668 newsource = conf->gen.tentative_source;
3669 conf->gen.status |= GUC_HAVE_TENTATIVE;
3673 newval = stack->value.stringval;
3674 newsource = stack->source;
3675 set_string_field(conf, &conf->tentative_val,
3676 stack->tentative_val.stringval);
3677 conf->gen.tentative_source = stack->tentative_source;
3680 if (*conf->variable != newval)
3682 if (conf->assign_hook)
3686 newstr = (*conf->assign_hook) (newval, true,
3689 elog(LOG, "failed to commit %s",
3691 else if (newstr != newval)
3694 * If newval should now be freed, it'll be
3695 * taken care of below.
3697 * See notes in set_config_option about
3700 newval = (char *) newstr;
3704 set_string_field(conf, conf->variable, newval);
3707 conf->gen.source = newsource;
3708 /* Release stacked values if not used anymore */
3709 set_string_field(conf, &stack->value.stringval,
3711 set_string_field(conf, &stack->tentative_val.stringval,
3713 /* Don't store tentative value separately after commit */
3715 set_string_field(conf, &conf->tentative_val, NULL);
3720 /* Finish popping the state stack */
3721 gconf->stack = stack->prev;
3725 * If we're now out of all xact levels, forget TENTATIVE status bit;
3726 * there's nothing tentative about the value anymore.
3730 Assert(gconf->stack == NULL);
3734 /* Report new value if we changed it */
3735 if (changed && (gconf->flags & GUC_REPORT))
3736 ReportGUCOption(gconf);
3740 * If we're now out of all xact levels, we can clear guc_dirty. (Note: we
3741 * cannot reset guc_dirty when exiting a subtransaction, because we know
3742 * that all outer transaction levels will have stacked values to deal
3748 /* Update nesting level */
3749 GUCNestLevel = nestLevel - 1;
3754 * Start up automatic reporting of changes to variables marked GUC_REPORT.
3755 * This is executed at completion of backend startup.
3758 BeginReportingGUCOptions(void)
3763 * Don't do anything unless talking to an interactive frontend of protocol
3766 if (whereToSendOutput != DestRemote ||
3767 PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
3770 reporting_enabled = true;
3772 /* Transmit initial values of interesting variables */
3773 for (i = 0; i < num_guc_variables; i++)
3775 struct config_generic *conf = guc_variables[i];
3777 if (conf->flags & GUC_REPORT)
3778 ReportGUCOption(conf);
3783 * ReportGUCOption: if appropriate, transmit option value to frontend
3786 ReportGUCOption(struct config_generic * record)
3788 if (reporting_enabled && (record->flags & GUC_REPORT))
3790 char *val = _ShowOption(record, false);
3791 StringInfoData msgbuf;
3793 pq_beginmessage(&msgbuf, 'S');
3794 pq_sendstring(&msgbuf, record->name);
3795 pq_sendstring(&msgbuf, val);
3796 pq_endmessage(&msgbuf);
3804 * Try to interpret value as boolean value. Valid values are: true,
3805 * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
3806 * If the string parses okay, return true, else false.
3807 * If okay and result is not NULL, return the value in *result.
3810 parse_bool(const char *value, bool *result)
3812 size_t len = strlen(value);
3814 if (pg_strncasecmp(value, "true", len) == 0)
3819 else if (pg_strncasecmp(value, "false", len) == 0)
3825 else if (pg_strncasecmp(value, "yes", len) == 0)
3830 else if (pg_strncasecmp(value, "no", len) == 0)
3836 /* 'o' is not unique enough */
3837 else if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
3842 else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
3848 else if (pg_strcasecmp(value, "1") == 0)
3853 else if (pg_strcasecmp(value, "0") == 0)
3862 *result = false; /* suppress compiler warning */
3871 * Try to parse value as an integer. The accepted formats are the
3872 * usual decimal, octal, or hexadecimal formats, optionally followed by
3873 * a unit name if "flags" indicates a unit is allowed.
3875 * If the string parses okay, return true, else false.
3876 * If okay and result is not NULL, return the value in *result.
3877 * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
3878 * HINT message, or NULL if no hint provided.
3881 parse_int(const char *value, int *result, int flags, const char **hintmsg)
3886 /* To suppress compiler warnings, always set output params */
3892 /* We assume here that int64 is at least as wide as long */
3894 val = strtol(value, &endptr, 0);
3896 if (endptr == value)
3897 return false; /* no HINT for integer syntax error */
3899 if (errno == ERANGE || val != (int64) ((int32) val))
3902 *hintmsg = gettext_noop("Value exceeds integer range.");
3906 /* allow whitespace between integer and unit */
3907 while (isspace((unsigned char) *endptr))
3910 /* Handle possible unit */
3911 if (*endptr != '\0')
3914 * Note: the multiple-switch coding technique here is a bit tedious,
3915 * but seems necessary to avoid intermediate-value overflows.
3917 * If INT64_IS_BUSTED (ie, it's really int32) we will fail to detect
3918 * overflow due to units conversion, but there are few enough such
3919 * machines that it does not seem worth trying to be smarter.
3921 if (flags & GUC_UNIT_MEMORY)
3923 /* Set hint for use if no match or trailing garbage */
3925 *hintmsg = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", and \"GB\".");
3927 #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
3928 #error BLCKSZ must be between 1KB and 1MB
3930 #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
3931 #error XLOG_BLCKSZ must be between 1KB and 1MB
3934 if (strncmp(endptr, "kB", 2) == 0)
3937 switch (flags & GUC_UNIT_MEMORY)
3939 case GUC_UNIT_BLOCKS:
3940 val /= (BLCKSZ / 1024);
3942 case GUC_UNIT_XBLOCKS:
3943 val /= (XLOG_BLCKSZ / 1024);
3947 else if (strncmp(endptr, "MB", 2) == 0)
3950 switch (flags & GUC_UNIT_MEMORY)
3955 case GUC_UNIT_BLOCKS:
3956 val *= KB_PER_MB / (BLCKSZ / 1024);
3958 case GUC_UNIT_XBLOCKS:
3959 val *= KB_PER_MB / (XLOG_BLCKSZ / 1024);
3963 else if (strncmp(endptr, "GB", 2) == 0)
3966 switch (flags & GUC_UNIT_MEMORY)
3971 case GUC_UNIT_BLOCKS:
3972 val *= KB_PER_GB / (BLCKSZ / 1024);
3974 case GUC_UNIT_XBLOCKS:
3975 val *= KB_PER_GB / (XLOG_BLCKSZ / 1024);
3980 else if (flags & GUC_UNIT_TIME)
3982 /* Set hint for use if no match or trailing garbage */
3984 *hintmsg = gettext_noop("Valid units for this parameter are \"ms\", \"s\", \"min\", \"h\", and \"d\".");
3986 if (strncmp(endptr, "ms", 2) == 0)
3989 switch (flags & GUC_UNIT_TIME)
3999 else if (strncmp(endptr, "s", 1) == 0)
4002 switch (flags & GUC_UNIT_TIME)
4012 else if (strncmp(endptr, "min", 3) == 0)
4015 switch (flags & GUC_UNIT_TIME)
4025 else if (strncmp(endptr, "h", 1) == 0)
4028 switch (flags & GUC_UNIT_TIME)
4041 else if (strncmp(endptr, "d", 1) == 0)
4044 switch (flags & GUC_UNIT_TIME)
4059 /* allow whitespace after unit */
4060 while (isspace((unsigned char) *endptr))
4063 if (*endptr != '\0')
4064 return false; /* appropriate hint, if any, already set */
4066 /* Check for overflow due to units conversion */
4067 if (val != (int64) ((int32) val))
4070 *hintmsg = gettext_noop("Value exceeds integer range.");
4076 *result = (int) val;
4083 * Try to parse value as a floating point number in the usual format.
4084 * If the string parses okay, return true, else false.
4085 * If okay and result is not NULL, return the value in *result.
4088 parse_real(const char *value, double *result)
4094 *result = 0; /* suppress compiler warning */
4097 val = strtod(value, &endptr);
4098 if (endptr == value || errno == ERANGE)
4101 /* allow whitespace after number */
4102 while (isspace((unsigned char) *endptr))
4104 if (*endptr != '\0')
4114 * Call a GucStringAssignHook function, being careful to free the
4115 * "newval" string if the hook ereports.
4117 * This is split out of set_config_option just to avoid the "volatile"
4118 * qualifiers that would otherwise have to be plastered all over.
4121 call_string_assign_hook(GucStringAssignHook assign_hook,
4122 char *newval, bool doit, GucSource source)
4128 result = (*assign_hook) (newval, doit, source);
4142 * Sets option `name' to given value. The value should be a string
4143 * which is going to be parsed and converted to the appropriate data
4144 * type. The context and source parameters indicate in which context this
4145 * function is being called so it can apply the access restrictions
4148 * If value is NULL, set the option to its default value. If the
4149 * parameter changeVal is false then don't really set the option but do all
4150 * the checks to see if it would work.
4152 * If there is an error (non-existing option, invalid value) then an
4153 * ereport(ERROR) is thrown *unless* this is called in a context where we
4154 * don't want to ereport (currently, startup or SIGHUP config file reread).
4155 * In that case we write a suitable error message via ereport(DEBUG) and
4156 * return false. This is working around the deficiencies in the ereport
4157 * mechanism, so don't blame me. In all other cases, the function
4158 * returns true, including cases where the input is valid but we chose
4159 * not to apply it because of context or source-priority considerations.
4161 * See also SetConfigOption for an external interface.
4164 set_config_option(const char *name, const char *value,
4165 GucContext context, GucSource source,
4166 bool isLocal, bool changeVal)
4168 struct config_generic *record;
4172 if (context == PGC_SIGHUP || source == PGC_S_DEFAULT)
4175 * To avoid cluttering the log, only the postmaster bleats loudly
4176 * about problems with the config file.
4178 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
4180 else if (source == PGC_S_DATABASE || source == PGC_S_USER)
4185 record = find_option(name, elevel);
4189 (errcode(ERRCODE_UNDEFINED_OBJECT),
4190 errmsg("unrecognized configuration parameter \"%s\"", name)));
4195 * Do not replace a value that has been set on the command line by a SIGHUP
4198 if (context == PGC_SIGHUP && record->source == PGC_S_ARGV)
4202 * Check if the option can be set at this time. See guc.h for the precise
4203 * rules. Note that we don't want to throw errors if we're in the SIGHUP
4204 * context. In that case we just ignore the attempt and return true.
4206 switch (record->context)
4209 if (context == PGC_SIGHUP)
4211 if (context != PGC_INTERNAL)
4214 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4215 errmsg("parameter \"%s\" cannot be changed",
4220 case PGC_POSTMASTER:
4221 if (context == PGC_SIGHUP)
4223 if (changeVal && !is_newvalue_equal(record, value))
4225 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4226 errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
4231 if (context != PGC_POSTMASTER)
4234 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4235 errmsg("parameter \"%s\" cannot be changed after server start",
4241 if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
4244 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4245 errmsg("parameter \"%s\" cannot be changed now",
4251 * Hmm, the idea of the SIGHUP context is "ought to be global, but
4252 * can be changed after postmaster start". But there's nothing
4253 * that prevents a crafty administrator from sending SIGHUP
4254 * signals to individual backends only.
4258 if (context == PGC_SIGHUP)
4261 * If a PGC_BACKEND parameter is changed in the config file,
4262 * we want to accept the new value in the postmaster (whence
4263 * it will propagate to subsequently-started backends), but
4264 * ignore it in existing backends. This is a tad klugy, but
4265 * necessary because we don't re-read the config file during
4268 if (IsUnderPostmaster)
4271 else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
4274 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4275 errmsg("parameter \"%s\" cannot be set after connection start",
4281 if (context == PGC_USERSET || context == PGC_BACKEND)
4284 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4285 errmsg("permission denied to set parameter \"%s\"",
4296 * Should we set reset/stacked values? (If so, the behavior is not
4297 * transactional.) This is done either when we get a default
4298 * value from the database's/user's/client's default settings or
4299 * when we reset a value to its default.
4301 makeDefault = changeVal && (source <= PGC_S_OVERRIDE)
4302 && ((value != NULL) || source == PGC_S_DEFAULT);
4305 * Ignore attempted set if overridden by previously processed
4306 * setting. However, if changeVal is false then plow ahead anyway
4307 * since we are trying to find out if the value is potentially
4308 * good, not actually use it. Also keep going if makeDefault is
4309 * true, since we may want to set the reset/stacked values even if
4310 * we can't set the variable itself. There's one exception to
4311 * this rule: if we want to apply the default value to variables
4312 * that were removed from the configuration file. This is
4313 * indicated by source == PGC_S_DEFAULT and context == PGC_SIGHUP.
4315 if (record->source > source
4316 && !(source == PGC_S_DEFAULT && context == PGC_SIGHUP))
4318 if (changeVal && !makeDefault)
4320 elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
4328 * Evaluate value and set variable.
4330 switch (record->vartype)
4334 struct config_bool *conf = (struct config_bool *) record;
4339 if (!parse_bool(value, &newval))
4342 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4343 errmsg("parameter \"%s\" requires a Boolean value",
4349 * If value == NULL and source == PGC_S_DEFAULT then
4350 * we reset some value to its default (removed from
4351 * configuration file).
4353 else if (source == PGC_S_DEFAULT)
4354 newval = conf->boot_val;
4355 /* else we handle a "RESET varname" command */
4358 newval = conf->reset_val;
4359 source = conf->gen.reset_source;
4362 if (conf->assign_hook)
4363 if (!(*conf->assign_hook) (newval, changeVal, source))
4366 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4367 errmsg("invalid value for parameter \"%s\": %d",
4368 name, (int) newval)));
4372 if (changeVal || makeDefault)
4374 /* Save old value to support transaction abort */
4376 push_old_value(&conf->gen);
4379 *conf->variable = newval;
4380 conf->gen.source = source;
4386 if (conf->gen.reset_source <= source)
4388 conf->reset_val = newval;
4389 conf->gen.reset_source = source;
4391 for (stack = conf->gen.stack; stack; stack = stack->prev)
4393 if (stack->source <= source)
4395 stack->value.boolval = newval;
4396 stack->source = source;
4402 conf->gen.status |= GUC_HAVE_LOCAL;
4407 conf->tentative_val = newval;
4408 conf->gen.tentative_source = source;
4409 conf->gen.status |= GUC_HAVE_TENTATIVE;
4418 struct config_int *conf = (struct config_int *) record;
4423 const char *hintmsg;
4425 if (!parse_int(value, &newval, conf->gen.flags, &hintmsg))
4428 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4429 errmsg("invalid value for parameter \"%s\": \"%s\"",
4431 hintmsg ? errhint(hintmsg) : 0));
4434 if (newval < conf->min || newval > conf->max)
4437 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4438 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
4439 newval, name, conf->min, conf->max)));
4444 * If value == NULL and source == PGC_S_DEFAULT then
4445 * we reset some value to its default (removed from
4446 * configuration file).
4448 else if (source == PGC_S_DEFAULT)
4449 newval = conf->boot_val;
4450 /* else we handle a "RESET varname" command */
4453 newval = conf->reset_val;
4454 source = conf->gen.reset_source;
4457 if (conf->assign_hook)
4458 if (!(*conf->assign_hook) (newval, changeVal, source))
4461 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4462 errmsg("invalid value for parameter \"%s\": %d",
4467 if (changeVal || makeDefault)
4469 /* Save old value to support transaction abort */
4471 push_old_value(&conf->gen);
4474 *conf->variable = newval;
4475 conf->gen.source = source;
4481 if (conf->gen.reset_source <= source)
4483 conf->reset_val = newval;
4484 conf->gen.reset_source = source;
4486 for (stack = conf->gen.stack; stack; stack = stack->prev)
4488 if (stack->source <= source)
4490 stack->value.intval = newval;
4491 stack->source = source;
4497 conf->gen.status |= GUC_HAVE_LOCAL;
4502 conf->tentative_val = newval;
4503 conf->gen.tentative_source = source;
4504 conf->gen.status |= GUC_HAVE_TENTATIVE;
4513 struct config_real *conf = (struct config_real *) record;
4518 if (!parse_real(value, &newval))
4521 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4522 errmsg("parameter \"%s\" requires a numeric value",
4526 if (newval < conf->min || newval > conf->max)
4529 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4530 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
4531 newval, name, conf->min, conf->max)));
4536 * If value == NULL and source == PGC_S_DEFAULT then
4537 * we reset some value to its default (removed from
4538 * configuration file).
4540 else if (source == PGC_S_DEFAULT)
4541 newval = conf->boot_val;
4542 /* else we handle a "RESET varname" command */
4545 newval = conf->reset_val;
4546 source = conf->gen.reset_source;
4549 if (conf->assign_hook)
4550 if (!(*conf->assign_hook) (newval, changeVal, source))
4553 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4554 errmsg("invalid value for parameter \"%s\": %g",
4559 if (changeVal || makeDefault)
4561 /* Save old value to support transaction abort */
4563 push_old_value(&conf->gen);
4566 *conf->variable = newval;
4567 conf->gen.source = source;
4573 if (conf->gen.reset_source <= source)
4575 conf->reset_val = newval;
4576 conf->gen.reset_source = source;
4578 for (stack = conf->gen.stack; stack; stack = stack->prev)
4580 if (stack->source <= source)
4582 stack->value.realval = newval;
4583 stack->source = source;
4589 conf->gen.status |= GUC_HAVE_LOCAL;
4594 conf->tentative_val = newval;
4595 conf->gen.tentative_source = source;
4596 conf->gen.status |= GUC_HAVE_TENTATIVE;
4605 struct config_string *conf = (struct config_string *) record;
4610 newval = guc_strdup(elevel, value);
4615 * The only sort of "parsing" check we need to do is apply
4616 * truncation if GUC_IS_NAME.
4618 if (conf->gen.flags & GUC_IS_NAME)
4619 truncate_identifier(newval, strlen(newval), true);
4622 * If value == NULL and source == PGC_S_DEFAULT then
4623 * we reset some value to its default (removed from
4624 * configuration file).
4626 else if (source == PGC_S_DEFAULT)
4628 if (conf->boot_val == NULL)
4632 newval = guc_strdup(elevel, conf->boot_val);
4637 /* else we handle a "RESET varname" command */
4638 else if (conf->reset_val)
4641 * We could possibly avoid strdup here, but easier to make
4642 * this case work the same as the normal assignment case.
4644 newval = guc_strdup(elevel, conf->reset_val);
4647 source = conf->gen.reset_source;
4651 /* Nothing to reset to, as yet; so do nothing */
4655 if (conf->assign_hook)
4657 const char *hookresult;
4660 * If the hook ereports, we have to make sure we free
4661 * newval, else it will be a permanent memory leak.
4663 hookresult = call_string_assign_hook(conf->assign_hook,
4667 if (hookresult == NULL)
4671 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4672 errmsg("invalid value for parameter \"%s\": \"%s\"",
4673 name, value ? value : "")));
4676 else if (hookresult != newval)
4681 * Having to cast away const here is annoying, but the
4682 * alternative is to declare assign_hooks as returning
4683 * char*, which would mean they'd have to cast away
4684 * const, or as both taking and returning char*, which
4685 * doesn't seem attractive either --- we don't want
4686 * them to scribble on the passed str.
4688 newval = (char *) hookresult;
4692 if (changeVal || makeDefault)
4694 /* Save old value to support transaction abort */
4696 push_old_value(&conf->gen);
4699 set_string_field(conf, conf->variable, newval);
4700 conf->gen.source = source;
4706 if (conf->gen.reset_source <= source)
4708 set_string_field(conf, &conf->reset_val, newval);
4709 conf->gen.reset_source = source;
4711 for (stack = conf->gen.stack; stack; stack = stack->prev)
4713 if (stack->source <= source)
4715 set_string_field(conf, &stack->value.stringval,
4717 stack->source = source;
4720 /* Perhaps we didn't install newval anywhere */
4721 if (!string_field_used(conf, newval))
4726 conf->gen.status |= GUC_HAVE_LOCAL;
4731 set_string_field(conf, &conf->tentative_val, newval);
4732 conf->gen.tentative_source = source;
4733 conf->gen.status |= GUC_HAVE_TENTATIVE;
4743 if (changeVal && (record->flags & GUC_REPORT))
4744 ReportGUCOption(record);
4751 * Set a config option to the given value. See also set_config_option,
4752 * this is just the wrapper to be called from outside GUC. NB: this
4753 * is used only for non-transactional operations.
4756 SetConfigOption(const char *name, const char *value,
4757 GucContext context, GucSource source)
4759 (void) set_config_option(name, value, context, source, false, true);
4765 * Fetch the current value of the option `name'. If the option doesn't exist,
4766 * throw an ereport and don't return.
4768 * The string is *not* allocated for modification and is really only
4769 * valid until the next call to configuration related functions.
4772 GetConfigOption(const char *name)
4774 struct config_generic *record;
4775 static char buffer[256];
4777 record = find_option(name, ERROR);
4780 (errcode(ERRCODE_UNDEFINED_OBJECT),
4781 errmsg("unrecognized configuration parameter \"%s\"", name)));
4782 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4784 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4785 errmsg("must be superuser to examine \"%s\"", name)));
4787 switch (record->vartype)
4790 return *((struct config_bool *) record)->variable ? "on" : "off";
4793 snprintf(buffer, sizeof(buffer), "%d",
4794 *((struct config_int *) record)->variable);
4798 snprintf(buffer, sizeof(buffer), "%g",
4799 *((struct config_real *) record)->variable);
4803 return *((struct config_string *) record)->variable;
4809 * Get the RESET value associated with the given option.
4812 GetConfigOptionResetString(const char *name)
4814 struct config_generic *record;
4815 static char buffer[256];
4817 record = find_option(name, ERROR);
4820 (errcode(ERRCODE_UNDEFINED_OBJECT),
4821 errmsg("unrecognized configuration parameter \"%s\"", name)));
4822 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4824 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4825 errmsg("must be superuser to examine \"%s\"", name)));
4827 switch (record->vartype)
4830 return ((struct config_bool *) record)->reset_val ? "on" : "off";
4833 snprintf(buffer, sizeof(buffer), "%d",
4834 ((struct config_int *) record)->reset_val);
4838 snprintf(buffer, sizeof(buffer), "%g",
4839 ((struct config_real *) record)->reset_val);
4843 return ((struct config_string *) record)->reset_val;
4849 * Detect whether the given configuration option can only be set by
4853 IsSuperuserConfigOption(const char *name)
4855 struct config_generic *record;
4857 record = find_option(name, ERROR);
4858 /* On an unrecognized name, don't error, just return false. */
4861 return (record->context == PGC_SUSET);
4866 * flatten_set_variable_args
4867 * Given a parsenode List as emitted by the grammar for SET,
4868 * convert to the flat string representation used by GUC.
4870 * We need to be told the name of the variable the args are for, because
4871 * the flattening rules vary (ugh).
4873 * The result is NULL if args is NIL (ie, SET ... TO DEFAULT), otherwise
4874 * a palloc'd string.
4877 flatten_set_variable_args(const char *name, List *args)
4879 struct config_generic *record;
4884 /* Fast path if just DEFAULT */
4888 /* Else get flags for the variable */
4889 record = find_option(name, ERROR);
4892 (errcode(ERRCODE_UNDEFINED_OBJECT),
4893 errmsg("unrecognized configuration parameter \"%s\"", name)));
4895 flags = record->flags;
4897 /* Complain if list input and non-list variable */
4898 if ((flags & GUC_LIST_INPUT) == 0 &&
4899 list_length(args) != 1)
4901 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4902 errmsg("SET %s takes only one argument", name)));
4904 initStringInfo(&buf);
4908 A_Const *arg = (A_Const *) lfirst(l);
4911 if (l != list_head(args))
4912 appendStringInfo(&buf, ", ");
4914 if (!IsA(arg, A_Const))
4915 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
4917 switch (nodeTag(&arg->val))
4920 appendStringInfo(&buf, "%ld", intVal(&arg->val));
4923 /* represented as a string, so just copy it */
4924 appendStringInfoString(&buf, strVal(&arg->val));
4927 val = strVal(&arg->val);
4928 if (arg->typename != NULL)
4931 * Must be a ConstInterval argument for TIME ZONE. Coerce
4932 * to interval and back to normalize the value and account
4939 typmod = typenameTypeMod(NULL, arg->typename, INTERVALOID);
4942 DirectFunctionCall3(interval_in,
4943 CStringGetDatum(val),
4944 ObjectIdGetDatum(InvalidOid),
4945 Int32GetDatum(typmod));
4948 DatumGetCString(DirectFunctionCall1(interval_out,
4950 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
4955 * Plain string literal or identifier. For quote mode,
4956 * quote it if it's not a vanilla identifier.
4958 if (flags & GUC_LIST_QUOTE)
4959 appendStringInfoString(&buf, quote_identifier(val));
4961 appendStringInfoString(&buf, val);
4965 elog(ERROR, "unrecognized node type: %d",
4966 (int) nodeTag(&arg->val));
4979 ExecSetVariableStmt(VariableSetStmt *stmt)
4984 case VAR_SET_CURRENT:
4985 set_config_option(stmt->name,
4986 ExtractSetVariableArgs(stmt),
4987 (superuser() ? PGC_SUSET : PGC_USERSET),
4994 * Special case for special SQL syntax that effectively sets
4995 * more than one variable per statement.
4997 if (strcmp(stmt->name, "TRANSACTION") == 0)
5001 foreach(head, stmt->args)
5003 DefElem *item = (DefElem *) lfirst(head);
5005 if (strcmp(item->defname, "transaction_isolation") == 0)
5006 SetPGVariable("transaction_isolation",
5007 list_make1(item->arg), stmt->is_local);
5008 else if (strcmp(item->defname, "transaction_read_only") == 0)
5009 SetPGVariable("transaction_read_only",
5010 list_make1(item->arg), stmt->is_local);
5012 elog(ERROR, "unexpected SET TRANSACTION element: %s",
5016 else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
5020 foreach(head, stmt->args)
5022 DefElem *item = (DefElem *) lfirst(head);
5024 if (strcmp(item->defname, "transaction_isolation") == 0)
5025 SetPGVariable("default_transaction_isolation",
5026 list_make1(item->arg), stmt->is_local);
5027 else if (strcmp(item->defname, "transaction_read_only") == 0)
5028 SetPGVariable("default_transaction_read_only",
5029 list_make1(item->arg), stmt->is_local);
5031 elog(ERROR, "unexpected SET SESSION element: %s",
5036 elog(ERROR, "unexpected SET MULTI element: %s",
5039 case VAR_SET_DEFAULT:
5041 set_config_option(stmt->name,
5043 (superuser() ? PGC_SUSET : PGC_USERSET),
5055 * Get the value to assign for a VariableSetStmt, or NULL if it's RESET.
5056 * The result is palloc'd.
5058 * This is exported for use by actions such as ALTER ROLE SET.
5061 ExtractSetVariableArgs(VariableSetStmt *stmt)
5066 return flatten_set_variable_args(stmt->name, stmt->args);
5067 case VAR_SET_CURRENT:
5068 return GetConfigOptionByName(stmt->name, NULL);
5075 * SetPGVariable - SET command exported as an easily-C-callable function.
5077 * This provides access to SET TO value, as well as SET TO DEFAULT (expressed
5078 * by passing args == NIL), but not SET FROM CURRENT functionality.
5081 SetPGVariable(const char *name, List *args, bool is_local)
5083 char *argstring = flatten_set_variable_args(name, args);
5085 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
5086 set_config_option(name,
5088 (superuser() ? PGC_SUSET : PGC_USERSET),
5095 * SET command wrapped as a SQL callable function.
5098 set_config_by_name(PG_FUNCTION_ARGS)
5106 if (PG_ARGISNULL(0))
5108 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
5109 errmsg("SET requires parameter name")));
5111 /* Get the GUC variable name */
5112 name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
5114 /* Get the desired value or set to NULL for a reset request */
5115 if (PG_ARGISNULL(1))
5118 value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
5121 * Get the desired state of is_local. Default to false if provided value
5124 if (PG_ARGISNULL(2))
5127 is_local = PG_GETARG_BOOL(2);
5129 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
5130 set_config_option(name,
5132 (superuser() ? PGC_SUSET : PGC_USERSET),
5137 /* get the new current value */
5138 new_value = GetConfigOptionByName(name, NULL);
5140 /* Convert return string to text */
5141 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
5144 PG_RETURN_TEXT_P(result_text);
5149 define_custom_variable(struct config_generic * variable)
5151 const char *name = variable->name;
5152 const char **nameAddr = &name;
5154 struct config_string *pHolder;
5155 struct config_generic **res = (struct config_generic **) bsearch(
5157 (void *) guc_variables,
5159 sizeof(struct config_generic *),
5164 add_guc_variable(variable, ERROR);
5169 * This better be a placeholder
5171 if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
5173 (errcode(ERRCODE_INTERNAL_ERROR),
5174 errmsg("attempt to redefine parameter \"%s\"", name)));
5176 Assert((*res)->vartype == PGC_STRING);
5177 pHolder = (struct config_string *) * res;
5179 /* We have the same name, no sorting is necessary */
5182 value = *pHolder->variable;
5185 * Assign the string value stored in the placeholder to the real variable.
5187 * XXX this is not really good enough --- it should be a nontransactional
5188 * assignment, since we don't want it to roll back if the current xact
5191 set_config_option(name, value,
5192 pHolder->gen.context, pHolder->gen.source,
5196 * Free up as much as we conveniently can of the placeholder structure
5197 * (this neglects any stack items...)
5199 set_string_field(pHolder, pHolder->variable, NULL);
5200 set_string_field(pHolder, &pHolder->reset_val, NULL);
5201 set_string_field(pHolder, &pHolder->tentative_val, NULL);
5207 init_custom_variable(struct config_generic * gen,
5209 const char *short_desc,
5210 const char *long_desc,
5212 enum config_type type)
5214 gen->name = guc_strdup(ERROR, name);
5215 gen->context = context;
5216 gen->group = CUSTOM_OPTIONS;
5217 gen->short_desc = short_desc;
5218 gen->long_desc = long_desc;
5219 gen->vartype = type;
5223 DefineCustomBoolVariable(const char *name,
5224 const char *short_desc,
5225 const char *long_desc,
5228 GucBoolAssignHook assign_hook,
5229 GucShowHook show_hook)
5231 size_t sz = sizeof(struct config_bool);
5232 struct config_bool *var = (struct config_bool *) guc_malloc(ERROR, sz);
5235 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_BOOL);
5237 var->variable = valueAddr;
5238 var->reset_val = *valueAddr;
5239 var->assign_hook = assign_hook;
5240 var->show_hook = show_hook;
5241 define_custom_variable(&var->gen);
5245 DefineCustomIntVariable(const char *name,
5246 const char *short_desc,
5247 const char *long_desc,
5252 GucIntAssignHook assign_hook,
5253 GucShowHook show_hook)
5255 size_t sz = sizeof(struct config_int);
5256 struct config_int *var = (struct config_int *) guc_malloc(ERROR, sz);
5259 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_INT);
5261 var->variable = valueAddr;
5262 var->reset_val = *valueAddr;
5263 var->min = minValue;
5264 var->max = maxValue;
5265 var->assign_hook = assign_hook;
5266 var->show_hook = show_hook;
5267 define_custom_variable(&var->gen);
5271 DefineCustomRealVariable(const char *name,
5272 const char *short_desc,
5273 const char *long_desc,
5278 GucRealAssignHook assign_hook,
5279 GucShowHook show_hook)
5281 size_t sz = sizeof(struct config_real);
5282 struct config_real *var = (struct config_real *) guc_malloc(ERROR, sz);
5285 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_REAL);
5287 var->variable = valueAddr;
5288 var->reset_val = *valueAddr;
5289 var->min = minValue;
5290 var->max = maxValue;
5291 var->assign_hook = assign_hook;
5292 var->show_hook = show_hook;
5293 define_custom_variable(&var->gen);
5297 DefineCustomStringVariable(const char *name,
5298 const char *short_desc,
5299 const char *long_desc,
5302 GucStringAssignHook assign_hook,
5303 GucShowHook show_hook)
5305 size_t sz = sizeof(struct config_string);
5306 struct config_string *var = (struct config_string *) guc_malloc(ERROR, sz);
5309 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_STRING);
5311 var->variable = valueAddr;
5312 var->reset_val = *valueAddr;
5313 var->assign_hook = assign_hook;
5314 var->show_hook = show_hook;
5315 define_custom_variable(&var->gen);
5319 EmitWarningsOnPlaceholders(const char *className)
5321 struct config_generic **vars = guc_variables;
5322 struct config_generic **last = vars + num_guc_variables;
5324 int nameLen = strlen(className);
5328 struct config_generic *var = *vars++;
5330 if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
5331 strncmp(className, var->name, nameLen) == 0 &&
5332 var->name[nameLen] == GUC_QUALIFIER_SEPARATOR)
5335 (errcode(ERRCODE_UNDEFINED_OBJECT),
5336 errmsg("unrecognized configuration parameter \"%s\"", var->name)));
5346 GetPGVariable(const char *name, DestReceiver *dest)
5348 if (pg_strcasecmp(name, "all") == 0)
5349 ShowAllGUCConfig(dest);
5351 ShowGUCConfigOption(name, dest);
5355 GetPGVariableResultDesc(const char *name)
5359 if (pg_strcasecmp(name, "all") == 0)
5361 /* need a tuple descriptor representing three TEXT columns */
5362 tupdesc = CreateTemplateTupleDesc(3, false);
5363 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
5365 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
5367 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
5373 const char *varname;
5375 /* Get the canonical spelling of name */
5376 (void) GetConfigOptionByName(name, &varname);
5378 /* need a tuple descriptor representing a single TEXT column */
5379 tupdesc = CreateTemplateTupleDesc(1, false);
5380 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
5391 ShowGUCConfigOption(const char *name, DestReceiver *dest)
5393 TupOutputState *tstate;
5395 const char *varname;
5398 /* Get the value and canonical spelling of name */
5399 value = GetConfigOptionByName(name, &varname);
5401 /* need a tuple descriptor representing a single TEXT column */
5402 tupdesc = CreateTemplateTupleDesc(1, false);
5403 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
5406 /* prepare for projection of tuples */
5407 tstate = begin_tup_output_tupdesc(dest, tupdesc);
5410 do_text_output_oneline(tstate, value);
5412 end_tup_output(tstate);
5419 ShowAllGUCConfig(DestReceiver *dest)
5421 bool am_superuser = superuser();
5423 TupOutputState *tstate;
5427 /* need a tuple descriptor representing three TEXT columns */
5428 tupdesc = CreateTemplateTupleDesc(3, false);
5429 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
5431 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
5433 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
5437 /* prepare for projection of tuples */
5438 tstate = begin_tup_output_tupdesc(dest, tupdesc);
5440 for (i = 0; i < num_guc_variables; i++)
5442 struct config_generic *conf = guc_variables[i];
5444 if ((conf->flags & GUC_NO_SHOW_ALL) ||
5445 ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
5448 /* assign to the values array */
5449 values[0] = (char *) conf->name;
5450 values[1] = _ShowOption(conf, true);
5451 values[2] = (char *) conf->short_desc;
5453 /* send it to dest */
5454 do_tup_output(tstate, values);
5457 if (values[1] != NULL)
5461 end_tup_output(tstate);
5465 * Return GUC variable value by name; optionally return canonical
5466 * form of name. Return value is palloc'd.
5469 GetConfigOptionByName(const char *name, const char **varname)
5471 struct config_generic *record;
5473 record = find_option(name, ERROR);
5476 (errcode(ERRCODE_UNDEFINED_OBJECT),
5477 errmsg("unrecognized configuration parameter \"%s\"", name)));
5478 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
5480 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5481 errmsg("must be superuser to examine \"%s\"", name)));
5484 *varname = record->name;
5486 return _ShowOption(record, true);
5490 * Return GUC variable value by variable number; optionally return canonical
5491 * form of name. Return value is palloc'd.
5494 GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
5497 struct config_generic *conf;
5499 /* check requested variable number valid */
5500 Assert((varnum >= 0) && (varnum < num_guc_variables));
5502 conf = guc_variables[varnum];
5506 if ((conf->flags & GUC_NO_SHOW_ALL) ||
5507 ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
5513 /* first get the generic attributes */
5516 values[0] = conf->name;
5518 /* setting : use _ShowOption in order to avoid duplicating the logic */
5519 values[1] = _ShowOption(conf, false);
5522 if (conf->vartype == PGC_INT)
5526 switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
5531 case GUC_UNIT_BLOCKS:
5532 snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
5535 case GUC_UNIT_XBLOCKS:
5536 snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
5557 values[3] = config_group_names[conf->group];
5560 values[4] = conf->short_desc;
5563 values[5] = conf->long_desc;
5566 values[6] = GucContext_Names[conf->context];
5569 values[7] = config_type_names[conf->vartype];
5572 values[8] = GucSource_Names[conf->source];
5574 /* now get the type specifc attributes */
5575 switch (conf->vartype)
5589 struct config_int *lconf = (struct config_int *) conf;
5592 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
5593 values[9] = pstrdup(buffer);
5596 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
5597 values[10] = pstrdup(buffer);
5603 struct config_real *lconf = (struct config_real *) conf;
5606 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
5607 values[9] = pstrdup(buffer);
5610 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
5611 values[10] = pstrdup(buffer);
5628 * should never get here, but in case we do, set 'em to NULL
5642 * Return the total number of GUC variables
5645 GetNumConfigOptions(void)
5647 return num_guc_variables;
5651 * show_config_by_name - equiv to SHOW X command but implemented as
5655 show_config_by_name(PG_FUNCTION_ARGS)
5661 /* Get the GUC variable name */
5662 varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
5665 varval = GetConfigOptionByName(varname, NULL);
5667 /* Convert to text */
5668 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));
5671 PG_RETURN_TEXT_P(result_text);
5675 * show_all_settings - equiv to SHOW ALL command but implemented as
5678 #define NUM_PG_SETTINGS_ATTS 11
5681 show_all_settings(PG_FUNCTION_ARGS)
5683 FuncCallContext *funcctx;
5687 AttInMetadata *attinmeta;
5688 MemoryContext oldcontext;
5690 /* stuff done only on the first call of the function */
5691 if (SRF_IS_FIRSTCALL())
5693 /* create a function context for cross-call persistence */
5694 funcctx = SRF_FIRSTCALL_INIT();
5697 * switch to memory context appropriate for multiple function calls
5699 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
5702 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
5703 * of the appropriate types
5705 tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
5706 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
5708 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
5710 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "unit",
5712 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "category",
5714 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "short_desc",
5716 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "extra_desc",
5718 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "context",
5720 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "vartype",
5722 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "source",
5724 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "min_val",
5726 TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val",
5730 * Generate attribute metadata needed later to produce tuples from raw
5733 attinmeta = TupleDescGetAttInMetadata(tupdesc);
5734 funcctx->attinmeta = attinmeta;
5736 /* total number of tuples to be returned */
5737 funcctx->max_calls = GetNumConfigOptions();
5739 MemoryContextSwitchTo(oldcontext);
5742 /* stuff done on every call of the function */
5743 funcctx = SRF_PERCALL_SETUP();
5745 call_cntr = funcctx->call_cntr;
5746 max_calls = funcctx->max_calls;
5747 attinmeta = funcctx->attinmeta;
5749 if (call_cntr < max_calls) /* do when there is more left to send */
5751 char *values[NUM_PG_SETTINGS_ATTS];
5757 * Get the next visible GUC variable name and value
5761 GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
5764 /* bump the counter and get the next config setting */
5765 call_cntr = ++funcctx->call_cntr;
5767 /* make sure we haven't gone too far now */
5768 if (call_cntr >= max_calls)
5769 SRF_RETURN_DONE(funcctx);
5774 tuple = BuildTupleFromCStrings(attinmeta, values);
5776 /* make the tuple into a datum */
5777 result = HeapTupleGetDatum(tuple);
5779 SRF_RETURN_NEXT(funcctx, result);
5783 /* do when there is no more left */
5784 SRF_RETURN_DONE(funcctx);
5789 _ShowOption(struct config_generic * record, bool use_units)
5794 switch (record->vartype)
5798 struct config_bool *conf = (struct config_bool *) record;
5800 if (conf->show_hook)
5801 val = (*conf->show_hook) ();
5803 val = *conf->variable ? "on" : "off";
5809 struct config_int *conf = (struct config_int *) record;
5811 if (conf->show_hook)
5812 val = (*conf->show_hook) ();
5816 int result = *conf->variable;
5818 if (use_units && result > 0 && (record->flags & GUC_UNIT_MEMORY))
5820 switch (record->flags & GUC_UNIT_MEMORY)
5822 case GUC_UNIT_BLOCKS:
5823 result *= BLCKSZ / 1024;
5825 case GUC_UNIT_XBLOCKS:
5826 result *= XLOG_BLCKSZ / 1024;
5830 if (result % KB_PER_GB == 0)
5832 result /= KB_PER_GB;
5835 else if (result % KB_PER_MB == 0)
5837 result /= KB_PER_MB;
5845 else if (use_units && result > 0 && (record->flags & GUC_UNIT_TIME))
5847 switch (record->flags & GUC_UNIT_TIME)
5853 result *= MS_PER_MIN;
5857 if (result % MS_PER_D == 0)
5862 else if (result % MS_PER_H == 0)
5867 else if (result % MS_PER_MIN == 0)
5869 result /= MS_PER_MIN;
5870 strcpy(unit, "min");
5872 else if (result % MS_PER_S == 0)
5885 snprintf(buffer, sizeof(buffer), "%d%s",
5886 (int) result, unit);
5894 struct config_real *conf = (struct config_real *) record;
5896 if (conf->show_hook)
5897 val = (*conf->show_hook) ();
5900 snprintf(buffer, sizeof(buffer), "%g",
5909 struct config_string *conf = (struct config_string *) record;
5911 if (conf->show_hook)
5912 val = (*conf->show_hook) ();
5913 else if (*conf->variable && **conf->variable)
5914 val = *conf->variable;
5921 /* just to keep compiler quiet */
5926 return pstrdup(val);
5931 is_newvalue_equal(struct config_generic * record, const char *newvalue)
5933 switch (record->vartype)
5937 struct config_bool *conf = (struct config_bool *) record;
5940 return parse_bool(newvalue, &newval)
5941 && *conf->variable == newval;
5945 struct config_int *conf = (struct config_int *) record;
5948 return parse_int(newvalue, &newval, record->flags, NULL)
5949 && *conf->variable == newval;
5953 struct config_real *conf = (struct config_real *) record;
5956 return parse_real(newvalue, &newval)
5957 && *conf->variable == newval;
5961 struct config_string *conf = (struct config_string *) record;
5963 return strcmp(*conf->variable, newvalue) == 0;
5974 * This routine dumps out all non-default GUC options into a binary
5975 * file that is read by all exec'ed backends. The format is:
5977 * variable name, string, null terminated
5978 * variable value, string, null terminated
5979 * variable source, integer
5982 write_nondefault_variables(GucContext context)
5988 Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
5990 elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
5995 fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
5999 (errcode_for_file_access(),
6000 errmsg("could not write to file \"%s\": %m",
6001 CONFIG_EXEC_PARAMS_NEW)));
6005 for (i = 0; i < num_guc_variables; i++)
6007 struct config_generic *gconf = guc_variables[i];
6009 if (gconf->source != PGC_S_DEFAULT)
6011 fprintf(fp, "%s", gconf->name);
6014 switch (gconf->vartype)
6018 struct config_bool *conf = (struct config_bool *) gconf;
6020 if (*conf->variable == 0)
6021 fprintf(fp, "false");
6023 fprintf(fp, "true");
6029 struct config_int *conf = (struct config_int *) gconf;
6031 fprintf(fp, "%d", *conf->variable);
6037 struct config_real *conf = (struct config_real *) gconf;
6039 /* Could lose precision here? */
6040 fprintf(fp, "%f", *conf->variable);
6046 struct config_string *conf = (struct config_string *) gconf;
6048 fprintf(fp, "%s", *conf->variable);
6055 fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
6062 (errcode_for_file_access(),
6063 errmsg("could not write to file \"%s\": %m",
6064 CONFIG_EXEC_PARAMS_NEW)));
6069 * Put new file in place. This could delay on Win32, but we don't hold
6070 * any exclusive locks.
6072 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
6077 * Read string, including null byte from file
6079 * Return NULL on EOF and nothing read
6082 read_string_with_null(FILE *fp)
6091 if ((ch = fgetc(fp)) == EOF)
6096 elog(FATAL, "invalid format of exec config params file");
6099 str = guc_malloc(FATAL, maxlen);
6100 else if (i == maxlen)
6101 str = guc_realloc(FATAL, str, maxlen *= 2);
6110 * This routine loads a previous postmaster dump of its non-default
6114 read_nondefault_variables(void)
6124 fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
6127 /* File not found is fine */
6128 if (errno != ENOENT)
6130 (errcode_for_file_access(),
6131 errmsg("could not read from file \"%s\": %m",
6132 CONFIG_EXEC_PARAMS)));
6138 struct config_generic *record;
6140 if ((varname = read_string_with_null(fp)) == NULL)
6143 if ((record = find_option(varname, FATAL)) == NULL)
6144 elog(FATAL, "failed to locate variable %s in exec config params file", varname);
6145 if ((varvalue = read_string_with_null(fp)) == NULL)
6146 elog(FATAL, "invalid format of exec config params file");
6147 if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
6148 elog(FATAL, "invalid format of exec config params file");
6150 (void) set_config_option(varname, varvalue, record->context,
6151 varsource, false, true);
6158 #endif /* EXEC_BACKEND */
6162 * A little "long argument" simulation, although not quite GNU
6163 * compliant. Takes a string of the form "some-option=some value" and
6164 * returns name = "some_option" and value = "some value" in malloc'ed
6165 * storage. Note that '-' is converted to '_' in the option name. If
6166 * there is no '=' in the input string then value will be NULL.
6169 ParseLongOption(const char *string, char **name, char **value)
6178 equal_pos = strcspn(string, "=");
6180 if (string[equal_pos] == '=')
6182 *name = guc_malloc(FATAL, equal_pos + 1);
6183 strlcpy(*name, string, equal_pos + 1);
6185 *value = guc_strdup(FATAL, &string[equal_pos + 1]);
6189 /* no equal sign in string */
6190 *name = guc_strdup(FATAL, string);
6194 for (cp = *name; *cp; cp++)
6201 * Handle options fetched from pg_database.datconfig, pg_authid.rolconfig,
6202 * pg_proc.proconfig, etc. Caller must specify proper context/source/local.
6204 * The array parameter must be an array of TEXT (it must not be NULL).
6207 ProcessGUCArray(ArrayType *array,
6208 GucContext context, GucSource source, bool isLocal)
6212 Assert(array != NULL);
6213 Assert(ARR_ELEMTYPE(array) == TEXTOID);
6214 Assert(ARR_NDIM(array) == 1);
6215 Assert(ARR_LBOUND(array)[0] == 1);
6217 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6225 d = array_ref(array, 1, &i,
6226 -1 /* varlenarray */ ,
6227 -1 /* TEXT's typlen */ ,
6228 false /* TEXT's typbyval */ ,
6229 'i' /* TEXT's typalign */ ,
6235 s = DatumGetCString(DirectFunctionCall1(textout, d));
6237 ParseLongOption(s, &name, &value);
6241 (errcode(ERRCODE_SYNTAX_ERROR),
6242 errmsg("could not parse setting for parameter \"%s\"",
6248 (void) set_config_option(name, value, context, source, isLocal, true);
6258 * Add an entry to an option array. The array parameter may be NULL
6259 * to indicate the current table entry is NULL.
6262 GUCArrayAdd(ArrayType *array, const char *name, const char *value)
6264 const char *varname;
6272 /* test if the option is valid */
6273 set_config_option(name, value,
6274 superuser() ? PGC_SUSET : PGC_USERSET,
6275 PGC_S_TEST, false, false);
6277 /* convert name to canonical spelling, so we can use plain strcmp */
6278 (void) GetConfigOptionByName(name, &varname);
6281 newval = palloc(strlen(name) + 1 + strlen(value) + 1);
6282 sprintf(newval, "%s=%s", name, value);
6283 datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
6291 Assert(ARR_ELEMTYPE(array) == TEXTOID);
6292 Assert(ARR_NDIM(array) == 1);
6293 Assert(ARR_LBOUND(array)[0] == 1);
6295 index = ARR_DIMS(array)[0] + 1; /* add after end */
6297 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6302 d = array_ref(array, 1, &i,
6303 -1 /* varlenarray */ ,
6304 -1 /* TEXT's typlen */ ,
6305 false /* TEXT's typbyval */ ,
6306 'i' /* TEXT's typalign */ ,
6310 current = DatumGetCString(DirectFunctionCall1(textout, d));
6311 if (strncmp(current, newval, strlen(name) + 1) == 0)
6318 a = array_set(array, 1, &index,
6321 -1 /* varlena array */ ,
6322 -1 /* TEXT's typlen */ ,
6323 false /* TEXT's typbyval */ ,
6324 'i' /* TEXT's typalign */ );
6327 a = construct_array(&datum, 1,
6336 * Delete an entry from an option array. The array parameter may be NULL
6337 * to indicate the current table entry is NULL. Also, if the return value
6338 * is NULL then a null should be stored.
6341 GUCArrayDelete(ArrayType *array, const char *name)
6343 const char *varname;
6344 ArrayType *newarray;
6350 /* test if the option is valid */
6351 set_config_option(name, NULL,
6352 superuser() ? PGC_SUSET : PGC_USERSET,
6353 PGC_S_TEST, false, false);
6355 /* convert name to canonical spelling, so we can use plain strcmp */
6356 (void) GetConfigOptionByName(name, &varname);
6359 /* if array is currently null, then surely nothing to delete */
6366 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6372 d = array_ref(array, 1, &i,
6373 -1 /* varlenarray */ ,
6374 -1 /* TEXT's typlen */ ,
6375 false /* TEXT's typbyval */ ,
6376 'i' /* TEXT's typalign */ ,
6380 val = DatumGetCString(DirectFunctionCall1(textout, d));
6382 /* ignore entry if it's what we want to delete */
6383 if (strncmp(val, name, strlen(name)) == 0
6384 && val[strlen(name)] == '=')
6387 /* else add it to the output array */
6390 newarray = array_set(newarray, 1, &index,
6393 -1 /* varlenarray */ ,
6394 -1 /* TEXT's typlen */ ,
6395 false /* TEXT's typbyval */ ,
6396 'i' /* TEXT's typalign */ );
6399 newarray = construct_array(&d, 1,
6411 * assign_hook subroutines
6415 assign_log_destination(const char *value, bool doit, GucSource source)
6422 /* Need a modifiable copy of string */
6423 rawstring = pstrdup(value);
6425 /* Parse string into list of identifiers */
6426 if (!SplitIdentifierString(rawstring, ',', &elemlist))
6428 /* syntax error in list */
6430 list_free(elemlist);
6431 if (source >= PGC_S_INTERACTIVE)
6433 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6434 errmsg("invalid list syntax for parameter \"log_destination\"")));
6438 foreach(l, elemlist)
6440 char *tok = (char *) lfirst(l);
6442 if (pg_strcasecmp(tok, "stderr") == 0)
6443 newlogdest |= LOG_DESTINATION_STDERR;
6444 else if (pg_strcasecmp(tok, "csvlog") == 0)
6445 newlogdest |= LOG_DESTINATION_CSVLOG;
6447 else if (pg_strcasecmp(tok, "syslog") == 0)
6448 newlogdest |= LOG_DESTINATION_SYSLOG;
6451 else if (pg_strcasecmp(tok, "eventlog") == 0)
6452 newlogdest |= LOG_DESTINATION_EVENTLOG;
6456 if (source >= PGC_S_INTERACTIVE)
6458 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6459 errmsg("unrecognized \"log_destination\" key word: \"%s\"",
6462 list_free(elemlist);
6468 Log_destination = newlogdest;
6471 list_free(elemlist);
6479 assign_syslog_facility(const char *facility, bool doit, GucSource source)
6483 if (pg_strcasecmp(facility, "LOCAL0") == 0)
6484 syslog_fac = LOG_LOCAL0;
6485 else if (pg_strcasecmp(facility, "LOCAL1") == 0)
6486 syslog_fac = LOG_LOCAL1;
6487 else if (pg_strcasecmp(facility, "LOCAL2") == 0)
6488 syslog_fac = LOG_LOCAL2;
6489 else if (pg_strcasecmp(facility, "LOCAL3") == 0)
6490 syslog_fac = LOG_LOCAL3;
6491 else if (pg_strcasecmp(facility, "LOCAL4") == 0)
6492 syslog_fac = LOG_LOCAL4;
6493 else if (pg_strcasecmp(facility, "LOCAL5") == 0)
6494 syslog_fac = LOG_LOCAL5;
6495 else if (pg_strcasecmp(facility, "LOCAL6") == 0)
6496 syslog_fac = LOG_LOCAL6;
6497 else if (pg_strcasecmp(facility, "LOCAL7") == 0)
6498 syslog_fac = LOG_LOCAL7;
6500 return NULL; /* reject */
6504 syslog_facility = syslog_fac;
6505 set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
6513 assign_syslog_ident(const char *ident, bool doit, GucSource source)
6516 set_syslog_parameters(ident, syslog_facility);
6520 #endif /* HAVE_SYSLOG */
6524 assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
6526 if (pg_strcasecmp(newval, "serializable") == 0)
6529 DefaultXactIsoLevel = XACT_SERIALIZABLE;
6531 else if (pg_strcasecmp(newval, "repeatable read") == 0)
6534 DefaultXactIsoLevel = XACT_REPEATABLE_READ;
6536 else if (pg_strcasecmp(newval, "read committed") == 0)
6539 DefaultXactIsoLevel = XACT_READ_COMMITTED;
6541 else if (pg_strcasecmp(newval, "read uncommitted") == 0)
6544 DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
6552 assign_session_replication_role(const char *newval, bool doit, GucSource source)
6556 if (pg_strcasecmp(newval, "origin") == 0)
6557 newrole = SESSION_REPLICATION_ROLE_ORIGIN;
6558 else if (pg_strcasecmp(newval, "replica") == 0)
6559 newrole = SESSION_REPLICATION_ROLE_REPLICA;
6560 else if (pg_strcasecmp(newval, "local") == 0)
6561 newrole = SESSION_REPLICATION_ROLE_LOCAL;
6566 * Must flush the plan cache when changing replication role; but don't
6567 * flush unnecessarily.
6569 if (doit && SessionReplicationRole != newrole)
6572 SessionReplicationRole = newrole;
6579 assign_log_min_messages(const char *newval,
6580 bool doit, GucSource source)
6582 return (assign_msglvl(&log_min_messages, newval, doit, source));
6586 assign_client_min_messages(const char *newval, bool doit, GucSource source)
6588 return (assign_msglvl(&client_min_messages, newval, doit, source));
6592 assign_min_error_statement(const char *newval, bool doit, GucSource source)
6594 return (assign_msglvl(&log_min_error_statement, newval, doit, source));
6598 assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
6600 if (pg_strcasecmp(newval, "debug") == 0)
6605 else if (pg_strcasecmp(newval, "debug5") == 0)
6610 else if (pg_strcasecmp(newval, "debug4") == 0)
6615 else if (pg_strcasecmp(newval, "debug3") == 0)
6620 else if (pg_strcasecmp(newval, "debug2") == 0)
6625 else if (pg_strcasecmp(newval, "debug1") == 0)
6630 else if (pg_strcasecmp(newval, "log") == 0)
6637 * Client_min_messages always prints 'info', but we allow it as a value
6640 else if (pg_strcasecmp(newval, "info") == 0)
6645 else if (pg_strcasecmp(newval, "notice") == 0)
6650 else if (pg_strcasecmp(newval, "warning") == 0)
6655 else if (pg_strcasecmp(newval, "error") == 0)
6660 /* We allow FATAL/PANIC for client-side messages too. */
6661 else if (pg_strcasecmp(newval, "fatal") == 0)
6666 else if (pg_strcasecmp(newval, "panic") == 0)
6672 return NULL; /* fail */
6673 return newval; /* OK */
6677 assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
6679 if (pg_strcasecmp(newval, "terse") == 0)
6682 Log_error_verbosity = PGERROR_TERSE;
6684 else if (pg_strcasecmp(newval, "default") == 0)
6687 Log_error_verbosity = PGERROR_DEFAULT;
6689 else if (pg_strcasecmp(newval, "verbose") == 0)
6692 Log_error_verbosity = PGERROR_VERBOSE;
6695 return NULL; /* fail */
6696 return newval; /* OK */
6700 assign_log_statement(const char *newval, bool doit, GucSource source)
6702 if (pg_strcasecmp(newval, "none") == 0)
6705 log_statement = LOGSTMT_NONE;
6707 else if (pg_strcasecmp(newval, "ddl") == 0)
6710 log_statement = LOGSTMT_DDL;
6712 else if (pg_strcasecmp(newval, "mod") == 0)
6715 log_statement = LOGSTMT_MOD;
6717 else if (pg_strcasecmp(newval, "all") == 0)
6720 log_statement = LOGSTMT_ALL;
6723 return NULL; /* fail */
6724 return newval; /* OK */
6728 show_num_temp_buffers(void)
6731 * We show the GUC var until local buffers have been initialized, and
6732 * NLocBuffer afterwards.
6734 static char nbuf[32];
6736 sprintf(nbuf, "%d", NLocBuffer ? NLocBuffer : num_temp_buffers);
6741 assign_phony_autocommit(bool newval, bool doit, GucSource source)
6745 if (doit && source >= PGC_S_INTERACTIVE)
6747 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6748 errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
6755 assign_custom_variable_classes(const char *newval, bool doit, GucSource source)
6758 * Check syntax. newval must be a comma separated list of identifiers.
6759 * Whitespace is allowed but skipped.
6761 bool hasSpaceAfterToken = false;
6762 const char *cp = newval;
6768 * Resetting custom_variable_classes by removing it from the
6769 * configuration file will lead to newval = NULL
6772 return guc_strdup(ERROR, "");
6774 initStringInfo(&buf);
6775 while ((c = *cp++) != 0)
6777 if (isspace((unsigned char) c))
6780 hasSpaceAfterToken = true;
6786 hasSpaceAfterToken = false;
6790 appendStringInfoChar(&buf, ',');
6795 if (hasSpaceAfterToken || !isalnum((unsigned char) c))
6798 * Syntax error due to token following space after token or non
6799 * alpha numeric character
6802 (errcode(ERRCODE_SYNTAX_ERROR),
6803 errmsg("invalid syntax for \"custom_variable_classes\": \"%s\"", newval)));
6808 appendStringInfoChar(&buf, (char) c);
6811 /* Remove stray ',' at end */
6812 if (symLen == 0 && buf.len > 0)
6813 buf.data[--buf.len] = '\0';
6818 newval = guc_strdup(ERROR, buf.data);
6825 assign_debug_assertions(bool newval, bool doit, GucSource source)
6827 #ifndef USE_ASSERT_CHECKING
6830 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6831 errmsg("assertion checking is not supported by this build")));
6837 assign_ssl(bool newval, bool doit, GucSource source)
6842 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6843 errmsg("SSL is not supported by this build")));
6849 assign_stage_log_stats(bool newval, bool doit, GucSource source)
6851 if (newval && log_statement_stats)
6853 if (source >= PGC_S_INTERACTIVE)
6855 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6856 errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
6857 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6858 else if (source != PGC_S_OVERRIDE)
6865 assign_log_stats(bool newval, bool doit, GucSource source)
6868 (log_parser_stats || log_planner_stats || log_executor_stats))
6870 if (source >= PGC_S_INTERACTIVE)
6872 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6873 errmsg("cannot enable \"log_statement_stats\" when "
6874 "\"log_parser_stats\", \"log_planner_stats\", "
6875 "or \"log_executor_stats\" is true")));
6876 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6877 else if (source != PGC_S_OVERRIDE)
6884 assign_transaction_read_only(bool newval, bool doit, GucSource source)
6886 /* Can't go to r/w mode inside a r/o transaction */
6887 if (newval == false && XactReadOnly && IsSubTransaction())
6889 if (source >= PGC_S_INTERACTIVE)
6891 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6892 errmsg("cannot set transaction read-write mode inside a read-only transaction")));
6893 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6894 else if (source != PGC_S_OVERRIDE)
6901 assign_canonical_path(const char *newval, bool doit, GucSource source)
6905 char *canon_val = guc_strdup(ERROR, newval);
6907 canonicalize_path(canon_val);
6915 assign_backslash_quote(const char *newval, bool doit, GucSource source)
6917 BackslashQuoteType bq;
6921 * Although only "on", "off", and "safe_encoding" are documented, we use
6922 * parse_bool so we can accept all the likely variants of "on" and "off".
6924 if (pg_strcasecmp(newval, "safe_encoding") == 0)
6925 bq = BACKSLASH_QUOTE_SAFE_ENCODING;
6926 else if (parse_bool(newval, &bqbool))
6928 bq = bqbool ? BACKSLASH_QUOTE_ON : BACKSLASH_QUOTE_OFF;
6931 return NULL; /* reject */
6934 backslash_quote = bq;
6940 assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
6943 * The powerup value shown above for timezone_abbreviations is "UNKNOWN".
6944 * When we see this we just do nothing. If this value isn't overridden
6945 * from the config file then pg_timezone_abbrev_initialize() will
6946 * eventually replace it with "Default". This hack has two purposes: to
6947 * avoid wasting cycles loading values that might soon be overridden from
6948 * the config file, and to avoid trying to read the timezone abbrev files
6949 * during InitializeGUCOptions(). The latter doesn't work in an
6950 * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
6951 * we can't locate PGSHAREDIR. (Essentially the same hack is used to
6952 * delay initializing TimeZone ... if we have any more, we should try to
6953 * clean up and centralize this mechanism ...)
6955 if (strcmp(newval, "UNKNOWN") == 0)
6960 /* Loading abbrev file is expensive, so only do it when value changes */
6961 if (timezone_abbreviations_string == NULL ||
6962 strcmp(timezone_abbreviations_string, newval) != 0)
6967 * If reading config file, only the postmaster should bleat loudly
6968 * about problems. Otherwise, it's just this one process doing it,
6969 * and we use WARNING message level.
6971 if (source == PGC_S_FILE)
6972 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
6975 if (!load_tzoffsets(newval, doit, elevel))
6982 * pg_timezone_abbrev_initialize --- set default value if not done already
6984 * This is called after initial loading of postgresql.conf. If no
6985 * timezone_abbreviations setting was found therein, select default.
6988 pg_timezone_abbrev_initialize(void)
6990 if (strcmp(timezone_abbreviations_string, "UNKNOWN") == 0)
6992 SetConfigOption("timezone_abbreviations", "Default",
6993 PGC_POSTMASTER, PGC_S_ARGV);
6998 assign_xmlbinary(const char *newval, bool doit, GucSource source)
7002 if (pg_strcasecmp(newval, "base64") == 0)
7003 xb = XMLBINARY_BASE64;
7004 else if (pg_strcasecmp(newval, "hex") == 0)
7007 return NULL; /* reject */
7016 assign_xmloption(const char *newval, bool doit, GucSource source)
7020 if (pg_strcasecmp(newval, "document") == 0)
7021 xo = XMLOPTION_DOCUMENT;
7022 else if (pg_strcasecmp(newval, "content") == 0)
7023 xo = XMLOPTION_CONTENT;
7025 return NULL; /* reject */
7034 assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
7037 return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
7043 show_tcp_keepalives_idle(void)
7045 static char nbuf[16];
7047 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
7052 assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
7055 return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
7061 show_tcp_keepalives_interval(void)
7063 static char nbuf[16];
7065 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
7070 assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
7073 return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
7079 show_tcp_keepalives_count(void)
7081 static char nbuf[16];
7083 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
7088 assign_maxconnections(int newval, bool doit, GucSource source)
7090 if (newval + autovacuum_max_workers > INT_MAX / 4)
7094 MaxBackends = newval + autovacuum_max_workers;
7100 assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
7102 if (newval + MaxConnections > INT_MAX / 4)
7106 MaxBackends = newval + MaxConnections;
7111 #include "guc-file.c"