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-2008, PostgreSQL Global Development Group
10 * Written by Peter Eisentraut <peter_e@gmx.net>.
13 * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.458 2008/06/30 22:10:43 momjian 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 "regex/regex.h"
58 #include "storage/bufmgr.h"
59 #include "storage/fd.h"
60 #include "storage/freespace.h"
61 #include "tcop/tcopprot.h"
62 #include "tsearch/ts_cache.h"
63 #include "utils/builtins.h"
64 #include "utils/guc_tables.h"
65 #include "utils/memutils.h"
66 #include "utils/pg_locale.h"
67 #include "utils/plancache.h"
68 #include "utils/portal.h"
69 #include "utils/ps_status.h"
70 #include "utils/tzparser.h"
71 #include "utils/xml.h"
74 #define PG_KRB_SRVTAB ""
77 #define PG_KRB_SRVNAM ""
80 #define CONFIG_FILENAME "postgresql.conf"
81 #define HBA_FILENAME "pg_hba.conf"
82 #define IDENT_FILENAME "pg_ident.conf"
85 #define CONFIG_EXEC_PARAMS "global/config_exec_params"
86 #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
89 /* upper limit for GUC variables measured in kilobytes of memory */
91 #define MAX_KILOBYTES INT_MAX
93 #define MAX_KILOBYTES (INT_MAX / 1024)
96 #define KB_PER_MB (1024)
97 #define KB_PER_GB (1024*1024)
101 #define MS_PER_MIN (1000 * 60)
103 #define S_PER_H (60 * 60)
104 #define MS_PER_H (1000 * 60 * 60)
105 #define MIN_PER_D (60 * 24)
106 #define S_PER_D (60 * 60 * 24)
107 #define MS_PER_D (1000 * 60 * 60 * 24)
109 /* XXX these should appear in other modules' header files */
110 extern bool Log_disconnections;
111 extern int CommitDelay;
112 extern int CommitSiblings;
113 extern char *default_tablespace;
114 extern char *temp_tablespaces;
115 extern bool synchronize_seqscans;
116 extern bool fullPageWrites;
119 extern bool trace_sort;
121 #ifdef TRACE_SYNCSCAN
122 extern bool trace_syncscan;
124 #ifdef DEBUG_BOUNDED_SORT
125 extern bool optimize_bounded_sort;
129 extern char *SSLCipherSuites;
133 static const char *assign_log_destination(const char *value,
134 bool doit, GucSource source);
137 static int syslog_facility = LOG_LOCAL0;
139 static bool assign_syslog_facility(int newval,
140 bool doit, GucSource source);
141 static const char *assign_syslog_ident(const char *ident,
142 bool doit, GucSource source);
145 static bool assign_session_replication_role(int newval, bool doit,
147 static const char *show_num_temp_buffers(void);
148 static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
149 static const char *assign_custom_variable_classes(const char *newval, bool doit,
151 static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
152 static bool assign_ssl(bool newval, bool doit, GucSource source);
153 static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
154 static bool assign_log_stats(bool newval, bool doit, GucSource source);
155 static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
156 static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
157 static const char *assign_timezone_abbreviations(const char *newval, bool doit, GucSource source);
158 static const char *show_archive_command(void);
159 static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
160 static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);
161 static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source);
162 static const char *show_tcp_keepalives_idle(void);
163 static const char *show_tcp_keepalives_interval(void);
164 static const char *show_tcp_keepalives_count(void);
165 static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);
166 static bool assign_maxconnections(int newval, bool doit, GucSource source);
168 static char *config_enum_get_options(struct config_enum *record,
169 const char *prefix, const char *suffix);
173 * Options for enum values defined in this module.
175 static const struct config_enum_entry message_level_options[] = {
176 {"debug", DEBUG2, false},
177 {"debug5", DEBUG5, false},
178 {"debug4", DEBUG4, false},
179 {"debug3", DEBUG3, false},
180 {"debug2", DEBUG2, false},
181 {"debug1", DEBUG1, false},
183 {"info", INFO, false},
184 {"notice", NOTICE, false},
185 {"warning", WARNING, false},
186 {"error", ERROR, false},
187 {"fatal", FATAL, false},
188 {"panic", PANIC, false},
192 static const struct config_enum_entry log_error_verbosity_options[] = {
193 {"default", PGERROR_DEFAULT, false},
194 {"terse", PGERROR_TERSE, false},
195 {"verbose", PGERROR_VERBOSE, false},
199 static const struct config_enum_entry log_statement_options[] = {
200 {"none", LOGSTMT_NONE, false},
201 {"ddl", LOGSTMT_DDL, false},
202 {"mod", LOGSTMT_MOD, false},
203 {"all", LOGSTMT_ALL, false},
207 static const struct config_enum_entry regex_flavor_options[] = {
208 {"advanced", REG_ADVANCED, false},
209 {"extended", REG_EXTENDED, false},
210 {"basic", REG_BASIC, false},
214 static const struct config_enum_entry isolation_level_options[] = {
215 {"serializable", XACT_SERIALIZABLE, false},
216 {"repeatable read", XACT_REPEATABLE_READ, false},
217 {"read committed", XACT_READ_COMMITTED, false},
218 {"read uncommitted", XACT_READ_UNCOMMITTED, false},
222 static const struct config_enum_entry session_replication_role_options[] = {
223 {"origin", SESSION_REPLICATION_ROLE_ORIGIN, false},
224 {"replica", SESSION_REPLICATION_ROLE_REPLICA, false},
225 {"local", SESSION_REPLICATION_ROLE_LOCAL, false},
230 static const struct config_enum_entry syslog_facility_options[] = {
231 {"local0", LOG_LOCAL0, false},
232 {"local1", LOG_LOCAL1, false},
233 {"local2", LOG_LOCAL2, false},
234 {"local3", LOG_LOCAL3, false},
235 {"local4", LOG_LOCAL4, false},
236 {"local5", LOG_LOCAL5, false},
237 {"local6", LOG_LOCAL6, false},
238 {"local7", LOG_LOCAL7, false},
243 static const struct config_enum_entry track_function_options[] = {
244 {"none", TRACK_FUNC_OFF, false},
245 {"pl", TRACK_FUNC_PL, false},
246 {"all", TRACK_FUNC_ALL, false},
250 static const struct config_enum_entry xmlbinary_options[] = {
251 {"base64", XMLBINARY_BASE64, false},
252 {"hex", XMLBINARY_HEX, false},
256 static const struct config_enum_entry xmloption_options[] = {
257 {"content", XMLOPTION_CONTENT, false},
258 {"document", XMLOPTION_DOCUMENT, false},
263 * Although only "on", "off", and "safe_encoding" are documented, we
264 * accept all the likely variants of "on" and "off".
266 static const struct config_enum_entry backslash_quote_options[] = {
267 {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING, false},
268 {"on", BACKSLASH_QUOTE_ON, false},
269 {"off", BACKSLASH_QUOTE_OFF, false},
270 {"true", BACKSLASH_QUOTE_ON, true},
271 {"false", BACKSLASH_QUOTE_OFF, true},
272 {"yes", BACKSLASH_QUOTE_ON, true},
273 {"no", BACKSLASH_QUOTE_OFF, true},
274 {"1", BACKSLASH_QUOTE_ON, true},
275 {"0", BACKSLASH_QUOTE_OFF, true},
280 * Options for enum values stored in other modules
282 extern const struct config_enum_entry sync_method_options[];
285 * GUC option variables that are exported from this module
287 #ifdef USE_ASSERT_CHECKING
288 bool assert_enabled = true;
290 bool assert_enabled = false;
292 bool log_duration = false;
293 bool Debug_print_plan = false;
294 bool Debug_print_parse = false;
295 bool Debug_print_rewritten = false;
296 bool Debug_pretty_print = false;
298 bool log_parser_stats = false;
299 bool log_planner_stats = false;
300 bool log_executor_stats = false;
301 bool log_statement_stats = false; /* this is sort of all three
303 bool log_btree_build_stats = false;
305 bool check_function_bodies = true;
306 bool default_with_oids = false;
307 bool SQL_inheritance = true;
309 bool Password_encryption = true;
311 int log_min_error_statement = ERROR;
312 int log_min_messages = WARNING;
313 int client_min_messages = NOTICE;
314 int log_min_duration_statement = -1;
315 int log_temp_files = -1;
317 int num_temp_buffers = 1000;
319 char *ConfigFileName;
322 char *external_pid_file;
324 int tcp_keepalives_idle;
325 int tcp_keepalives_interval;
326 int tcp_keepalives_count;
329 * These variables are all dummies that don't do anything, except in some
330 * cases provide the value for SHOW to display. The real state is elsewhere
331 * and is kept in sync by assign_hooks.
333 static char *log_destination_string;
336 static char *syslog_ident_str;
338 static bool phony_autocommit;
339 static bool session_auth_is_superuser;
340 static double phony_random_seed;
341 static char *client_encoding_string;
342 static char *datestyle_string;
343 static char *locale_collate;
344 static char *locale_ctype;
345 static char *server_encoding_string;
346 static char *server_version_string;
347 static int server_version_num;
348 static char *timezone_string;
349 static char *log_timezone_string;
350 static char *timezone_abbreviations_string;
351 static char *XactIsoLevel_string;
352 static char *data_directory;
353 static char *custom_variable_classes;
354 static int max_function_args;
355 static int max_index_keys;
356 static int max_identifier_length;
357 static int block_size;
358 static bool integer_datetimes;
360 /* should be static, but commands/variable.c needs to get at these */
362 char *session_authorization_string;
366 * Displayable names for context types (enum GucContext)
368 * Note: these strings are deliberately not localized.
370 const char *const GucContext_Names[] =
372 /* PGC_INTERNAL */ "internal",
373 /* PGC_POSTMASTER */ "postmaster",
374 /* PGC_SIGHUP */ "sighup",
375 /* PGC_BACKEND */ "backend",
376 /* PGC_SUSET */ "superuser",
377 /* PGC_USERSET */ "user"
381 * Displayable names for source types (enum GucSource)
383 * Note: these strings are deliberately not localized.
385 const char *const GucSource_Names[] =
387 /* PGC_S_DEFAULT */ "default",
388 /* PGC_S_ENV_VAR */ "environment variable",
389 /* PGC_S_FILE */ "configuration file",
390 /* PGC_S_ARGV */ "command line",
391 /* PGC_S_DATABASE */ "database",
392 /* PGC_S_USER */ "user",
393 /* PGC_S_CLIENT */ "client",
394 /* PGC_S_OVERRIDE */ "override",
395 /* PGC_S_INTERACTIVE */ "interactive",
396 /* PGC_S_TEST */ "test",
397 /* PGC_S_SESSION */ "session"
401 * Displayable names for the groupings defined in enum config_group
403 const char *const config_group_names[] =
406 gettext_noop("Ungrouped"),
408 gettext_noop("File Locations"),
410 gettext_noop("Connections and Authentication"),
411 /* CONN_AUTH_SETTINGS */
412 gettext_noop("Connections and Authentication / Connection Settings"),
413 /* CONN_AUTH_SECURITY */
414 gettext_noop("Connections and Authentication / Security and Authentication"),
416 gettext_noop("Resource Usage"),
418 gettext_noop("Resource Usage / Memory"),
420 gettext_noop("Resource Usage / Free Space Map"),
421 /* RESOURCES_KERNEL */
422 gettext_noop("Resource Usage / Kernel Resources"),
424 gettext_noop("Write-Ahead Log"),
426 gettext_noop("Write-Ahead Log / Settings"),
427 /* WAL_CHECKPOINTS */
428 gettext_noop("Write-Ahead Log / Checkpoints"),
430 gettext_noop("Query Tuning"),
431 /* QUERY_TUNING_METHOD */
432 gettext_noop("Query Tuning / Planner Method Configuration"),
433 /* QUERY_TUNING_COST */
434 gettext_noop("Query Tuning / Planner Cost Constants"),
435 /* QUERY_TUNING_GEQO */
436 gettext_noop("Query Tuning / Genetic Query Optimizer"),
437 /* QUERY_TUNING_OTHER */
438 gettext_noop("Query Tuning / Other Planner Options"),
440 gettext_noop("Reporting and Logging"),
442 gettext_noop("Reporting and Logging / Where to Log"),
444 gettext_noop("Reporting and Logging / When to Log"),
446 gettext_noop("Reporting and Logging / What to Log"),
448 gettext_noop("Statistics"),
449 /* STATS_MONITORING */
450 gettext_noop("Statistics / Monitoring"),
451 /* STATS_COLLECTOR */
452 gettext_noop("Statistics / Query and Index Statistics Collector"),
454 gettext_noop("Autovacuum"),
456 gettext_noop("Client Connection Defaults"),
457 /* CLIENT_CONN_STATEMENT */
458 gettext_noop("Client Connection Defaults / Statement Behavior"),
459 /* CLIENT_CONN_LOCALE */
460 gettext_noop("Client Connection Defaults / Locale and Formatting"),
461 /* CLIENT_CONN_OTHER */
462 gettext_noop("Client Connection Defaults / Other Defaults"),
463 /* LOCK_MANAGEMENT */
464 gettext_noop("Lock Management"),
466 gettext_noop("Version and Platform Compatibility"),
467 /* COMPAT_OPTIONS_PREVIOUS */
468 gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
469 /* COMPAT_OPTIONS_CLIENT */
470 gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
472 gettext_noop("Preset Options"),
474 gettext_noop("Customized Options"),
475 /* DEVELOPER_OPTIONS */
476 gettext_noop("Developer Options"),
477 /* help_config wants this array to be null-terminated */
482 * Displayable names for GUC variable types (enum config_type)
484 * Note: these strings are deliberately not localized.
486 const char *const config_type_names[] =
488 /* PGC_BOOL */ "bool",
489 /* PGC_INT */ "integer",
490 /* PGC_REAL */ "real",
491 /* PGC_STRING */ "string",
492 /* PGC_ENUM */ "enum"
497 * Contents of GUC tables
499 * See src/backend/utils/misc/README for design notes.
503 * 1. Declare a global variable of type bool, int, double, or char*
504 * and make use of it.
506 * 2. Decide at what times it's safe to set the option. See guc.h for
509 * 3. Decide on a name, a default value, upper and lower bounds (if
512 * 4. Add a record below.
514 * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
517 * 6. Don't forget to document the option (at least in config.sgml).
519 * 7. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
520 * it is not single quoted at dump time.
524 /******** option records follow ********/
526 static struct config_bool ConfigureNamesBool[] =
529 {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
530 gettext_noop("Enables the planner's use of sequential-scan plans."),
537 {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
538 gettext_noop("Enables the planner's use of index-scan plans."),
545 {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
546 gettext_noop("Enables the planner's use of bitmap-scan plans."),
553 {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
554 gettext_noop("Enables the planner's use of TID scan plans."),
561 {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
562 gettext_noop("Enables the planner's use of explicit sort steps."),
569 {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
570 gettext_noop("Enables the planner's use of hashed aggregation plans."),
577 {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
578 gettext_noop("Enables the planner's use of nested-loop join plans."),
585 {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
586 gettext_noop("Enables the planner's use of merge join plans."),
593 {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
594 gettext_noop("Enables the planner's use of hash join plans."),
601 {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
602 gettext_noop("Enables the planner to use constraints to optimize queries."),
603 gettext_noop("Child table scans will be skipped if their "
604 "constraints guarantee that no rows match the query.")
606 &constraint_exclusion,
610 {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
611 gettext_noop("Enables genetic query optimization."),
612 gettext_noop("This algorithm attempts to do planning without "
613 "exhaustive searching.")
619 /* Not for general use --- used by SET SESSION AUTHORIZATION */
620 {"is_superuser", PGC_INTERNAL, UNGROUPED,
621 gettext_noop("Shows whether the current user is a superuser."),
623 GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
625 &session_auth_is_superuser,
629 {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
630 gettext_noop("Enables SSL connections."),
634 false, assign_ssl, NULL
637 {"fsync", PGC_SIGHUP, WAL_SETTINGS,
638 gettext_noop("Forces synchronization of updates to disk."),
639 gettext_noop("The server will use the fsync() system call in several places to make "
640 "sure that updates are physically written to disk. This insures "
641 "that a database cluster will recover to a consistent state after "
642 "an operating system or hardware crash.")
648 {"synchronous_commit", PGC_USERSET, WAL_SETTINGS,
649 gettext_noop("Sets immediate fsync at commit."),
656 {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
657 gettext_noop("Continues processing past damaged page headers."),
658 gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
659 "report an error, aborting the current transaction. Setting "
660 "zero_damaged_pages to true causes the system to instead report a "
661 "warning, zero out the damaged page, and continue processing. This "
662 "behavior will destroy data, namely all the rows on the damaged page."),
669 {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
670 gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
671 gettext_noop("A page write in process during an operating system crash might be "
672 "only partially written to disk. During recovery, the row changes "
673 "stored in WAL are not enough to recover. This option writes "
674 "pages when first modified after a checkpoint to WAL so full recovery "
681 {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
682 gettext_noop("Runs the server silently."),
683 gettext_noop("If this parameter is set, the server will automatically run in the "
684 "background and any controlling terminals are dissociated.")
690 {"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
691 gettext_noop("Logs each checkpoint."),
698 {"log_connections", PGC_BACKEND, LOGGING_WHAT,
699 gettext_noop("Logs each successful connection."),
706 {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
707 gettext_noop("Logs end of a session, including duration."),
714 {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
715 gettext_noop("Turns on various assertion checks."),
716 gettext_noop("This is a debugging aid."),
720 #ifdef USE_ASSERT_CHECKING
725 assign_debug_assertions, NULL
728 /* currently undocumented, so don't show in SHOW ALL */
729 {"exit_on_error", PGC_USERSET, UNGROUPED,
730 gettext_noop("No description available."),
732 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
738 {"log_duration", PGC_SUSET, LOGGING_WHAT,
739 gettext_noop("Logs the duration of each completed SQL statement."),
746 {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
747 gettext_noop("Prints the parse tree to the server log."),
754 {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
755 gettext_noop("Prints the parse tree after rewriting to server log."),
758 &Debug_print_rewritten,
762 {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
763 gettext_noop("Prints the execution plan to server log."),
770 {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
771 gettext_noop("Indents parse and plan tree displays."),
778 {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
779 gettext_noop("Writes parser performance statistics to the server log."),
783 false, assign_stage_log_stats, NULL
786 {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
787 gettext_noop("Writes planner performance statistics to the server log."),
791 false, assign_stage_log_stats, NULL
794 {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
795 gettext_noop("Writes executor performance statistics to the server log."),
799 false, assign_stage_log_stats, NULL
802 {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
803 gettext_noop("Writes cumulative performance statistics to the server log."),
806 &log_statement_stats,
807 false, assign_log_stats, NULL
809 #ifdef BTREE_BUILD_STATS
811 {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
812 gettext_noop("No description available."),
816 &log_btree_build_stats,
822 {"track_activities", PGC_SUSET, STATS_COLLECTOR,
823 gettext_noop("Collects information about executing commands."),
824 gettext_noop("Enables the collection of information on the currently "
825 "executing command of each session, along with "
826 "the time at which that command began execution.")
828 &pgstat_track_activities,
832 {"track_counts", PGC_SUSET, STATS_COLLECTOR,
833 gettext_noop("Collects statistics on database activity."),
836 &pgstat_track_counts,
841 {"update_process_title", PGC_SUSET, STATS_COLLECTOR,
842 gettext_noop("Updates the process title to show the active SQL command."),
843 gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.")
845 &update_process_title,
850 {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
851 gettext_noop("Starts the autovacuum subprocess."),
854 &autovacuum_start_daemon,
859 {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
860 gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
870 {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
871 gettext_noop("No description available."),
879 {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
880 gettext_noop("No description available."),
888 {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
889 gettext_noop("No description available."),
897 {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
898 gettext_noop("No description available."),
908 {"log_lock_waits", PGC_SUSET, LOGGING_WHAT,
909 gettext_noop("Logs long lock waits."),
917 {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
918 gettext_noop("Logs the host name in the connection logs."),
919 gettext_noop("By default, connection logs only show the IP address "
920 "of the connecting host. If you want them to show the host name you "
921 "can turn this on, but depending on your host name resolution "
922 "setup it might impose a non-negligible performance penalty.")
928 {"sql_inheritance", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
929 gettext_noop("Causes subtables to be included by default in various commands."),
936 {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
937 gettext_noop("Encrypt passwords."),
938 gettext_noop("When a password is specified in CREATE USER or "
939 "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
940 "this parameter determines whether the password is to be encrypted.")
942 &Password_encryption,
946 {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
947 gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
948 gettext_noop("When turned on, expressions of the form expr = NULL "
949 "(or NULL = expr) are treated as expr IS NULL, that is, they "
950 "return true if expr evaluates to the null value, and false "
951 "otherwise. The correct behavior of expr = NULL is to always "
952 "return null (unknown).")
954 &Transform_null_equals,
958 {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
959 gettext_noop("Enables per-database user names."),
966 /* only here for backwards compatibility */
967 {"autocommit", PGC_USERSET, CLIENT_CONN_STATEMENT,
968 gettext_noop("This parameter doesn't do anything."),
969 gettext_noop("It's just here so that we won't choke on SET AUTOCOMMIT TO ON from 7.3-vintage clients."),
970 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
973 true, assign_phony_autocommit, NULL
976 {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
977 gettext_noop("Sets the default read-only status of new transactions."),
980 &DefaultXactReadOnly,
984 {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
985 gettext_noop("Sets the current transaction's read-only status."),
987 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
990 false, assign_transaction_read_only, NULL
993 {"add_missing_from", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
994 gettext_noop("Automatically adds missing table references to FROM clauses."),
1001 {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
1002 gettext_noop("Check function bodies during CREATE FUNCTION."),
1005 &check_function_bodies,
1009 {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1010 gettext_noop("Enable input of NULL elements in arrays."),
1011 gettext_noop("When turned on, unquoted NULL in an array input "
1012 "value means a null value; "
1013 "otherwise it is taken literally.")
1019 {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1020 gettext_noop("Create new tables with OIDs by default."),
1027 {"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
1028 gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
1035 {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
1036 gettext_noop("Truncate existing log files of same name during log rotation."),
1039 &Log_truncate_on_rotation,
1045 {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
1046 gettext_noop("Emit information about resource usage in sorting."),
1055 #ifdef TRACE_SYNCSCAN
1056 /* this is undocumented because not exposed in a standard build */
1058 {"trace_syncscan", PGC_USERSET, DEVELOPER_OPTIONS,
1059 gettext_noop("Generate debugging output for synchronized scanning."),
1068 #ifdef DEBUG_BOUNDED_SORT
1069 /* this is undocumented because not exposed in a standard build */
1072 "optimize_bounded_sort", PGC_USERSET, QUERY_TUNING_METHOD,
1073 gettext_noop("Enable bounded sorting using heap sort."),
1077 &optimize_bounded_sort,
1084 {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
1085 gettext_noop("Emit WAL-related debugging output."),
1095 {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
1096 gettext_noop("Datetimes are integer based."),
1098 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1101 #ifdef HAVE_INT64_TIMESTAMP
1109 {"krb_caseins_users", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1110 gettext_noop("Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive."),
1113 &pg_krb_caseins_users,
1118 {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1119 gettext_noop("Warn about backslash escapes in ordinary string literals."),
1122 &escape_string_warning,
1127 {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1128 gettext_noop("Causes '...' strings to treat backslashes literally."),
1132 &standard_conforming_strings,
1137 {"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1138 gettext_noop("Enable synchronized sequential scans."),
1141 &synchronize_seqscans,
1146 {"archive_mode", PGC_POSTMASTER, WAL_SETTINGS,
1147 gettext_noop("Allows archiving of WAL files using archive_command."),
1155 {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
1156 gettext_noop("Allows modifications of the structure of system tables."),
1160 &allowSystemTableMods,
1165 {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
1166 gettext_noop("Disables reading from system indexes."),
1167 gettext_noop("It does not prevent updating the indexes, so it is safe "
1168 "to use. The worst consequence is slowness."),
1171 &IgnoreSystemIndexes,
1175 /* End-of-list marker */
1177 {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
1182 static struct config_int ConfigureNamesInt[] =
1185 {"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
1186 gettext_noop("Forces a switch to the next xlog file if a "
1187 "new file has not been started within N seconds."),
1191 &XLogArchiveTimeout,
1192 0, 0, INT_MAX, NULL, NULL
1195 {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1196 gettext_noop("Waits N seconds on connection startup after authentication."),
1197 gettext_noop("This allows attaching a debugger to the process."),
1198 GUC_NOT_IN_SAMPLE | GUC_UNIT_S
1201 0, 0, INT_MAX, NULL, NULL
1204 {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1205 gettext_noop("Sets the default statistics target."),
1206 gettext_noop("This applies to table columns that have not had a "
1207 "column-specific target set via ALTER TABLE SET STATISTICS.")
1209 &default_statistics_target,
1210 10, 1, 1000, NULL, NULL
1213 {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1214 gettext_noop("Sets the FROM-list size beyond which subqueries "
1215 "are not collapsed."),
1216 gettext_noop("The planner will merge subqueries into upper "
1217 "queries if the resulting FROM list would have no more than "
1220 &from_collapse_limit,
1221 8, 1, INT_MAX, NULL, NULL
1224 {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1225 gettext_noop("Sets the FROM-list size beyond which JOIN "
1226 "constructs are not flattened."),
1227 gettext_noop("The planner will flatten explicit JOIN "
1228 "constructs into lists of FROM items whenever a "
1229 "list of no more than this many items would result.")
1231 &join_collapse_limit,
1232 8, 1, INT_MAX, NULL, NULL
1235 {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1236 gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1240 12, 2, INT_MAX, NULL, NULL
1243 {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1244 gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1248 DEFAULT_GEQO_EFFORT, MIN_GEQO_EFFORT, MAX_GEQO_EFFORT, NULL, NULL
1251 {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1252 gettext_noop("GEQO: number of individuals in the population."),
1253 gettext_noop("Zero selects a suitable default value.")
1256 0, 0, INT_MAX, NULL, NULL
1259 {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1260 gettext_noop("GEQO: number of iterations of the algorithm."),
1261 gettext_noop("Zero selects a suitable default value.")
1264 0, 0, INT_MAX, NULL, NULL
1268 {"deadlock_timeout", PGC_SIGHUP, LOCK_MANAGEMENT,
1269 gettext_noop("Sets the time to wait on a lock before checking for deadlock."),
1274 1000, 1, INT_MAX / 1000, NULL, NULL
1278 * Note: MaxBackends is limited to INT_MAX/4 because some places compute
1279 * 4*MaxBackends without any overflow check. This check is made in
1280 * assign_maxconnections, since MaxBackends is computed as MaxConnections
1281 * plus autovacuum_max_workers.
1283 * Likewise we have to limit NBuffers to INT_MAX/2.
1286 {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1287 gettext_noop("Sets the maximum number of concurrent connections."),
1291 100, 1, INT_MAX / 4, assign_maxconnections, NULL
1295 {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1296 gettext_noop("Sets the number of connection slots reserved for superusers."),
1300 3, 0, INT_MAX / 4, NULL, NULL
1304 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1305 gettext_noop("Sets the number of shared memory buffers used by the server."),
1310 1024, 16, INT_MAX / 2, NULL, NULL
1314 {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1315 gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1320 1024, 100, INT_MAX / 2, NULL, show_num_temp_buffers
1324 {"port", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1325 gettext_noop("Sets the TCP port the server listens on."),
1329 DEF_PGPORT, 1, 65535, NULL, NULL
1333 {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1334 gettext_noop("Sets the access permissions of the Unix-domain socket."),
1335 gettext_noop("Unix-domain sockets use the usual Unix file system "
1336 "permission set. The parameter value is expected to be an numeric mode "
1337 "specification in the form accepted by the chmod and umask system "
1338 "calls. (To use the customary octal format the number must start with "
1341 &Unix_socket_permissions,
1342 0777, 0000, 0777, NULL, NULL
1346 {"work_mem", PGC_USERSET, RESOURCES_MEM,
1347 gettext_noop("Sets the maximum memory to be used for query workspaces."),
1348 gettext_noop("This much memory can be used by each internal "
1349 "sort operation and hash table before switching to "
1350 "temporary disk files."),
1354 1024, 64, MAX_KILOBYTES, NULL, NULL
1358 {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1359 gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1360 gettext_noop("This includes operations such as VACUUM and CREATE INDEX."),
1363 &maintenance_work_mem,
1364 16384, 1024, MAX_KILOBYTES, NULL, NULL
1368 {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1369 gettext_noop("Sets the maximum stack depth, in kilobytes."),
1374 100, 100, MAX_KILOBYTES, assign_max_stack_depth, NULL
1378 {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
1379 gettext_noop("Vacuum cost for a page found in the buffer cache."),
1383 1, 0, 10000, NULL, NULL
1387 {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
1388 gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1391 &VacuumCostPageMiss,
1392 10, 0, 10000, NULL, NULL
1396 {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
1397 gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1400 &VacuumCostPageDirty,
1401 20, 0, 10000, NULL, NULL
1405 {"vacuum_cost_limit", PGC_USERSET, RESOURCES,
1406 gettext_noop("Vacuum cost amount available before napping."),
1410 200, 1, 10000, NULL, NULL
1414 {"vacuum_cost_delay", PGC_USERSET, RESOURCES,
1415 gettext_noop("Vacuum cost delay in milliseconds."),
1420 0, 0, 1000, NULL, NULL
1424 {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
1425 gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
1429 &autovacuum_vac_cost_delay,
1430 20, -1, 1000, NULL, NULL
1434 {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
1435 gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
1438 &autovacuum_vac_cost_limit,
1439 -1, -1, 10000, NULL, NULL
1443 {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
1444 gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
1447 &max_files_per_process,
1448 1000, 25, INT_MAX, NULL, NULL
1452 {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
1453 gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
1456 &max_prepared_xacts,
1457 5, 0, INT_MAX, NULL, NULL
1462 {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
1463 gettext_noop("No description available."),
1468 FirstNormalObjectId, 0, INT_MAX, NULL, NULL
1471 {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
1472 gettext_noop("No description available."),
1477 0, 0, INT_MAX, NULL, NULL
1482 {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
1483 gettext_noop("Sets the maximum allowed duration of any statement."),
1484 gettext_noop("A value of 0 turns off the timeout."),
1488 0, 0, INT_MAX, NULL, NULL
1492 {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
1493 gettext_noop("Minimum age at which VACUUM should freeze a table row."),
1496 &vacuum_freeze_min_age,
1497 100000000, 0, 1000000000, NULL, NULL
1501 {"max_fsm_relations", PGC_POSTMASTER, RESOURCES_FSM,
1502 gettext_noop("Sets the maximum number of tables and indexes for which free space is tracked."),
1506 1000, 100, INT_MAX, NULL, NULL
1509 {"max_fsm_pages", PGC_POSTMASTER, RESOURCES_FSM,
1510 gettext_noop("Sets the maximum number of disk pages for which free space is tracked."),
1514 20000, 1000, INT_MAX, NULL, NULL
1518 {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
1519 gettext_noop("Sets the maximum number of locks per transaction."),
1520 gettext_noop("The shared lock table is sized on the assumption that "
1521 "at most max_locks_per_transaction * max_connections distinct "
1522 "objects will need to be locked at any one time.")
1524 &max_locks_per_xact,
1525 64, 10, INT_MAX, NULL, NULL
1529 {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
1530 gettext_noop("Sets the maximum allowed time to complete client authentication."),
1534 &AuthenticationTimeout,
1535 60, 1, 600, NULL, NULL
1539 /* Not for general use */
1540 {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
1541 gettext_noop("Waits N seconds on connection startup before authentication."),
1542 gettext_noop("This allows attaching a debugger to the process."),
1543 GUC_NOT_IN_SAMPLE | GUC_UNIT_S
1546 0, 0, 60, NULL, NULL
1550 {"checkpoint_segments", PGC_SIGHUP, WAL_CHECKPOINTS,
1551 gettext_noop("Sets the maximum distance in log segments between automatic WAL checkpoints."),
1554 &CheckPointSegments,
1555 3, 1, INT_MAX, NULL, NULL
1559 {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
1560 gettext_noop("Sets the maximum time between automatic WAL checkpoints."),
1565 300, 30, 3600, NULL, NULL
1569 {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
1570 gettext_noop("Enables warnings if checkpoint segments are filled more "
1571 "frequently than this."),
1572 gettext_noop("Write a message to the server log if checkpoints "
1573 "caused by the filling of checkpoint segment files happens more "
1574 "frequently than this number of seconds. Zero turns off the warning."),
1578 30, 0, INT_MAX, NULL, NULL
1582 {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
1583 gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
1588 8, 4, INT_MAX, NULL, NULL
1592 {"wal_writer_delay", PGC_SIGHUP, WAL_SETTINGS,
1593 gettext_noop("WAL writer sleep time between WAL flushes."),
1598 200, 1, 10000, NULL, NULL
1602 {"commit_delay", PGC_USERSET, WAL_SETTINGS,
1603 gettext_noop("Sets the delay in microseconds between transaction commit and "
1604 "flushing WAL to disk."),
1608 0, 0, 100000, NULL, NULL
1612 {"commit_siblings", PGC_USERSET, WAL_SETTINGS,
1613 gettext_noop("Sets the minimum concurrent open transactions before performing "
1618 5, 1, 1000, NULL, NULL
1622 {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
1623 gettext_noop("Sets the number of digits displayed for floating-point values."),
1624 gettext_noop("This affects real, double precision, and geometric data types. "
1625 "The parameter value is added to the standard number of digits "
1626 "(FLT_DIG or DBL_DIG as appropriate).")
1628 &extra_float_digits,
1629 0, -15, 2, NULL, NULL
1633 {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
1634 gettext_noop("Sets the minimum execution time above which "
1635 "statements will be logged."),
1636 gettext_noop("Zero prints all queries. -1 turns this feature off."),
1639 &log_min_duration_statement,
1640 -1, -1, INT_MAX / 1000, NULL, NULL
1644 {"log_autovacuum_min_duration", PGC_SIGHUP, LOGGING_WHAT,
1645 gettext_noop("Sets the minimum execution time above which "
1646 "autovacuum actions will be logged."),
1647 gettext_noop("Zero prints all actions. -1 turns autovacuum logging off."),
1650 &Log_autovacuum_min_duration,
1651 -1, -1, INT_MAX / 1000, NULL, NULL
1655 {"bgwriter_delay", PGC_SIGHUP, RESOURCES,
1656 gettext_noop("Background writer sleep time between rounds."),
1661 200, 10, 10000, NULL, NULL
1665 {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
1666 gettext_noop("Background writer maximum number of LRU pages to flush per round."),
1669 &bgwriter_lru_maxpages,
1670 100, 0, 1000, NULL, NULL
1674 {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
1675 gettext_noop("Automatic log file rotation will occur after N minutes."),
1680 HOURS_PER_DAY * MINS_PER_HOUR, 0, INT_MAX / MINS_PER_HOUR, NULL, NULL
1684 {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
1685 gettext_noop("Automatic log file rotation will occur after N kilobytes."),
1690 10 * 1024, 0, INT_MAX / 1024, NULL, NULL
1694 {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
1695 gettext_noop("Shows the maximum number of function arguments."),
1697 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1700 FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
1704 {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
1705 gettext_noop("Shows the maximum number of index keys."),
1707 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1710 INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
1714 {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
1715 gettext_noop("Shows the maximum identifier length."),
1717 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1719 &max_identifier_length,
1720 NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
1724 {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
1725 gettext_noop("Shows the size of a disk block."),
1727 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1730 BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
1734 {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
1735 gettext_noop("Time to sleep between autovacuum runs."),
1739 &autovacuum_naptime,
1740 60, 1, INT_MAX / 1000, NULL, NULL
1743 {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
1744 gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
1747 &autovacuum_vac_thresh,
1748 50, 0, INT_MAX, NULL, NULL
1751 {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
1752 gettext_noop("Minimum number of tuple inserts, updates or deletes prior to analyze."),
1755 &autovacuum_anl_thresh,
1756 50, 0, INT_MAX, NULL, NULL
1759 /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
1760 {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
1761 gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
1764 &autovacuum_freeze_max_age,
1765 200000000, 100000000, 2000000000, NULL, NULL
1768 /* see max_connections */
1769 {"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM,
1770 gettext_noop("Sets the maximum number of simultaneously running autovacuum worker processes."),
1773 &autovacuum_max_workers,
1774 3, 1, INT_MAX / 4, assign_autovacuum_max_workers, NULL
1778 {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
1779 gettext_noop("Time between issuing TCP keepalives."),
1780 gettext_noop("A value of 0 uses the system default."),
1783 &tcp_keepalives_idle,
1784 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle
1788 {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
1789 gettext_noop("Time between TCP keepalive retransmits."),
1790 gettext_noop("A value of 0 uses the system default."),
1793 &tcp_keepalives_interval,
1794 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
1798 {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
1799 gettext_noop("Maximum number of TCP keepalive retransmits."),
1800 gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
1801 "lost before a connection is considered dead. A value of 0 uses the "
1804 &tcp_keepalives_count,
1805 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count
1809 {"gin_fuzzy_search_limit", PGC_USERSET, CLIENT_CONN_OTHER,
1810 gettext_noop("Sets the maximum allowed result for exact search by GIN."),
1814 &GinFuzzySearchLimit,
1815 0, 0, INT_MAX, NULL, NULL
1819 {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
1820 gettext_noop("Sets the planner's assumption about the size of the disk cache."),
1821 gettext_noop("That is, the portion of the kernel's disk cache that "
1822 "will be used for PostgreSQL data files. This is measured in disk "
1823 "pages, which are normally 8 kB each."),
1826 &effective_cache_size,
1827 DEFAULT_EFFECTIVE_CACHE_SIZE, 1, INT_MAX, NULL, NULL
1831 /* Can't be set in postgresql.conf */
1832 {"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
1833 gettext_noop("Shows the server version as an integer."),
1835 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1837 &server_version_num,
1838 PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM, NULL, NULL
1842 {"log_temp_files", PGC_USERSET, LOGGING_WHAT,
1843 gettext_noop("Log the use of temporary files larger than this number of kilobytes."),
1844 gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
1848 -1, -1, INT_MAX, NULL, NULL
1852 {"track_activity_query_size", PGC_POSTMASTER, RESOURCES_MEM,
1853 gettext_noop("Sets the size reserved for pg_stat_activity.current_query, in bytes."),
1856 &pgstat_track_activity_query_size,
1857 1024, 100, 102400, NULL, NULL
1860 /* End-of-list marker */
1862 {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
1867 static struct config_real ConfigureNamesReal[] =
1870 {"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1871 gettext_noop("Sets the planner's estimate of the cost of a "
1872 "sequentially fetched disk page."),
1876 DEFAULT_SEQ_PAGE_COST, 0, DBL_MAX, NULL, NULL
1879 {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1880 gettext_noop("Sets the planner's estimate of the cost of a "
1881 "nonsequentially fetched disk page."),
1885 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
1888 {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1889 gettext_noop("Sets the planner's estimate of the cost of "
1890 "processing each tuple (row)."),
1894 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1897 {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1898 gettext_noop("Sets the planner's estimate of the cost of "
1899 "processing each index entry during an index scan."),
1902 &cpu_index_tuple_cost,
1903 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1906 {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
1907 gettext_noop("Sets the planner's estimate of the cost of "
1908 "processing each operator or function call."),
1912 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
1916 {"cursor_tuple_fraction", PGC_USERSET, QUERY_TUNING_OTHER,
1917 gettext_noop("Sets the planner's estimate of the fraction of "
1918 "a cursor's rows that will be retrieved."),
1921 &cursor_tuple_fraction,
1922 DEFAULT_CURSOR_TUPLE_FRACTION, 0.0, 1.0, NULL, NULL
1926 {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
1927 gettext_noop("GEQO: selective pressure within the population."),
1930 &Geqo_selection_bias,
1931 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
1932 MAX_GEQO_SELECTION_BIAS, NULL, NULL
1936 {"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES,
1937 gettext_noop("Multiple of the average buffer usage to free per round."),
1940 &bgwriter_lru_multiplier,
1941 2.0, 0.0, 10.0, NULL, NULL
1945 {"seed", PGC_USERSET, UNGROUPED,
1946 gettext_noop("Sets the seed for random-number generation."),
1948 GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1951 0.0, -1.0, 1.0, assign_random_seed, show_random_seed
1955 {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1956 gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
1959 &autovacuum_vac_scale,
1960 0.2, 0.0, 100.0, NULL, NULL
1963 {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1964 gettext_noop("Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples."),
1967 &autovacuum_anl_scale,
1968 0.1, 0.0, 100.0, NULL, NULL
1972 {"checkpoint_completion_target", PGC_SIGHUP, WAL_CHECKPOINTS,
1973 gettext_noop("Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval."),
1976 &CheckPointCompletionTarget,
1977 0.5, 0.0, 1.0, NULL, NULL
1980 /* End-of-list marker */
1982 {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL
1987 static struct config_string ConfigureNamesString[] =
1990 {"archive_command", PGC_SIGHUP, WAL_SETTINGS,
1991 gettext_noop("Sets the shell command that will be called to archive a WAL file."),
1994 &XLogArchiveCommand,
1995 "", NULL, show_archive_command
1999 {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
2000 gettext_noop("Sets the client's character set encoding."),
2002 GUC_IS_NAME | GUC_REPORT
2004 &client_encoding_string,
2005 "SQL_ASCII", assign_client_encoding, NULL
2009 {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
2010 gettext_noop("Controls information prefixed to each log line."),
2011 gettext_noop("If blank, no prefix is used.")
2018 {"log_timezone", PGC_SIGHUP, LOGGING_WHAT,
2019 gettext_noop("Sets the time zone to use in log messages."),
2022 &log_timezone_string,
2023 "UNKNOWN", assign_log_timezone, show_log_timezone
2027 {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
2028 gettext_noop("Sets the display format for date and time values."),
2029 gettext_noop("Also controls interpretation of ambiguous "
2031 GUC_LIST_INPUT | GUC_REPORT
2034 "ISO, MDY", assign_datestyle, NULL
2038 {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
2039 gettext_noop("Sets the default tablespace to create tables and indexes in."),
2040 gettext_noop("An empty string selects the database's default tablespace."),
2043 &default_tablespace,
2044 "", assign_default_tablespace, NULL
2048 {"temp_tablespaces", PGC_USERSET, CLIENT_CONN_STATEMENT,
2049 gettext_noop("Sets the tablespace(s) to use for temporary tables and sort files."),
2051 GUC_LIST_INPUT | GUC_LIST_QUOTE
2054 "", assign_temp_tablespaces, NULL
2058 {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
2059 gettext_noop("Sets the path for dynamically loadable modules."),
2060 gettext_noop("If a dynamically loadable module needs to be opened and "
2061 "the specified name does not have a directory component (i.e., the "
2062 "name does not contain a slash), the system will search this path for "
2063 "the specified file."),
2066 &Dynamic_library_path,
2067 "$libdir", NULL, NULL
2071 {"krb_realm", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2072 gettext_noop("Sets realm to match Kerberos and GSSAPI users against."),
2081 {"krb_server_keyfile", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2082 gettext_noop("Sets the location of the Kerberos server key file."),
2086 &pg_krb_server_keyfile,
2087 PG_KRB_SRVTAB, NULL, NULL
2091 {"krb_srvname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2092 gettext_noop("Sets the name of the Kerberos service."),
2096 PG_KRB_SRVNAM, NULL, NULL
2100 {"krb_server_hostname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2101 gettext_noop("Sets the hostname of the Kerberos server."),
2104 &pg_krb_server_hostname,
2109 {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2110 gettext_noop("Sets the Bonjour broadcast service name."),
2117 /* See main.c about why defaults for LC_foo are not all alike */
2120 {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2121 gettext_noop("Shows the collation order locale."),
2123 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2130 {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2131 gettext_noop("Shows the character classification and case conversion locale."),
2133 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2140 {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
2141 gettext_noop("Sets the language in which messages are displayed."),
2145 "", locale_messages_assign, NULL
2149 {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
2150 gettext_noop("Sets the locale for formatting monetary amounts."),
2154 "C", locale_monetary_assign, NULL
2158 {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
2159 gettext_noop("Sets the locale for formatting numbers."),
2163 "C", locale_numeric_assign, NULL
2167 {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
2168 gettext_noop("Sets the locale for formatting date and time values."),
2172 "C", locale_time_assign, NULL
2176 {"shared_preload_libraries", PGC_POSTMASTER, RESOURCES_KERNEL,
2177 gettext_noop("Lists shared libraries to preload into server."),
2179 GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
2181 &shared_preload_libraries_string,
2186 {"local_preload_libraries", PGC_BACKEND, CLIENT_CONN_OTHER,
2187 gettext_noop("Lists shared libraries to preload into each backend."),
2189 GUC_LIST_INPUT | GUC_LIST_QUOTE
2191 &local_preload_libraries_string,
2196 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
2197 gettext_noop("Sets the schema search order for names that are not schema-qualified."),
2199 GUC_LIST_INPUT | GUC_LIST_QUOTE
2201 &namespace_search_path,
2202 "\"$user\",public", assign_search_path, NULL
2206 /* Can't be set in postgresql.conf */
2207 {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
2208 gettext_noop("Sets the server (database) character set encoding."),
2210 GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2212 &server_encoding_string,
2213 "SQL_ASCII", NULL, NULL
2217 /* Can't be set in postgresql.conf */
2218 {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
2219 gettext_noop("Shows the server version."),
2221 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2223 &server_version_string,
2224 PG_VERSION, NULL, NULL
2228 /* Not for general use --- used by SET ROLE */
2229 {"role", PGC_USERSET, UNGROUPED,
2230 gettext_noop("Sets the current role."),
2232 GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2235 "none", assign_role, show_role
2239 /* Not for general use --- used by SET SESSION AUTHORIZATION */
2240 {"session_authorization", PGC_USERSET, UNGROUPED,
2241 gettext_noop("Sets the session user name."),
2243 GUC_IS_NAME | GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2245 &session_authorization_string,
2246 NULL, assign_session_authorization, show_session_authorization
2250 {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
2251 gettext_noop("Sets the destination for server log output."),
2252 gettext_noop("Valid values are combinations of \"stderr\", "
2253 "\"syslog\", \"csvlog\", and \"eventlog\", "
2254 "depending on the platform."),
2257 &log_destination_string,
2258 "stderr", assign_log_destination, NULL
2261 {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
2262 gettext_noop("Sets the destination directory for log files."),
2263 gettext_noop("Can be specified as relative to the data directory "
2264 "or as absolute path."),
2268 "pg_log", assign_canonical_path, NULL
2271 {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
2272 gettext_noop("Sets the file name pattern for log files."),
2277 "postgresql-%Y-%m-%d_%H%M%S.log", NULL, 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 {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
2352 gettext_noop("Sets the list of known custom variable classes."),
2354 GUC_LIST_INPUT | GUC_LIST_QUOTE
2356 &custom_variable_classes,
2357 NULL, assign_custom_variable_classes, NULL
2361 {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
2362 gettext_noop("Sets the server's data directory."),
2371 {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
2372 gettext_noop("Sets the server's main configuration file."),
2374 GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
2381 {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
2382 gettext_noop("Sets the server's \"hba\" configuration file."),
2391 {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
2392 gettext_noop("Sets the server's \"ident\" configuration file."),
2401 {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
2402 gettext_noop("Writes the postmaster PID to the specified file."),
2407 NULL, assign_canonical_path, NULL
2411 {"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
2412 gettext_noop("Sets default text search configuration."),
2416 "pg_catalog.simple", assignTSCurrentConfig, NULL
2421 {"ssl_ciphers", PGC_POSTMASTER, CONN_AUTH_SECURITY,
2422 gettext_noop("Sets the list of allowed SSL ciphers."),
2427 "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH", NULL, NULL
2429 #endif /* USE_SSL */
2431 /* End-of-list marker */
2433 {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
2438 static struct config_enum ConfigureNamesEnum[] =
2441 {"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
2442 gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
2443 gettext_noop("Valid values are ON, OFF, and SAFE_ENCODING.")
2446 BACKSLASH_QUOTE_SAFE_ENCODING, backslash_quote_options, NULL, NULL
2450 {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
2451 gettext_noop("Sets the message levels that are sent to the client."),
2452 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, "
2453 "DEBUG1, LOG, NOTICE, WARNING, and ERROR. Each level includes all the "
2454 "levels that follow it. The later the level, the fewer messages are "
2457 &client_min_messages,
2458 NOTICE, message_level_options,NULL, NULL
2462 {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2463 gettext_noop("Sets the transaction isolation level of each new transaction."),
2464 gettext_noop("Each SQL transaction has an isolation level, which "
2465 "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
2467 &DefaultXactIsoLevel,
2468 XACT_READ_COMMITTED, isolation_level_options, NULL, NULL
2472 {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
2473 gettext_noop("Sets the verbosity of logged messages."),
2474 gettext_noop("Valid values are \"terse\", \"default\", and \"verbose\".")
2476 &Log_error_verbosity,
2477 PGERROR_DEFAULT, log_error_verbosity_options, NULL, NULL
2481 {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
2482 gettext_noop("Sets the message levels that are logged."),
2483 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, "
2484 "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level "
2485 "includes all the levels that follow it.")
2488 WARNING, message_level_options, NULL, NULL
2492 {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
2493 gettext_noop("Causes all statements generating error at or above this level to be logged."),
2494 gettext_noop("All SQL statements that cause an error of the "
2495 "specified level or a higher level are logged.")
2497 &log_min_error_statement,
2498 ERROR, message_level_options, NULL, NULL
2502 {"log_statement", PGC_SUSET, LOGGING_WHAT,
2503 gettext_noop("Sets the type of statements logged."),
2504 gettext_noop("Valid values are \"none\", \"ddl\", \"mod\", and \"all\".")
2507 LOGSTMT_NONE, log_statement_options, NULL, NULL
2512 {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2513 gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2514 gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2515 "LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2518 LOG_LOCAL0, syslog_facility_options, assign_syslog_facility, NULL
2523 {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
2524 gettext_noop("Sets the regular expression \"flavor\"."),
2525 gettext_noop("This can be set to advanced, extended, or basic.")
2528 REG_ADVANCED, regex_flavor_options, NULL, NULL
2532 {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
2533 gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
2534 gettext_noop("Each session can be either"
2535 " \"origin\", \"replica\", or \"local\".")
2537 &SessionReplicationRole,
2538 SESSION_REPLICATION_ROLE_ORIGIN, session_replication_role_options,
2539 assign_session_replication_role, NULL
2543 {"track_functions", PGC_SUSET, STATS_COLLECTOR,
2544 gettext_noop("Collects function-level statistics on database activity."),
2545 gettext_noop("Valid values are: NONE, PL, and ALL.")
2547 &pgstat_track_functions,
2548 TRACK_FUNC_OFF, track_function_options, NULL, NULL
2552 {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
2553 gettext_noop("Selects the method used for forcing WAL updates to disk."),
2557 DEFAULT_SYNC_METHOD, sync_method_options,
2558 assign_xlog_sync_method, NULL
2562 {"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
2563 gettext_noop("Sets how binary values are to be encoded in XML."),
2564 gettext_noop("Valid values are BASE64 and HEX.")
2567 XMLBINARY_BASE64, xmlbinary_options, NULL, NULL
2571 {"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
2572 gettext_noop("Sets whether XML data in implicit parsing and serialization "
2573 "operations is to be considered as documents or content fragments."),
2574 gettext_noop("Valid values are DOCUMENT and CONTENT.")
2577 XMLOPTION_CONTENT, xmloption_options, NULL, NULL
2581 /* End-of-list marker */
2583 {NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL
2587 /******** end of options list ********/
2591 * To allow continued support of obsolete names for GUC variables, we apply
2592 * the following mappings to any unrecognized name. Note that an old name
2593 * should be mapped to a new one only if the new variable has very similar
2594 * semantics to the old.
2596 static const char *const map_old_guc_names[] = {
2597 "sort_mem", "work_mem",
2598 "vacuum_mem", "maintenance_work_mem",
2604 * Actual lookup of variables is done through this single, sorted array.
2606 static struct config_generic **guc_variables;
2608 /* Current number of variables contained in the vector */
2609 static int num_guc_variables;
2611 /* Vector capacity */
2612 static int size_guc_variables;
2615 static bool guc_dirty; /* TRUE if need to do commit/abort work */
2617 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
2619 static int GUCNestLevel = 0; /* 1 when in main transaction */
2622 static int guc_var_compare(const void *a, const void *b);
2623 static int guc_name_compare(const char *namea, const char *nameb);
2624 static void push_old_value(struct config_generic * gconf, GucAction action);
2625 static void ReportGUCOption(struct config_generic * record);
2626 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
2627 static void ShowAllGUCConfig(DestReceiver *dest);
2628 static char *_ShowOption(struct config_generic * record, bool use_units);
2629 static bool is_newvalue_equal(struct config_generic * record, const char *newvalue);
2633 * Some infrastructure for checking malloc/strdup/realloc calls
2636 guc_malloc(int elevel, size_t size)
2640 data = malloc(size);
2643 (errcode(ERRCODE_OUT_OF_MEMORY),
2644 errmsg("out of memory")));
2649 guc_realloc(int elevel, void *old, size_t size)
2653 data = realloc(old, size);
2656 (errcode(ERRCODE_OUT_OF_MEMORY),
2657 errmsg("out of memory")));
2662 guc_strdup(int elevel, const char *src)
2669 (errcode(ERRCODE_OUT_OF_MEMORY),
2670 errmsg("out of memory")));
2676 * Support for assigning to a field of a string GUC item. Free the prior
2677 * value if it's not referenced anywhere else in the item (including stacked
2681 set_string_field(struct config_string * conf, char **field, char *newval)
2683 char *oldval = *field;
2686 /* Do the assignment */
2689 /* Exit if any duplicate references, or if old value was NULL anyway */
2690 if (oldval == NULL ||
2691 oldval == *(conf->variable) ||
2692 oldval == conf->reset_val ||
2693 oldval == conf->boot_val)
2695 for (stack = conf->gen.stack; stack; stack = stack->prev)
2697 if (oldval == stack->prior.stringval ||
2698 oldval == stack->masked.stringval)
2702 /* Not used anymore, so free it */
2707 * Detect whether strval is referenced anywhere in a GUC string item
2710 string_field_used(struct config_string * conf, char *strval)
2714 if (strval == *(conf->variable) ||
2715 strval == conf->reset_val ||
2716 strval == conf->boot_val)
2718 for (stack = conf->gen.stack; stack; stack = stack->prev)
2720 if (strval == stack->prior.stringval ||
2721 strval == stack->masked.stringval)
2728 * Support for copying a variable's active value into a stack entry
2731 set_stack_value(struct config_generic * gconf, union config_var_value * val)
2733 switch (gconf->vartype)
2737 *((struct config_bool *) gconf)->variable;
2741 *((struct config_int *) gconf)->variable;
2745 *((struct config_real *) gconf)->variable;
2748 /* we assume stringval is NULL if not valid */
2749 set_string_field((struct config_string *) gconf,
2751 *((struct config_string *) gconf)->variable);
2755 *((struct config_enum *) gconf)->variable;
2761 * Support for discarding a no-longer-needed value in a stack entry
2764 discard_stack_value(struct config_generic * gconf, union config_var_value * val)
2766 switch (gconf->vartype)
2772 /* no need to do anything */
2775 set_string_field((struct config_string *) gconf,
2784 * Fetch the sorted array pointer (exported for help_config.c's use ONLY)
2786 struct config_generic **
2787 get_guc_variables(void)
2789 return guc_variables;
2794 * Build the sorted array. This is split out so that it could be
2795 * re-executed after startup (eg, we could allow loadable modules to
2796 * add vars, and then we'd need to re-sort).
2799 build_guc_variables(void)
2803 struct config_generic **guc_vars;
2806 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2808 struct config_bool *conf = &ConfigureNamesBool[i];
2810 /* Rather than requiring vartype to be filled in by hand, do this: */
2811 conf->gen.vartype = PGC_BOOL;
2815 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2817 struct config_int *conf = &ConfigureNamesInt[i];
2819 conf->gen.vartype = PGC_INT;
2823 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2825 struct config_real *conf = &ConfigureNamesReal[i];
2827 conf->gen.vartype = PGC_REAL;
2831 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2833 struct config_string *conf = &ConfigureNamesString[i];
2835 conf->gen.vartype = PGC_STRING;
2839 for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
2841 struct config_enum *conf = &ConfigureNamesEnum[i];
2843 conf->gen.vartype = PGC_ENUM;
2848 * Create table with 20% slack
2850 size_vars = num_vars + num_vars / 4;
2852 guc_vars = (struct config_generic **)
2853 guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
2857 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2858 guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
2860 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2861 guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
2863 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2864 guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
2866 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2867 guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
2869 for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
2870 guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
2873 free(guc_variables);
2874 guc_variables = guc_vars;
2875 num_guc_variables = num_vars;
2876 size_guc_variables = size_vars;
2877 qsort((void *) guc_variables, num_guc_variables,
2878 sizeof(struct config_generic *), guc_var_compare);
2882 * Add a new GUC variable to the list of known variables. The
2883 * list is expanded if needed.
2886 add_guc_variable(struct config_generic * var, int elevel)
2888 if (num_guc_variables + 1 >= size_guc_variables)
2891 * Increase the vector by 25%
2893 int size_vars = size_guc_variables + size_guc_variables / 4;
2894 struct config_generic **guc_vars;
2899 guc_vars = (struct config_generic **)
2900 guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
2904 guc_vars = (struct config_generic **)
2905 guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
2908 if (guc_vars == NULL)
2909 return false; /* out of memory */
2911 guc_variables = guc_vars;
2912 size_guc_variables = size_vars;
2914 guc_variables[num_guc_variables++] = var;
2915 qsort((void *) guc_variables, num_guc_variables,
2916 sizeof(struct config_generic *), guc_var_compare);
2921 * Create and add a placeholder variable. It's presumed to belong
2922 * to a valid custom variable class at this point.
2924 static struct config_generic *
2925 add_placeholder_variable(const char *name, int elevel)
2927 size_t sz = sizeof(struct config_string) + sizeof(char *);
2928 struct config_string *var;
2929 struct config_generic *gen;
2931 var = (struct config_string *) guc_malloc(elevel, sz);
2937 gen->name = guc_strdup(elevel, name);
2938 if (gen->name == NULL)
2944 gen->context = PGC_USERSET;
2945 gen->group = CUSTOM_OPTIONS;
2946 gen->short_desc = "GUC placeholder variable";
2947 gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
2948 gen->vartype = PGC_STRING;
2951 * The char* is allocated at the end of the struct since we have no
2952 * 'static' place to point to. Note that the current value, as well as
2953 * the boot and reset values, start out NULL.
2955 var->variable = (char **) (var + 1);
2957 if (!add_guc_variable((struct config_generic *) var, elevel))
2959 free((void *) gen->name);
2968 * Detect whether the portion of "name" before dotPos matches any custom
2969 * variable class name listed in custom_var_classes. The latter must be
2970 * formatted the way that assign_custom_variable_classes does it, ie,
2971 * no whitespace. NULL is valid for custom_var_classes.
2974 is_custom_class(const char *name, int dotPos, const char *custom_var_classes)
2976 bool result = false;
2977 const char *ccs = custom_var_classes;
2981 const char *start = ccs;
2987 if (c == '\0' || c == ',')
2989 if (dotPos == ccs - start && strncmp(start, name, dotPos) == 0)
3004 * Look up option NAME. If it exists, return a pointer to its record,
3005 * else return NULL. If create_placeholders is TRUE, we'll create a
3006 * placeholder record for a valid-looking custom variable name.
3008 static struct config_generic *
3009 find_option(const char *name, bool create_placeholders, int elevel)
3011 const char **key = &name;
3012 struct config_generic **res;
3018 * By equating const char ** with struct config_generic *, we are assuming
3019 * the name field is first in config_generic.
3021 res = (struct config_generic **) bsearch((void *) &key,
3022 (void *) guc_variables,
3024 sizeof(struct config_generic *),
3030 * See if the name is an obsolete name for a variable. We assume that the
3031 * set of supported old names is short enough that a brute-force search is
3034 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
3036 if (guc_name_compare(name, map_old_guc_names[i]) == 0)
3037 return find_option(map_old_guc_names[i + 1], false, elevel);
3040 if (create_placeholders)
3043 * Check if the name is qualified, and if so, check if the qualifier
3044 * matches any custom variable class. If so, add a placeholder.
3046 const char *dot = strchr(name, GUC_QUALIFIER_SEPARATOR);
3049 is_custom_class(name, dot - name, custom_variable_classes))
3050 return add_placeholder_variable(name, elevel);
3059 * comparator for qsorting and bsearching guc_variables array
3062 guc_var_compare(const void *a, const void *b)
3064 struct config_generic *confa = *(struct config_generic **) a;
3065 struct config_generic *confb = *(struct config_generic **) b;
3067 return guc_name_compare(confa->name, confb->name);
3071 * the bare comparison function for GUC names
3074 guc_name_compare(const char *namea, const char *nameb)
3077 * The temptation to use strcasecmp() here must be resisted, because the
3078 * array ordering has to remain stable across setlocale() calls. So, build
3079 * our own with a simple ASCII-only downcasing.
3081 while (*namea && *nameb)
3083 char cha = *namea++;
3084 char chb = *nameb++;
3086 if (cha >= 'A' && cha <= 'Z')
3088 if (chb >= 'A' && chb <= 'Z')
3094 return 1; /* a is longer */
3096 return -1; /* b is longer */
3102 * Initialize GUC options during program startup.
3104 * Note that we cannot read the config file yet, since we have not yet
3105 * processed command-line switches.
3108 InitializeGUCOptions(void)
3115 * Before log_line_prefix could possibly receive a nonempty setting, make
3116 * sure that timezone processing is minimally alive (see elog.c).
3118 pg_timezone_pre_initialize();
3121 * Build sorted array of all GUC variables.
3123 build_guc_variables();
3126 * Load all variables with their compiled-in defaults, and initialize
3127 * status fields as needed.
3129 for (i = 0; i < num_guc_variables; i++)
3131 struct config_generic *gconf = guc_variables[i];
3134 gconf->reset_source = PGC_S_DEFAULT;
3135 gconf->source = PGC_S_DEFAULT;
3136 gconf->stack = NULL;
3138 switch (gconf->vartype)
3142 struct config_bool *conf = (struct config_bool *) gconf;
3144 if (conf->assign_hook)
3145 if (!(*conf->assign_hook) (conf->boot_val, true,
3147 elog(FATAL, "failed to initialize %s to %d",
3148 conf->gen.name, (int) conf->boot_val);
3149 *conf->variable = conf->reset_val = conf->boot_val;
3154 struct config_int *conf = (struct config_int *) gconf;
3156 Assert(conf->boot_val >= conf->min);
3157 Assert(conf->boot_val <= conf->max);
3158 if (conf->assign_hook)
3159 if (!(*conf->assign_hook) (conf->boot_val, true,
3161 elog(FATAL, "failed to initialize %s to %d",
3162 conf->gen.name, conf->boot_val);
3163 *conf->variable = conf->reset_val = conf->boot_val;
3168 struct config_real *conf = (struct config_real *) gconf;
3170 Assert(conf->boot_val >= conf->min);
3171 Assert(conf->boot_val <= conf->max);
3172 if (conf->assign_hook)
3173 if (!(*conf->assign_hook) (conf->boot_val, true,
3175 elog(FATAL, "failed to initialize %s to %g",
3176 conf->gen.name, conf->boot_val);
3177 *conf->variable = conf->reset_val = conf->boot_val;
3182 struct config_string *conf = (struct config_string *) gconf;
3185 *conf->variable = NULL;
3186 conf->reset_val = NULL;
3188 if (conf->boot_val == NULL)
3190 /* leave the value NULL, do not call assign hook */
3194 str = guc_strdup(FATAL, conf->boot_val);
3195 conf->reset_val = str;
3197 if (conf->assign_hook)
3201 newstr = (*conf->assign_hook) (str, true,
3205 elog(FATAL, "failed to initialize %s to \"%s\"",
3206 conf->gen.name, str);
3208 else if (newstr != str)
3213 * See notes in set_config_option about casting
3215 str = (char *) newstr;
3216 conf->reset_val = str;
3219 *conf->variable = str;
3224 struct config_enum *conf = (struct config_enum *) gconf;
3226 if (conf->assign_hook)
3227 if (!(*conf->assign_hook) (conf->boot_val, true,
3229 elog(FATAL, "failed to initialize %s to %s",
3231 config_enum_lookup_by_value(conf, conf->boot_val));
3232 *conf->variable = conf->reset_val = conf->boot_val;
3240 reporting_enabled = false;
3243 * Prevent any attempt to override the transaction modes from
3244 * non-interactive sources.
3246 SetConfigOption("transaction_isolation", "default",
3247 PGC_POSTMASTER, PGC_S_OVERRIDE);
3248 SetConfigOption("transaction_read_only", "no",
3249 PGC_POSTMASTER, PGC_S_OVERRIDE);
3252 * For historical reasons, some GUC parameters can receive defaults from
3253 * environment variables. Process those settings. NB: if you add or
3254 * remove anything here, see also ProcessConfigFile().
3257 env = getenv("PGPORT");
3259 SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3261 env = getenv("PGDATESTYLE");
3263 SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3265 env = getenv("PGCLIENTENCODING");
3267 SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
3270 * rlimit isn't exactly an "environment variable", but it behaves about
3271 * the same. If we can identify the platform stack depth rlimit, increase
3272 * default stack depth setting up to whatever is safe (but at most 2MB).
3274 stack_rlimit = get_stack_depth_rlimit();
3275 if (stack_rlimit > 0)
3277 int new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;
3279 if (new_limit > 100)
3283 new_limit = Min(new_limit, 2048);
3284 sprintf(limbuf, "%d", new_limit);
3285 SetConfigOption("max_stack_depth", limbuf,
3286 PGC_POSTMASTER, PGC_S_ENV_VAR);
3293 * Select the configuration files and data directory to be used, and
3294 * do the initial read of postgresql.conf.
3296 * This is called after processing command-line switches.
3297 * userDoption is the -D switch value if any (NULL if unspecified).
3298 * progname is just for use in error messages.
3300 * Returns true on success; on failure, prints a suitable error message
3301 * to stderr and returns false.
3304 SelectConfigFiles(const char *userDoption, const char *progname)
3308 struct stat stat_buf;
3310 /* configdir is -D option, or $PGDATA if no -D */
3312 configdir = make_absolute_path(userDoption);
3314 configdir = make_absolute_path(getenv("PGDATA"));
3317 * Find the configuration file: if config_file was specified on the
3318 * command line, use it, else use configdir/postgresql.conf. In any case
3319 * ensure the result is an absolute path, so that it will be interpreted
3320 * the same way by future backends.
3323 fname = make_absolute_path(ConfigFileName);
3326 fname = guc_malloc(FATAL,
3327 strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
3328 sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
3332 write_stderr("%s does not know where to find the server configuration file.\n"
3333 "You must specify the --config-file or -D invocation "
3334 "option or set the PGDATA environment variable.\n",
3340 * Set the ConfigFileName GUC variable to its final value, ensuring that
3341 * it can't be overridden later.
3343 SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3347 * Now read the config file for the first time.
3349 if (stat(ConfigFileName, &stat_buf) != 0)
3351 write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
3352 progname, ConfigFileName, strerror(errno));
3356 ProcessConfigFile(PGC_POSTMASTER);
3359 * If the data_directory GUC variable has been set, use that as DataDir;
3360 * otherwise use configdir if set; else punt.
3362 * Note: SetDataDir will copy and absolute-ize its argument, so we don't
3366 SetDataDir(data_directory);
3368 SetDataDir(configdir);
3371 write_stderr("%s does not know where to find the database system data.\n"
3372 "This can be specified as \"data_directory\" in \"%s\", "
3373 "or by the -D invocation option, or by the "
3374 "PGDATA environment variable.\n",
3375 progname, ConfigFileName);
3380 * Reflect the final DataDir value back into the data_directory GUC var.
3381 * (If you are wondering why we don't just make them a single variable,
3382 * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
3383 * child backends specially. XXX is that still true? Given that we now
3384 * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
3385 * DataDir in advance.)
3387 SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
3390 * Figure out where pg_hba.conf is, and make sure the path is absolute.
3393 fname = make_absolute_path(HbaFileName);
3396 fname = guc_malloc(FATAL,
3397 strlen(configdir) + strlen(HBA_FILENAME) + 2);
3398 sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
3402 write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
3403 "This can be specified as \"hba_file\" in \"%s\", "
3404 "or by the -D invocation option, or by the "
3405 "PGDATA environment variable.\n",
3406 progname, ConfigFileName);
3409 SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3413 * Likewise for pg_ident.conf.
3416 fname = make_absolute_path(IdentFileName);
3419 fname = guc_malloc(FATAL,
3420 strlen(configdir) + strlen(IDENT_FILENAME) + 2);
3421 sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
3425 write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
3426 "This can be specified as \"ident_file\" in \"%s\", "
3427 "or by the -D invocation option, or by the "
3428 "PGDATA environment variable.\n",
3429 progname, ConfigFileName);
3432 SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
3442 * Reset all options to their saved default values (implements RESET ALL)
3445 ResetAllOptions(void)
3449 for (i = 0; i < num_guc_variables; i++)
3451 struct config_generic *gconf = guc_variables[i];
3453 /* Don't reset non-SET-able values */
3454 if (gconf->context != PGC_SUSET &&
3455 gconf->context != PGC_USERSET)
3457 /* Don't reset if special exclusion from RESET ALL */
3458 if (gconf->flags & GUC_NO_RESET_ALL)
3460 /* No need to reset if wasn't SET */
3461 if (gconf->source <= PGC_S_OVERRIDE)
3464 /* Save old value to support transaction abort */
3465 push_old_value(gconf, GUC_ACTION_SET);
3467 switch (gconf->vartype)
3471 struct config_bool *conf = (struct config_bool *) gconf;
3473 if (conf->assign_hook)
3474 if (!(*conf->assign_hook) (conf->reset_val, true,
3476 elog(ERROR, "failed to reset %s", conf->gen.name);
3477 *conf->variable = conf->reset_val;
3478 conf->gen.source = conf->gen.reset_source;
3483 struct config_int *conf = (struct config_int *) gconf;
3485 if (conf->assign_hook)
3486 if (!(*conf->assign_hook) (conf->reset_val, true,
3488 elog(ERROR, "failed to reset %s", conf->gen.name);
3489 *conf->variable = conf->reset_val;
3490 conf->gen.source = conf->gen.reset_source;
3495 struct config_real *conf = (struct config_real *) gconf;
3497 if (conf->assign_hook)
3498 if (!(*conf->assign_hook) (conf->reset_val, true,
3500 elog(ERROR, "failed to reset %s", conf->gen.name);
3501 *conf->variable = conf->reset_val;
3502 conf->gen.source = conf->gen.reset_source;
3507 struct config_string *conf = (struct config_string *) gconf;
3510 /* We need not strdup here */
3511 str = conf->reset_val;
3513 if (conf->assign_hook && str)
3517 newstr = (*conf->assign_hook) (str, true,
3520 elog(ERROR, "failed to reset %s", conf->gen.name);
3521 else if (newstr != str)
3524 * See notes in set_config_option about casting
3526 str = (char *) newstr;
3530 set_string_field(conf, conf->variable, str);
3531 conf->gen.source = conf->gen.reset_source;
3536 struct config_enum *conf = (struct config_enum *) gconf;
3538 if (conf->assign_hook)
3539 if (!(*conf->assign_hook) (conf->reset_val, true,
3541 elog(ERROR, "failed to reset %s", conf->gen.name);
3542 *conf->variable = conf->reset_val;
3543 conf->gen.source = conf->gen.reset_source;
3548 if (gconf->flags & GUC_REPORT)
3549 ReportGUCOption(gconf);
3556 * Push previous state during transactional assignment to a GUC variable.
3559 push_old_value(struct config_generic * gconf, GucAction action)
3563 /* If we're not inside a nest level, do nothing */
3564 if (GUCNestLevel == 0)
3567 /* Do we already have a stack entry of the current nest level? */
3568 stack = gconf->stack;
3569 if (stack && stack->nest_level >= GUCNestLevel)
3571 /* Yes, so adjust its state if necessary */
3572 Assert(stack->nest_level == GUCNestLevel);
3575 case GUC_ACTION_SET:
3576 /* SET overrides any prior action at same nest level */
3577 if (stack->state == GUC_SET_LOCAL)
3579 /* must discard old masked value */
3580 discard_stack_value(gconf, &stack->masked);
3582 stack->state = GUC_SET;
3584 case GUC_ACTION_LOCAL:
3585 if (stack->state == GUC_SET)
3587 /* SET followed by SET LOCAL, remember SET's value */
3588 set_stack_value(gconf, &stack->masked);
3589 stack->state = GUC_SET_LOCAL;
3591 /* in all other cases, no change to stack entry */
3593 case GUC_ACTION_SAVE:
3594 /* Could only have a prior SAVE of same variable */
3595 Assert(stack->state == GUC_SAVE);
3598 Assert(guc_dirty); /* must be set already */
3603 * Push a new stack entry
3605 * We keep all the stack entries in TopTransactionContext for simplicity.
3607 stack = (GucStack *) MemoryContextAllocZero(TopTransactionContext,
3610 stack->prev = gconf->stack;
3611 stack->nest_level = GUCNestLevel;
3614 case GUC_ACTION_SET:
3615 stack->state = GUC_SET;
3617 case GUC_ACTION_LOCAL:
3618 stack->state = GUC_LOCAL;
3620 case GUC_ACTION_SAVE:
3621 stack->state = GUC_SAVE;
3624 stack->source = gconf->source;
3625 set_stack_value(gconf, &stack->prior);
3627 gconf->stack = stack;
3629 /* Ensure we remember to pop at end of xact */
3635 * Do GUC processing at main transaction start.
3641 * The nest level should be 0 between transactions; if it isn't, somebody
3642 * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
3643 * throw a warning but make no other effort to clean up.
3645 if (GUCNestLevel != 0)
3646 elog(WARNING, "GUC nest level = %d at transaction start",
3652 * Enter a new nesting level for GUC values. This is called at subtransaction
3653 * start and when entering a function that has proconfig settings. NOTE that
3654 * we must not risk error here, else subtransaction start will be unhappy.
3657 NewGUCNestLevel(void)
3659 return ++GUCNestLevel;
3663 * Do GUC processing at transaction or subtransaction commit or abort, or
3664 * when exiting a function that has proconfig settings. (The name is thus
3665 * a bit of a misnomer; perhaps it should be ExitGUCNestLevel or some such.)
3666 * During abort, we discard all GUC settings that were applied at nesting
3667 * levels >= nestLevel. nestLevel == 1 corresponds to the main transaction.
3670 AtEOXact_GUC(bool isCommit, int nestLevel)
3675 Assert(nestLevel > 0 && nestLevel <= GUCNestLevel);
3677 /* Quick exit if nothing's changed in this transaction */
3680 GUCNestLevel = nestLevel - 1;
3684 still_dirty = false;
3685 for (i = 0; i < num_guc_variables; i++)
3687 struct config_generic *gconf = guc_variables[i];
3691 * Process and pop each stack entry within the nest level. To
3692 * simplify fmgr_security_definer(), we allow failure exit from a
3693 * function-with-SET-options to be recovered at the surrounding
3694 * transaction or subtransaction abort; so there could be more than
3695 * one stack entry to pop.
3697 while ((stack = gconf->stack) != NULL &&
3698 stack->nest_level >= nestLevel)
3700 GucStack *prev = stack->prev;
3701 bool restorePrior = false;
3702 bool restoreMasked = false;
3706 * In this next bit, if we don't set either restorePrior or
3707 * restoreMasked, we must "discard" any unwanted fields of the
3708 * stack entries to avoid leaking memory. If we do set one of
3709 * those flags, unused fields will be cleaned up after restoring.
3711 if (!isCommit) /* if abort, always restore prior value */
3712 restorePrior = true;
3713 else if (stack->state == GUC_SAVE)
3714 restorePrior = true;
3715 else if (stack->nest_level == 1)
3717 /* transaction commit */
3718 if (stack->state == GUC_SET_LOCAL)
3719 restoreMasked = true;
3720 else if (stack->state == GUC_SET)
3722 /* we keep the current active value */
3723 discard_stack_value(gconf, &stack->prior);
3725 else /* must be GUC_LOCAL */
3726 restorePrior = true;
3728 else if (prev == NULL ||
3729 prev->nest_level < stack->nest_level - 1)
3731 /* decrement entry's level and do not pop it */
3732 stack->nest_level--;
3738 * We have to merge this stack entry into prev. See README for
3739 * discussion of this bit.
3741 switch (stack->state)
3744 Assert(false); /* can't get here */
3747 /* next level always becomes SET */
3748 discard_stack_value(gconf, &stack->prior);
3749 if (prev->state == GUC_SET_LOCAL)
3750 discard_stack_value(gconf, &prev->masked);
3751 prev->state = GUC_SET;
3755 if (prev->state == GUC_SET)
3757 /* LOCAL migrates down */
3758 prev->masked = stack->prior;
3759 prev->state = GUC_SET_LOCAL;
3763 /* else just forget this stack level */
3764 discard_stack_value(gconf, &stack->prior);
3769 /* prior state at this level no longer wanted */
3770 discard_stack_value(gconf, &stack->prior);
3771 /* copy down the masked state */
3772 if (prev->state == GUC_SET_LOCAL)
3773 discard_stack_value(gconf, &prev->masked);
3774 prev->masked = stack->masked;
3775 prev->state = GUC_SET_LOCAL;
3782 if (restorePrior || restoreMasked)
3784 /* Perform appropriate restoration of the stacked value */
3785 union config_var_value newvalue;
3786 GucSource newsource;
3790 newvalue = stack->masked;
3791 newsource = PGC_S_SESSION;
3795 newvalue = stack->prior;
3796 newsource = stack->source;
3799 switch (gconf->vartype)
3803 struct config_bool *conf = (struct config_bool *) gconf;
3804 bool newval = newvalue.boolval;
3806 if (*conf->variable != newval)
3808 if (conf->assign_hook)
3809 if (!(*conf->assign_hook) (newval,
3810 true, PGC_S_OVERRIDE))
3811 elog(LOG, "failed to commit %s",
3813 *conf->variable = newval;
3820 struct config_int *conf = (struct config_int *) gconf;
3821 int newval = newvalue.intval;
3823 if (*conf->variable != newval)
3825 if (conf->assign_hook)
3826 if (!(*conf->assign_hook) (newval,
3827 true, PGC_S_OVERRIDE))
3828 elog(LOG, "failed to commit %s",
3830 *conf->variable = newval;
3837 struct config_real *conf = (struct config_real *) gconf;
3838 double newval = newvalue.realval;
3840 if (*conf->variable != newval)
3842 if (conf->assign_hook)
3843 if (!(*conf->assign_hook) (newval,
3844 true, PGC_S_OVERRIDE))
3845 elog(LOG, "failed to commit %s",
3847 *conf->variable = newval;
3854 struct config_string *conf = (struct config_string *) gconf;
3855 char *newval = newvalue.stringval;
3857 if (*conf->variable != newval)
3859 if (conf->assign_hook && newval)
3863 newstr = (*conf->assign_hook) (newval, true,
3866 elog(LOG, "failed to commit %s",
3868 else if (newstr != newval)
3871 * If newval should now be freed,
3872 * it'll be taken care of below.
3874 * See notes in set_config_option
3877 newval = (char *) newstr;
3881 set_string_field(conf, conf->variable, newval);
3886 * Release stacked values if not used anymore. We
3887 * could use discard_stack_value() here, but since
3888 * we have type-specific code anyway, might as
3891 set_string_field(conf, &stack->prior.stringval, NULL);
3892 set_string_field(conf, &stack->masked.stringval, NULL);
3897 struct config_enum *conf = (struct config_enum *) gconf;
3898 int newval = newvalue.enumval;
3900 if (*conf->variable != newval)
3902 if (conf->assign_hook)
3903 if (!(*conf->assign_hook) (newval,
3904 true, PGC_S_OVERRIDE))
3905 elog(LOG, "failed to commit %s",
3907 *conf->variable = newval;
3914 gconf->source = newsource;
3917 /* Finish popping the state stack */
3918 gconf->stack = prev;
3921 /* Report new value if we changed it */
3922 if (changed && (gconf->flags & GUC_REPORT))
3923 ReportGUCOption(gconf);
3924 } /* end of stack-popping loop */
3930 /* If there are no remaining stack entries, we can reset guc_dirty */
3931 guc_dirty = still_dirty;
3933 /* Update nesting level */
3934 GUCNestLevel = nestLevel - 1;
3939 * Start up automatic reporting of changes to variables marked GUC_REPORT.
3940 * This is executed at completion of backend startup.
3943 BeginReportingGUCOptions(void)
3948 * Don't do anything unless talking to an interactive frontend of protocol
3951 if (whereToSendOutput != DestRemote ||
3952 PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
3955 reporting_enabled = true;
3957 /* Transmit initial values of interesting variables */
3958 for (i = 0; i < num_guc_variables; i++)
3960 struct config_generic *conf = guc_variables[i];
3962 if (conf->flags & GUC_REPORT)
3963 ReportGUCOption(conf);
3968 * ReportGUCOption: if appropriate, transmit option value to frontend
3971 ReportGUCOption(struct config_generic * record)
3973 if (reporting_enabled && (record->flags & GUC_REPORT))
3975 char *val = _ShowOption(record, false);
3976 StringInfoData msgbuf;
3978 pq_beginmessage(&msgbuf, 'S');
3979 pq_sendstring(&msgbuf, record->name);
3980 pq_sendstring(&msgbuf, val);
3981 pq_endmessage(&msgbuf);
3989 * Try to interpret value as boolean value. Valid values are: true,
3990 * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
3991 * If the string parses okay, return true, else false.
3992 * If okay and result is not NULL, return the value in *result.
3995 parse_bool(const char *value, bool *result)
3997 size_t len = strlen(value);
3999 if (pg_strncasecmp(value, "true", len) == 0)
4004 else if (pg_strncasecmp(value, "false", len) == 0)
4010 else if (pg_strncasecmp(value, "yes", len) == 0)
4015 else if (pg_strncasecmp(value, "no", len) == 0)
4021 /* 'o' is not unique enough */
4022 else if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
4027 else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
4033 else if (pg_strcasecmp(value, "1") == 0)
4038 else if (pg_strcasecmp(value, "0") == 0)
4047 *result = false; /* suppress compiler warning */
4056 * Try to parse value as an integer. The accepted formats are the
4057 * usual decimal, octal, or hexadecimal formats, optionally followed by
4058 * a unit name if "flags" indicates a unit is allowed.
4060 * If the string parses okay, return true, else false.
4061 * If okay and result is not NULL, return the value in *result.
4062 * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
4063 * HINT message, or NULL if no hint provided.
4066 parse_int(const char *value, int *result, int flags, const char **hintmsg)
4071 /* To suppress compiler warnings, always set output params */
4077 /* We assume here that int64 is at least as wide as long */
4079 val = strtol(value, &endptr, 0);
4081 if (endptr == value)
4082 return false; /* no HINT for integer syntax error */
4084 if (errno == ERANGE || val != (int64) ((int32) val))
4087 *hintmsg = gettext_noop("Value exceeds integer range.");
4091 /* allow whitespace between integer and unit */
4092 while (isspace((unsigned char) *endptr))
4095 /* Handle possible unit */
4096 if (*endptr != '\0')
4099 * Note: the multiple-switch coding technique here is a bit tedious,
4100 * but seems necessary to avoid intermediate-value overflows.
4102 * If INT64_IS_BUSTED (ie, it's really int32) we will fail to detect
4103 * overflow due to units conversion, but there are few enough such
4104 * machines that it does not seem worth trying to be smarter.
4106 if (flags & GUC_UNIT_MEMORY)
4108 /* Set hint for use if no match or trailing garbage */
4110 *hintmsg = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", and \"GB\".");
4112 #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
4113 #error BLCKSZ must be between 1KB and 1MB
4115 #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
4116 #error XLOG_BLCKSZ must be between 1KB and 1MB
4119 if (strncmp(endptr, "kB", 2) == 0)
4122 switch (flags & GUC_UNIT_MEMORY)
4124 case GUC_UNIT_BLOCKS:
4125 val /= (BLCKSZ / 1024);
4127 case GUC_UNIT_XBLOCKS:
4128 val /= (XLOG_BLCKSZ / 1024);
4132 else if (strncmp(endptr, "MB", 2) == 0)
4135 switch (flags & GUC_UNIT_MEMORY)
4140 case GUC_UNIT_BLOCKS:
4141 val *= KB_PER_MB / (BLCKSZ / 1024);
4143 case GUC_UNIT_XBLOCKS:
4144 val *= KB_PER_MB / (XLOG_BLCKSZ / 1024);
4148 else if (strncmp(endptr, "GB", 2) == 0)
4151 switch (flags & GUC_UNIT_MEMORY)
4156 case GUC_UNIT_BLOCKS:
4157 val *= KB_PER_GB / (BLCKSZ / 1024);
4159 case GUC_UNIT_XBLOCKS:
4160 val *= KB_PER_GB / (XLOG_BLCKSZ / 1024);
4165 else if (flags & GUC_UNIT_TIME)
4167 /* Set hint for use if no match or trailing garbage */
4169 *hintmsg = gettext_noop("Valid units for this parameter are \"ms\", \"s\", \"min\", \"h\", and \"d\".");
4171 if (strncmp(endptr, "ms", 2) == 0)
4174 switch (flags & GUC_UNIT_TIME)
4184 else if (strncmp(endptr, "s", 1) == 0)
4187 switch (flags & GUC_UNIT_TIME)
4197 else if (strncmp(endptr, "min", 3) == 0)
4200 switch (flags & GUC_UNIT_TIME)
4210 else if (strncmp(endptr, "h", 1) == 0)
4213 switch (flags & GUC_UNIT_TIME)
4226 else if (strncmp(endptr, "d", 1) == 0)
4229 switch (flags & GUC_UNIT_TIME)
4244 /* allow whitespace after unit */
4245 while (isspace((unsigned char) *endptr))
4248 if (*endptr != '\0')
4249 return false; /* appropriate hint, if any, already set */
4251 /* Check for overflow due to units conversion */
4252 if (val != (int64) ((int32) val))
4255 *hintmsg = gettext_noop("Value exceeds integer range.");
4261 *result = (int) val;
4268 * Try to parse value as a floating point number in the usual format.
4269 * If the string parses okay, return true, else false.
4270 * If okay and result is not NULL, return the value in *result.
4273 parse_real(const char *value, double *result)
4279 *result = 0; /* suppress compiler warning */
4282 val = strtod(value, &endptr);
4283 if (endptr == value || errno == ERANGE)
4286 /* allow whitespace after number */
4287 while (isspace((unsigned char) *endptr))
4289 if (*endptr != '\0')
4299 * Lookup the name for an enum option with the selected value.
4300 * Should only ever be called with known-valid values, so throws
4301 * an elog(ERROR) if the enum option is not found.
4303 * The returned string is a pointer to static data and not
4304 * allocated for modification.
4307 config_enum_lookup_by_value(struct config_enum *record, int val)
4309 const struct config_enum_entry *entry = record->options;
4310 while (entry && entry->name)
4312 if (entry->val == val)
4316 elog(ERROR, "could not find enum option %d for %s",
4317 val, record->gen.name);
4318 return NULL; /* silence compiler */
4323 * Lookup the value for an enum option with the selected name
4324 * (case-insensitive).
4325 * If the enum option is found, sets the retval value and returns
4326 * true. If it's not found, return FALSE and retval is set to 0.
4330 config_enum_lookup_by_name(struct config_enum *record, const char *value, int *retval)
4332 const struct config_enum_entry *entry = record->options;
4335 *retval = 0; /* suppress compiler warning */
4337 while (entry && entry->name)
4339 if (pg_strcasecmp(value, entry->name) == 0)
4341 *retval = entry->val;
4351 * Return a list of all available options for an enum, excluding
4352 * hidden ones, separated by ", " (comma-space).
4353 * If prefix is non-NULL, it is added before the first enum value.
4354 * If suffix is non-NULL, it is added to the end of the string.
4357 config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix)
4359 const struct config_enum_entry *entry = record->options;
4363 if (!entry || !entry->name)
4364 return NULL; /* Should not happen */
4366 while (entry && entry->name)
4369 len += strlen(entry->name) + 2; /* string and ", " */
4374 hintmsg = palloc(len + strlen(prefix) + strlen(suffix) + 2);
4376 strcpy(hintmsg, prefix);
4378 entry = record->options;
4379 while (entry && entry->name)
4383 strcat(hintmsg, entry->name);
4384 strcat(hintmsg, ", ");
4390 len = strlen(hintmsg);
4393 * All the entries may have been hidden, leaving the string empty
4394 * if no prefix was given. This indicates a broken GUC setup, since
4395 * there is no use for an enum without any values, so we just check
4396 * to make sure we don't write to invalid memory instead of actually
4397 * trying to do something smart with it.
4400 /* Replace final comma/space */
4401 hintmsg[len-2] = '\0';
4403 strcat(hintmsg, suffix);
4410 * Call a GucStringAssignHook function, being careful to free the
4411 * "newval" string if the hook ereports.
4413 * This is split out of set_config_option just to avoid the "volatile"
4414 * qualifiers that would otherwise have to be plastered all over.
4417 call_string_assign_hook(GucStringAssignHook assign_hook,
4418 char *newval, bool doit, GucSource source)
4424 result = (*assign_hook) (newval, doit, source);
4438 * Sets option `name' to given value. The value should be a string
4439 * which is going to be parsed and converted to the appropriate data
4440 * type. The context and source parameters indicate in which context this
4441 * function is being called so it can apply the access restrictions
4444 * If value is NULL, set the option to its default value (normally the
4445 * reset_val, but if source == PGC_S_DEFAULT we instead use the boot_val).
4447 * action indicates whether to set the value globally in the session, locally
4448 * to the current top transaction, or just for the duration of a function call.
4450 * If changeVal is false then don't really set the option but do all
4451 * the checks to see if it would work.
4453 * If there is an error (non-existing option, invalid value) then an
4454 * ereport(ERROR) is thrown *unless* this is called in a context where we
4455 * don't want to ereport (currently, startup or SIGHUP config file reread).
4456 * In that case we write a suitable error message via ereport(LOG) and
4457 * return false. This is working around the deficiencies in the ereport
4458 * mechanism, so don't blame me. In all other cases, the function
4459 * returns true, including cases where the input is valid but we chose
4460 * not to apply it because of context or source-priority considerations.
4462 * See also SetConfigOption for an external interface.
4465 set_config_option(const char *name, const char *value,
4466 GucContext context, GucSource source,
4467 GucAction action, bool changeVal)
4469 struct config_generic *record;
4473 if (context == PGC_SIGHUP || source == PGC_S_DEFAULT)
4476 * To avoid cluttering the log, only the postmaster bleats loudly
4477 * about problems with the config file.
4479 elevel = IsUnderPostmaster ? DEBUG3 : LOG;
4481 else if (source == PGC_S_DATABASE || source == PGC_S_USER)
4486 record = find_option(name, true, elevel);
4490 (errcode(ERRCODE_UNDEFINED_OBJECT),
4491 errmsg("unrecognized configuration parameter \"%s\"", name)));
4496 * If source is postgresql.conf, mark the found record with
4497 * GUC_IS_IN_FILE. This is for the convenience of ProcessConfigFile. Note
4498 * that we do it even if changeVal is false, since ProcessConfigFile wants
4499 * the marking to occur during its testing pass.
4501 if (source == PGC_S_FILE)
4502 record->status |= GUC_IS_IN_FILE;
4505 * Check if the option can be set at this time. See guc.h for the precise
4506 * rules. Note that we don't want to throw errors if we're in the SIGHUP
4507 * context. In that case we just ignore the attempt and return true.
4509 switch (record->context)
4512 if (context == PGC_SIGHUP)
4514 if (context != PGC_INTERNAL)
4517 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4518 errmsg("parameter \"%s\" cannot be changed",
4523 case PGC_POSTMASTER:
4524 if (context == PGC_SIGHUP)
4527 * We are reading a PGC_POSTMASTER var from postgresql.conf.
4528 * We can't change the setting, so give a warning if the DBA
4529 * tries to change it. (Throwing an error would be more
4530 * consistent, but seems overly rigid.)
4532 if (changeVal && !is_newvalue_equal(record, value))
4534 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4535 errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
4539 if (context != PGC_POSTMASTER)
4542 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4543 errmsg("parameter \"%s\" cannot be changed after server start",
4549 if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
4552 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4553 errmsg("parameter \"%s\" cannot be changed now",
4559 * Hmm, the idea of the SIGHUP context is "ought to be global, but
4560 * can be changed after postmaster start". But there's nothing
4561 * that prevents a crafty administrator from sending SIGHUP
4562 * signals to individual backends only.
4566 if (context == PGC_SIGHUP)
4569 * If a PGC_BACKEND parameter is changed in the config file,
4570 * we want to accept the new value in the postmaster (whence
4571 * it will propagate to subsequently-started backends), but
4572 * ignore it in existing backends. This is a tad klugy, but
4573 * necessary because we don't re-read the config file during
4576 if (IsUnderPostmaster)
4579 else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
4582 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4583 errmsg("parameter \"%s\" cannot be set after connection start",
4589 if (context == PGC_USERSET || context == PGC_BACKEND)
4592 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4593 errmsg("permission denied to set parameter \"%s\"",
4604 * Should we set reset/stacked values? (If so, the behavior is not
4605 * transactional.) This is done either when we get a default value from
4606 * the database's/user's/client's default settings or when we reset a
4607 * value to its default.
4609 makeDefault = changeVal && (source <= PGC_S_OVERRIDE) &&
4610 ((value != NULL) || source == PGC_S_DEFAULT);
4613 * Ignore attempted set if overridden by previously processed setting.
4614 * However, if changeVal is false then plow ahead anyway since we are
4615 * trying to find out if the value is potentially good, not actually use
4616 * it. Also keep going if makeDefault is true, since we may want to set
4617 * the reset/stacked values even if we can't set the variable itself.
4619 if (record->source > source)
4621 if (changeVal && !makeDefault)
4623 elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
4631 * Evaluate value and set variable.
4633 switch (record->vartype)
4637 struct config_bool *conf = (struct config_bool *) record;
4642 if (!parse_bool(value, &newval))
4645 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4646 errmsg("parameter \"%s\" requires a Boolean value",
4651 else if (source == PGC_S_DEFAULT)
4652 newval = conf->boot_val;
4655 newval = conf->reset_val;
4656 source = conf->gen.reset_source;
4659 /* Save old value to support transaction abort */
4660 if (changeVal && !makeDefault)
4661 push_old_value(&conf->gen, action);
4663 if (conf->assign_hook)
4664 if (!(*conf->assign_hook) (newval, changeVal, source))
4667 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4668 errmsg("invalid value for parameter \"%s\": %d",
4669 name, (int) newval)));
4675 *conf->variable = newval;
4676 conf->gen.source = source;
4682 if (conf->gen.reset_source <= source)
4684 conf->reset_val = newval;
4685 conf->gen.reset_source = source;
4687 for (stack = conf->gen.stack; stack; stack = stack->prev)
4689 if (stack->source <= source)
4691 stack->prior.boolval = newval;
4692 stack->source = source;
4701 struct config_int *conf = (struct config_int *) record;
4706 const char *hintmsg;
4708 if (!parse_int(value, &newval, conf->gen.flags, &hintmsg))
4711 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4712 errmsg("invalid value for parameter \"%s\": \"%s\"",
4714 hintmsg ? errhint(hintmsg) : 0));
4717 if (newval < conf->min || newval > conf->max)
4720 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4721 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
4722 newval, name, conf->min, conf->max)));
4726 else if (source == PGC_S_DEFAULT)
4727 newval = conf->boot_val;
4730 newval = conf->reset_val;
4731 source = conf->gen.reset_source;
4734 /* Save old value to support transaction abort */
4735 if (changeVal && !makeDefault)
4736 push_old_value(&conf->gen, action);
4738 if (conf->assign_hook)
4739 if (!(*conf->assign_hook) (newval, changeVal, source))
4742 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4743 errmsg("invalid value for parameter \"%s\": %d",
4750 *conf->variable = newval;
4751 conf->gen.source = source;
4757 if (conf->gen.reset_source <= source)
4759 conf->reset_val = newval;
4760 conf->gen.reset_source = source;
4762 for (stack = conf->gen.stack; stack; stack = stack->prev)
4764 if (stack->source <= source)
4766 stack->prior.intval = newval;
4767 stack->source = source;
4776 struct config_real *conf = (struct config_real *) record;
4781 if (!parse_real(value, &newval))
4784 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4785 errmsg("parameter \"%s\" requires a numeric value",
4789 if (newval < conf->min || newval > conf->max)
4792 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4793 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
4794 newval, name, conf->min, conf->max)));
4798 else if (source == PGC_S_DEFAULT)
4799 newval = conf->boot_val;
4802 newval = conf->reset_val;
4803 source = conf->gen.reset_source;
4806 /* Save old value to support transaction abort */
4807 if (changeVal && !makeDefault)
4808 push_old_value(&conf->gen, action);
4810 if (conf->assign_hook)
4811 if (!(*conf->assign_hook) (newval, changeVal, source))
4814 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4815 errmsg("invalid value for parameter \"%s\": %g",
4822 *conf->variable = newval;
4823 conf->gen.source = source;
4829 if (conf->gen.reset_source <= source)
4831 conf->reset_val = newval;
4832 conf->gen.reset_source = source;
4834 for (stack = conf->gen.stack; stack; stack = stack->prev)
4836 if (stack->source <= source)
4838 stack->prior.realval = newval;
4839 stack->source = source;
4848 struct config_string *conf = (struct config_string *) record;
4853 newval = guc_strdup(elevel, value);
4858 * The only sort of "parsing" check we need to do is apply
4859 * truncation if GUC_IS_NAME.
4861 if (conf->gen.flags & GUC_IS_NAME)
4862 truncate_identifier(newval, strlen(newval), true);
4864 else if (source == PGC_S_DEFAULT)
4866 if (conf->boot_val == NULL)
4870 newval = guc_strdup(elevel, conf->boot_val);
4878 * We could possibly avoid strdup here, but easier to make
4879 * this case work the same as the normal assignment case;
4880 * note the possible free of newval below.
4882 if (conf->reset_val == NULL)
4886 newval = guc_strdup(elevel, conf->reset_val);
4890 source = conf->gen.reset_source;
4893 /* Save old value to support transaction abort */
4894 if (changeVal && !makeDefault)
4895 push_old_value(&conf->gen, action);
4897 if (conf->assign_hook && newval)
4899 const char *hookresult;
4902 * If the hook ereports, we have to make sure we free
4903 * newval, else it will be a permanent memory leak.
4905 hookresult = call_string_assign_hook(conf->assign_hook,
4909 if (hookresult == NULL)
4913 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4914 errmsg("invalid value for parameter \"%s\": \"%s\"",
4915 name, value ? value : "")));
4918 else if (hookresult != newval)
4923 * Having to cast away const here is annoying, but the
4924 * alternative is to declare assign_hooks as returning
4925 * char*, which would mean they'd have to cast away
4926 * const, or as both taking and returning char*, which
4927 * doesn't seem attractive either --- we don't want
4928 * them to scribble on the passed str.
4930 newval = (char *) hookresult;
4936 set_string_field(conf, conf->variable, newval);
4937 conf->gen.source = source;
4943 if (conf->gen.reset_source <= source)
4945 set_string_field(conf, &conf->reset_val, newval);
4946 conf->gen.reset_source = source;
4948 for (stack = conf->gen.stack; stack; stack = stack->prev)
4950 if (stack->source <= source)
4952 set_string_field(conf, &stack->prior.stringval,
4954 stack->source = source;
4958 /* Perhaps we didn't install newval anywhere */
4959 if (newval && !string_field_used(conf, newval))
4965 struct config_enum *conf = (struct config_enum *) record;
4970 if (!config_enum_lookup_by_name(conf, value, &newval))
4972 char *hintmsg = config_enum_get_options(conf, "Available values: ", ".");
4975 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4976 errmsg("invalid value for parameter \"%s\": \"%s\"",
4978 hintmsg ? errhint(hintmsg) : 0));
4985 else if (source == PGC_S_DEFAULT)
4986 newval = conf->boot_val;
4989 newval = conf->reset_val;
4990 source = conf->gen.reset_source;
4993 /* Save old value to support transaction abort */
4994 if (changeVal && !makeDefault)
4995 push_old_value(&conf->gen, action);
4997 if (conf->assign_hook)
4998 if (!(*conf->assign_hook) (newval, changeVal, source))
5001 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5002 errmsg("invalid value for parameter \"%s\": \"%s\"",
5004 config_enum_lookup_by_value(conf, newval))));
5010 *conf->variable = newval;
5011 conf->gen.source = source;
5017 if (conf->gen.reset_source <= source)
5019 conf->reset_val = newval;
5020 conf->gen.reset_source = source;
5022 for (stack = conf->gen.stack; stack; stack = stack->prev)
5024 if (stack->source <= source)
5026 stack->prior.enumval = newval;
5027 stack->source = source;
5035 if (changeVal && (record->flags & GUC_REPORT))
5036 ReportGUCOption(record);
5043 * Set a config option to the given value. See also set_config_option,
5044 * this is just the wrapper to be called from outside GUC. NB: this
5045 * is used only for non-transactional operations.
5048 SetConfigOption(const char *name, const char *value,
5049 GucContext context, GucSource source)
5051 (void) set_config_option(name, value, context, source,
5052 GUC_ACTION_SET, true);
5058 * Fetch the current value of the option `name'. If the option doesn't exist,
5059 * throw an ereport and don't return.
5061 * The string is *not* allocated for modification and is really only
5062 * valid until the next call to configuration related functions.
5065 GetConfigOption(const char *name)
5067 struct config_generic *record;
5068 static char buffer[256];
5070 record = find_option(name, false, ERROR);
5073 (errcode(ERRCODE_UNDEFINED_OBJECT),
5074 errmsg("unrecognized configuration parameter \"%s\"", name)));
5075 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
5077 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5078 errmsg("must be superuser to examine \"%s\"", name)));
5080 switch (record->vartype)
5083 return *((struct config_bool *) record)->variable ? "on" : "off";
5086 snprintf(buffer, sizeof(buffer), "%d",
5087 *((struct config_int *) record)->variable);
5091 snprintf(buffer, sizeof(buffer), "%g",
5092 *((struct config_real *) record)->variable);
5096 return *((struct config_string *) record)->variable;
5099 return config_enum_lookup_by_value((struct config_enum *) record,
5100 *((struct config_enum *) record)->variable);
5106 * Get the RESET value associated with the given option.
5108 * Note: this is not re-entrant, due to use of static result buffer;
5109 * not to mention that a string variable could have its reset_val changed.
5110 * Beware of assuming the result value is good for very long.
5113 GetConfigOptionResetString(const char *name)
5115 struct config_generic *record;
5116 static char buffer[256];
5118 record = find_option(name, false, ERROR);
5121 (errcode(ERRCODE_UNDEFINED_OBJECT),
5122 errmsg("unrecognized configuration parameter \"%s\"", name)));
5123 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
5125 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5126 errmsg("must be superuser to examine \"%s\"", name)));
5128 switch (record->vartype)
5131 return ((struct config_bool *) record)->reset_val ? "on" : "off";
5134 snprintf(buffer, sizeof(buffer), "%d",
5135 ((struct config_int *) record)->reset_val);
5139 snprintf(buffer, sizeof(buffer), "%g",
5140 ((struct config_real *) record)->reset_val);
5144 return ((struct config_string *) record)->reset_val;
5147 return config_enum_lookup_by_value((struct config_enum *) record,
5148 ((struct config_enum *) record)->reset_val);
5154 * Detect whether the given configuration option can only be set by
5158 IsSuperuserConfigOption(const char *name)
5160 struct config_generic *record;
5162 record = find_option(name, false, ERROR);
5163 /* On an unrecognized name, don't error, just return false. */
5166 return (record->context == PGC_SUSET);
5171 * GUC_complaint_elevel
5172 * Get the ereport error level to use in an assign_hook's error report.
5174 * This should be used by assign hooks that want to emit a custom error
5175 * report (in addition to the generic "invalid value for option FOO" that
5176 * guc.c will provide). Note that the result might be ERROR or a lower
5177 * level, so the caller must be prepared for control to return from ereport,
5178 * or not. If control does return, return false/NULL from the hook function.
5180 * At some point it'd be nice to replace this with a mechanism that allows
5181 * the custom message to become the DETAIL line of guc.c's generic message.
5184 GUC_complaint_elevel(GucSource source)
5188 if (source == PGC_S_FILE)
5191 * To avoid cluttering the log, only the postmaster bleats loudly
5192 * about problems with the config file.
5194 elevel = IsUnderPostmaster ? DEBUG3 : LOG;
5196 else if (source == PGC_S_OVERRIDE)
5199 * If we're a postmaster child, this is probably "undo" during
5200 * transaction abort, so we don't want to clutter the log. There's
5201 * a small chance of a real problem with an OVERRIDE setting,
5202 * though, so suppressing the message entirely wouldn't be desirable.
5204 elevel = IsUnderPostmaster ? DEBUG5 : LOG;
5206 else if (source < PGC_S_INTERACTIVE)
5216 * flatten_set_variable_args
5217 * Given a parsenode List as emitted by the grammar for SET,
5218 * convert to the flat string representation used by GUC.
5220 * We need to be told the name of the variable the args are for, because
5221 * the flattening rules vary (ugh).
5223 * The result is NULL if args is NIL (ie, SET ... TO DEFAULT), otherwise
5224 * a palloc'd string.
5227 flatten_set_variable_args(const char *name, List *args)
5229 struct config_generic *record;
5234 /* Fast path if just DEFAULT */
5238 /* Else get flags for the variable */
5239 record = find_option(name, true, ERROR);
5242 (errcode(ERRCODE_UNDEFINED_OBJECT),
5243 errmsg("unrecognized configuration parameter \"%s\"", name)));
5245 flags = record->flags;
5247 /* Complain if list input and non-list variable */
5248 if ((flags & GUC_LIST_INPUT) == 0 &&
5249 list_length(args) != 1)
5251 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5252 errmsg("SET %s takes only one argument", name)));
5254 initStringInfo(&buf);
5257 * Each list member may be a plain A_Const node, or an A_Const within a
5258 * TypeCast; the latter case is supported only for ConstInterval
5259 * arguments (for SET TIME ZONE).
5263 Node *arg = (Node *) lfirst(l);
5265 TypeName *typename = NULL;
5268 if (l != list_head(args))
5269 appendStringInfo(&buf, ", ");
5271 if (IsA(arg, TypeCast))
5273 TypeCast *tc = (TypeCast *) arg;
5276 typename = tc->typename;
5279 if (!IsA(arg, A_Const))
5280 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
5281 con = (A_Const *) arg;
5283 switch (nodeTag(&con->val))
5286 appendStringInfo(&buf, "%ld", intVal(&con->val));
5289 /* represented as a string, so just copy it */
5290 appendStringInfoString(&buf, strVal(&con->val));
5293 val = strVal(&con->val);
5294 if (typename != NULL)
5297 * Must be a ConstInterval argument for TIME ZONE. Coerce
5298 * to interval and back to normalize the value and account
5306 typoid = typenameTypeId(NULL, typename, &typmod);
5307 Assert(typoid == INTERVALOID);
5310 DirectFunctionCall3(interval_in,
5311 CStringGetDatum(val),
5312 ObjectIdGetDatum(InvalidOid),
5313 Int32GetDatum(typmod));
5316 DatumGetCString(DirectFunctionCall1(interval_out,
5318 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
5323 * Plain string literal or identifier. For quote mode,
5324 * quote it if it's not a vanilla identifier.
5326 if (flags & GUC_LIST_QUOTE)
5327 appendStringInfoString(&buf, quote_identifier(val));
5329 appendStringInfoString(&buf, val);
5333 elog(ERROR, "unrecognized node type: %d",
5334 (int) nodeTag(&con->val));
5347 ExecSetVariableStmt(VariableSetStmt *stmt)
5349 GucAction action = stmt->is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET;
5354 case VAR_SET_CURRENT:
5355 set_config_option(stmt->name,
5356 ExtractSetVariableArgs(stmt),
5357 (superuser() ? PGC_SUSET : PGC_USERSET),
5365 * Special case for special SQL syntax that effectively sets more
5366 * than one variable per statement.
5368 if (strcmp(stmt->name, "TRANSACTION") == 0)
5372 foreach(head, stmt->args)
5374 DefElem *item = (DefElem *) lfirst(head);
5376 if (strcmp(item->defname, "transaction_isolation") == 0)
5377 SetPGVariable("transaction_isolation",
5378 list_make1(item->arg), stmt->is_local);
5379 else if (strcmp(item->defname, "transaction_read_only") == 0)
5380 SetPGVariable("transaction_read_only",
5381 list_make1(item->arg), stmt->is_local);
5383 elog(ERROR, "unexpected SET TRANSACTION element: %s",
5387 else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
5391 foreach(head, stmt->args)
5393 DefElem *item = (DefElem *) lfirst(head);
5395 if (strcmp(item->defname, "transaction_isolation") == 0)
5396 SetPGVariable("default_transaction_isolation",
5397 list_make1(item->arg), stmt->is_local);
5398 else if (strcmp(item->defname, "transaction_read_only") == 0)
5399 SetPGVariable("default_transaction_read_only",
5400 list_make1(item->arg), stmt->is_local);
5402 elog(ERROR, "unexpected SET SESSION element: %s",
5407 elog(ERROR, "unexpected SET MULTI element: %s",
5410 case VAR_SET_DEFAULT:
5412 set_config_option(stmt->name,
5414 (superuser() ? PGC_SUSET : PGC_USERSET),
5426 * Get the value to assign for a VariableSetStmt, or NULL if it's RESET.
5427 * The result is palloc'd.
5429 * This is exported for use by actions such as ALTER ROLE SET.
5432 ExtractSetVariableArgs(VariableSetStmt *stmt)
5437 return flatten_set_variable_args(stmt->name, stmt->args);
5438 case VAR_SET_CURRENT:
5439 return GetConfigOptionByName(stmt->name, NULL);
5446 * SetPGVariable - SET command exported as an easily-C-callable function.
5448 * This provides access to SET TO value, as well as SET TO DEFAULT (expressed
5449 * by passing args == NIL), but not SET FROM CURRENT functionality.
5452 SetPGVariable(const char *name, List *args, bool is_local)
5454 char *argstring = flatten_set_variable_args(name, args);
5456 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
5457 set_config_option(name,
5459 (superuser() ? PGC_SUSET : PGC_USERSET),
5461 is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
5466 * SET command wrapped as a SQL callable function.
5469 set_config_by_name(PG_FUNCTION_ARGS)
5476 if (PG_ARGISNULL(0))
5478 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
5479 errmsg("SET requires parameter name")));
5481 /* Get the GUC variable name */
5482 name = TextDatumGetCString(PG_GETARG_DATUM(0));
5484 /* Get the desired value or set to NULL for a reset request */
5485 if (PG_ARGISNULL(1))
5488 value = TextDatumGetCString(PG_GETARG_DATUM(1));
5491 * Get the desired state of is_local. Default to false if provided value
5494 if (PG_ARGISNULL(2))
5497 is_local = PG_GETARG_BOOL(2);
5499 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
5500 set_config_option(name,
5502 (superuser() ? PGC_SUSET : PGC_USERSET),
5504 is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
5507 /* get the new current value */
5508 new_value = GetConfigOptionByName(name, NULL);
5510 /* Convert return string to text */
5511 PG_RETURN_TEXT_P(cstring_to_text(new_value));
5516 * Common code for DefineCustomXXXVariable subroutines: allocate the
5517 * new variable's config struct and fill in generic fields.
5519 static struct config_generic *
5520 init_custom_variable(const char *name,
5521 const char *short_desc,
5522 const char *long_desc,
5524 enum config_type type,
5527 struct config_generic *gen;
5529 gen = (struct config_generic *) guc_malloc(ERROR, sz);
5532 gen->name = guc_strdup(ERROR, name);
5533 gen->context = context;
5534 gen->group = CUSTOM_OPTIONS;
5535 gen->short_desc = short_desc;
5536 gen->long_desc = long_desc;
5537 gen->vartype = type;
5543 * Common code for DefineCustomXXXVariable subroutines: insert the new
5544 * variable into the GUC variable array, replacing any placeholder.
5547 define_custom_variable(struct config_generic * variable)
5549 const char *name = variable->name;
5550 const char **nameAddr = &name;
5552 struct config_string *pHolder;
5553 struct config_generic **res;
5555 res = (struct config_generic **) bsearch((void *) &nameAddr,
5556 (void *) guc_variables,
5558 sizeof(struct config_generic *),
5562 /* No placeholder to replace, so just add it */
5563 add_guc_variable(variable, ERROR);
5568 * This better be a placeholder
5570 if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
5572 (errcode(ERRCODE_INTERNAL_ERROR),
5573 errmsg("attempt to redefine parameter \"%s\"", name)));
5575 Assert((*res)->vartype == PGC_STRING);
5576 pHolder = (struct config_string *) (*res);
5579 * Replace the placeholder. We aren't changing the name, so no re-sorting
5585 * Assign the string value stored in the placeholder to the real variable.
5587 * XXX this is not really good enough --- it should be a nontransactional
5588 * assignment, since we don't want it to roll back if the current xact
5591 value = *pHolder->variable;
5594 set_config_option(name, value,
5595 pHolder->gen.context, pHolder->gen.source,
5596 GUC_ACTION_SET, true);
5599 * Free up as much as we conveniently can of the placeholder structure
5600 * (this neglects any stack items...)
5602 set_string_field(pHolder, pHolder->variable, NULL);
5603 set_string_field(pHolder, &pHolder->reset_val, NULL);
5609 DefineCustomBoolVariable(const char *name,
5610 const char *short_desc,
5611 const char *long_desc,
5614 GucBoolAssignHook assign_hook,
5615 GucShowHook show_hook)
5617 struct config_bool *var;
5619 var = (struct config_bool *)
5620 init_custom_variable(name, short_desc, long_desc, context,
5621 PGC_BOOL, sizeof(struct config_bool));
5622 var->variable = valueAddr;
5623 var->boot_val = *valueAddr;
5624 var->reset_val = *valueAddr;
5625 var->assign_hook = assign_hook;
5626 var->show_hook = show_hook;
5627 define_custom_variable(&var->gen);
5631 DefineCustomIntVariable(const char *name,
5632 const char *short_desc,
5633 const char *long_desc,
5638 GucIntAssignHook assign_hook,
5639 GucShowHook show_hook)
5641 struct config_int *var;
5643 var = (struct config_int *)
5644 init_custom_variable(name, short_desc, long_desc, context,
5645 PGC_INT, sizeof(struct config_int));
5646 var->variable = valueAddr;
5647 var->boot_val = *valueAddr;
5648 var->reset_val = *valueAddr;
5649 var->min = minValue;
5650 var->max = maxValue;
5651 var->assign_hook = assign_hook;
5652 var->show_hook = show_hook;
5653 define_custom_variable(&var->gen);
5657 DefineCustomRealVariable(const char *name,
5658 const char *short_desc,
5659 const char *long_desc,
5664 GucRealAssignHook assign_hook,
5665 GucShowHook show_hook)
5667 struct config_real *var;
5669 var = (struct config_real *)
5670 init_custom_variable(name, short_desc, long_desc, context,
5671 PGC_REAL, sizeof(struct config_real));
5672 var->variable = valueAddr;
5673 var->boot_val = *valueAddr;
5674 var->reset_val = *valueAddr;
5675 var->min = minValue;
5676 var->max = maxValue;
5677 var->assign_hook = assign_hook;
5678 var->show_hook = show_hook;
5679 define_custom_variable(&var->gen);
5683 DefineCustomStringVariable(const char *name,
5684 const char *short_desc,
5685 const char *long_desc,
5688 GucStringAssignHook assign_hook,
5689 GucShowHook show_hook)
5691 struct config_string *var;
5693 var = (struct config_string *)
5694 init_custom_variable(name, short_desc, long_desc, context,
5695 PGC_STRING, sizeof(struct config_string));
5696 var->variable = valueAddr;
5697 var->boot_val = *valueAddr;
5698 /* we could probably do without strdup, but keep it like normal case */
5700 var->reset_val = guc_strdup(ERROR, var->boot_val);
5701 var->assign_hook = assign_hook;
5702 var->show_hook = show_hook;
5703 define_custom_variable(&var->gen);
5707 DefineCustomEnumVariable(const char *name,
5708 const char *short_desc,
5709 const char *long_desc,
5711 const struct config_enum_entry *options,
5713 GucEnumAssignHook assign_hook,
5714 GucShowHook show_hook)
5716 struct config_enum *var;
5718 var = (struct config_enum *)
5719 init_custom_variable(name, short_desc, long_desc, context,
5720 PGC_ENUM, sizeof(struct config_enum));
5721 var->variable = valueAddr;
5722 var->boot_val = *valueAddr;
5723 var->reset_val = *valueAddr;
5724 var->options = options;
5725 var->assign_hook = assign_hook;
5726 var->show_hook = show_hook;
5727 define_custom_variable(&var->gen);
5731 EmitWarningsOnPlaceholders(const char *className)
5733 struct config_generic **vars = guc_variables;
5734 struct config_generic **last = vars + num_guc_variables;
5736 int nameLen = strlen(className);
5740 struct config_generic *var = *vars++;
5742 if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
5743 strncmp(className, var->name, nameLen) == 0 &&
5744 var->name[nameLen] == GUC_QUALIFIER_SEPARATOR)
5747 (errcode(ERRCODE_UNDEFINED_OBJECT),
5748 errmsg("unrecognized configuration parameter \"%s\"", var->name)));
5758 GetPGVariable(const char *name, DestReceiver *dest)
5760 if (guc_name_compare(name, "all") == 0)
5761 ShowAllGUCConfig(dest);
5763 ShowGUCConfigOption(name, dest);
5767 GetPGVariableResultDesc(const char *name)
5771 if (guc_name_compare(name, "all") == 0)
5773 /* need a tuple descriptor representing three TEXT columns */
5774 tupdesc = CreateTemplateTupleDesc(3, false);
5775 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
5777 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
5779 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
5785 const char *varname;
5787 /* Get the canonical spelling of name */
5788 (void) GetConfigOptionByName(name, &varname);
5790 /* need a tuple descriptor representing a single TEXT column */
5791 tupdesc = CreateTemplateTupleDesc(1, false);
5792 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
5803 ShowGUCConfigOption(const char *name, DestReceiver *dest)
5805 TupOutputState *tstate;
5807 const char *varname;
5810 /* Get the value and canonical spelling of name */
5811 value = GetConfigOptionByName(name, &varname);
5813 /* need a tuple descriptor representing a single TEXT column */
5814 tupdesc = CreateTemplateTupleDesc(1, false);
5815 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
5818 /* prepare for projection of tuples */
5819 tstate = begin_tup_output_tupdesc(dest, tupdesc);
5822 do_text_output_oneline(tstate, value);
5824 end_tup_output(tstate);
5831 ShowAllGUCConfig(DestReceiver *dest)
5833 bool am_superuser = superuser();
5835 TupOutputState *tstate;
5839 /* need a tuple descriptor representing three TEXT columns */
5840 tupdesc = CreateTemplateTupleDesc(3, false);
5841 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
5843 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
5845 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
5849 /* prepare for projection of tuples */
5850 tstate = begin_tup_output_tupdesc(dest, tupdesc);
5852 for (i = 0; i < num_guc_variables; i++)
5854 struct config_generic *conf = guc_variables[i];
5856 if ((conf->flags & GUC_NO_SHOW_ALL) ||
5857 ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
5860 /* assign to the values array */
5861 values[0] = (char *) conf->name;
5862 values[1] = _ShowOption(conf, true);
5863 values[2] = (char *) conf->short_desc;
5865 /* send it to dest */
5866 do_tup_output(tstate, values);
5869 if (values[1] != NULL)
5873 end_tup_output(tstate);
5877 * Return GUC variable value by name; optionally return canonical
5878 * form of name. Return value is palloc'd.
5881 GetConfigOptionByName(const char *name, const char **varname)
5883 struct config_generic *record;
5885 record = find_option(name, false, ERROR);
5888 (errcode(ERRCODE_UNDEFINED_OBJECT),
5889 errmsg("unrecognized configuration parameter \"%s\"", name)));
5890 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
5892 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5893 errmsg("must be superuser to examine \"%s\"", name)));
5896 *varname = record->name;
5898 return _ShowOption(record, true);
5902 * Return GUC variable value by variable number; optionally return canonical
5903 * form of name. Return value is palloc'd.
5906 GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
5909 struct config_generic *conf;
5911 /* check requested variable number valid */
5912 Assert((varnum >= 0) && (varnum < num_guc_variables));
5914 conf = guc_variables[varnum];
5918 if ((conf->flags & GUC_NO_SHOW_ALL) ||
5919 ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
5925 /* first get the generic attributes */
5928 values[0] = conf->name;
5930 /* setting : use _ShowOption in order to avoid duplicating the logic */
5931 values[1] = _ShowOption(conf, false);
5934 if (conf->vartype == PGC_INT)
5938 switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
5943 case GUC_UNIT_BLOCKS:
5944 snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
5947 case GUC_UNIT_XBLOCKS:
5948 snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
5969 values[3] = config_group_names[conf->group];
5972 values[4] = conf->short_desc;
5975 values[5] = conf->long_desc;
5978 values[6] = GucContext_Names[conf->context];
5981 values[7] = config_type_names[conf->vartype];
5984 values[8] = GucSource_Names[conf->source];
5986 /* now get the type specifc attributes */
5987 switch (conf->vartype)
6004 struct config_int *lconf = (struct config_int *) conf;
6007 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
6008 values[9] = pstrdup(buffer);
6011 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
6012 values[10] = pstrdup(buffer);
6021 struct config_real *lconf = (struct config_real *) conf;
6024 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
6025 values[9] = pstrdup(buffer);
6028 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
6029 values[10] = pstrdup(buffer);
6058 values[11] = config_enum_get_options((struct config_enum *) conf, "", "");
6065 * should never get here, but in case we do, set 'em to NULL
6082 * Return the total number of GUC variables
6085 GetNumConfigOptions(void)
6087 return num_guc_variables;
6091 * show_config_by_name - equiv to SHOW X command but implemented as
6095 show_config_by_name(PG_FUNCTION_ARGS)
6100 /* Get the GUC variable name */
6101 varname = TextDatumGetCString(PG_GETARG_DATUM(0));
6104 varval = GetConfigOptionByName(varname, NULL);
6106 /* Convert to text */
6107 PG_RETURN_TEXT_P(cstring_to_text(varval));
6111 * show_all_settings - equiv to SHOW ALL command but implemented as
6114 #define NUM_PG_SETTINGS_ATTS 12
6117 show_all_settings(PG_FUNCTION_ARGS)
6119 FuncCallContext *funcctx;
6123 AttInMetadata *attinmeta;
6124 MemoryContext oldcontext;
6126 /* stuff done only on the first call of the function */
6127 if (SRF_IS_FIRSTCALL())
6129 /* create a function context for cross-call persistence */
6130 funcctx = SRF_FIRSTCALL_INIT();
6133 * switch to memory context appropriate for multiple function calls
6135 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
6138 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
6139 * of the appropriate types
6141 tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
6142 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
6144 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
6146 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "unit",
6148 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "category",
6150 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "short_desc",
6152 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "extra_desc",
6154 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "context",
6156 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "vartype",
6158 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "source",
6160 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "min_val",
6162 TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val",
6164 TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
6168 * Generate attribute metadata needed later to produce tuples from raw
6171 attinmeta = TupleDescGetAttInMetadata(tupdesc);
6172 funcctx->attinmeta = attinmeta;
6174 /* total number of tuples to be returned */
6175 funcctx->max_calls = GetNumConfigOptions();
6177 MemoryContextSwitchTo(oldcontext);
6180 /* stuff done on every call of the function */
6181 funcctx = SRF_PERCALL_SETUP();
6183 call_cntr = funcctx->call_cntr;
6184 max_calls = funcctx->max_calls;
6185 attinmeta = funcctx->attinmeta;
6187 if (call_cntr < max_calls) /* do when there is more left to send */
6189 char *values[NUM_PG_SETTINGS_ATTS];
6195 * Get the next visible GUC variable name and value
6199 GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
6202 /* bump the counter and get the next config setting */
6203 call_cntr = ++funcctx->call_cntr;
6205 /* make sure we haven't gone too far now */
6206 if (call_cntr >= max_calls)
6207 SRF_RETURN_DONE(funcctx);
6212 tuple = BuildTupleFromCStrings(attinmeta, values);
6214 /* make the tuple into a datum */
6215 result = HeapTupleGetDatum(tuple);
6217 SRF_RETURN_NEXT(funcctx, result);
6221 /* do when there is no more left */
6222 SRF_RETURN_DONE(funcctx);
6227 _ShowOption(struct config_generic * record, bool use_units)
6232 switch (record->vartype)
6236 struct config_bool *conf = (struct config_bool *) record;
6238 if (conf->show_hook)
6239 val = (*conf->show_hook) ();
6241 val = *conf->variable ? "on" : "off";
6247 struct config_int *conf = (struct config_int *) record;
6249 if (conf->show_hook)
6250 val = (*conf->show_hook) ();
6254 int result = *conf->variable;
6256 if (use_units && result > 0 && (record->flags & GUC_UNIT_MEMORY))
6258 switch (record->flags & GUC_UNIT_MEMORY)
6260 case GUC_UNIT_BLOCKS:
6261 result *= BLCKSZ / 1024;
6263 case GUC_UNIT_XBLOCKS:
6264 result *= XLOG_BLCKSZ / 1024;
6268 if (result % KB_PER_GB == 0)
6270 result /= KB_PER_GB;
6273 else if (result % KB_PER_MB == 0)
6275 result /= KB_PER_MB;
6283 else if (use_units && result > 0 && (record->flags & GUC_UNIT_TIME))
6285 switch (record->flags & GUC_UNIT_TIME)
6291 result *= MS_PER_MIN;
6295 if (result % MS_PER_D == 0)
6300 else if (result % MS_PER_H == 0)
6305 else if (result % MS_PER_MIN == 0)
6307 result /= MS_PER_MIN;
6308 strcpy(unit, "min");
6310 else if (result % MS_PER_S == 0)
6323 snprintf(buffer, sizeof(buffer), "%d%s",
6324 (int) result, unit);
6332 struct config_real *conf = (struct config_real *) record;
6334 if (conf->show_hook)
6335 val = (*conf->show_hook) ();
6338 snprintf(buffer, sizeof(buffer), "%g",
6347 struct config_string *conf = (struct config_string *) record;
6349 if (conf->show_hook)
6350 val = (*conf->show_hook) ();
6351 else if (*conf->variable && **conf->variable)
6352 val = *conf->variable;
6360 struct config_enum *conf = (struct config_enum *) record;
6363 val = (*conf->show_hook) ();
6365 val = config_enum_lookup_by_value(conf, *conf->variable);
6370 /* just to keep compiler quiet */
6375 return pstrdup(val);
6380 * Attempt (badly) to detect if a proposed new GUC setting is the same
6381 * as the current value.
6383 * XXX this does not really work because it doesn't account for the
6384 * effects of canonicalization of string values by assign_hooks.
6387 is_newvalue_equal(struct config_generic * record, const char *newvalue)
6389 /* newvalue == NULL isn't supported */
6390 Assert(newvalue != NULL);
6392 switch (record->vartype)
6396 struct config_bool *conf = (struct config_bool *) record;
6399 return parse_bool(newvalue, &newval)
6400 && *conf->variable == newval;
6404 struct config_int *conf = (struct config_int *) record;
6407 return parse_int(newvalue, &newval, record->flags, NULL)
6408 && *conf->variable == newval;
6412 struct config_real *conf = (struct config_real *) record;
6415 return parse_real(newvalue, &newval)
6416 && *conf->variable == newval;
6420 struct config_string *conf = (struct config_string *) record;
6422 return *conf->variable != NULL &&
6423 strcmp(*conf->variable, newvalue) == 0;
6428 struct config_enum *conf = (struct config_enum *) record;
6431 return config_enum_lookup_by_name(conf, newvalue, &newval)
6432 && *conf->variable == newval;
6443 * This routine dumps out all non-default GUC options into a binary
6444 * file that is read by all exec'ed backends. The format is:
6446 * variable name, string, null terminated
6447 * variable value, string, null terminated
6448 * variable source, integer
6451 write_nondefault_variables(GucContext context)
6457 Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
6459 elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
6464 fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
6468 (errcode_for_file_access(),
6469 errmsg("could not write to file \"%s\": %m",
6470 CONFIG_EXEC_PARAMS_NEW)));
6474 for (i = 0; i < num_guc_variables; i++)
6476 struct config_generic *gconf = guc_variables[i];
6478 if (gconf->source != PGC_S_DEFAULT)
6480 fprintf(fp, "%s", gconf->name);
6483 switch (gconf->vartype)
6487 struct config_bool *conf = (struct config_bool *) gconf;
6489 if (*conf->variable == 0)
6490 fprintf(fp, "false");
6492 fprintf(fp, "true");
6498 struct config_int *conf = (struct config_int *) gconf;
6500 fprintf(fp, "%d", *conf->variable);
6506 struct config_real *conf = (struct config_real *) gconf;
6508 /* Could lose precision here? */
6509 fprintf(fp, "%f", *conf->variable);
6515 struct config_string *conf = (struct config_string *) gconf;
6517 fprintf(fp, "%s", *conf->variable);
6523 struct config_enum *conf = (struct config_enum *) gconf;
6525 fprintf(fp, "%s", config_enum_lookup_by_value(conf, *conf->variable));
6532 fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
6539 (errcode_for_file_access(),
6540 errmsg("could not write to file \"%s\": %m",
6541 CONFIG_EXEC_PARAMS_NEW)));
6546 * Put new file in place. This could delay on Win32, but we don't hold
6547 * any exclusive locks.
6549 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
6554 * Read string, including null byte from file
6556 * Return NULL on EOF and nothing read
6559 read_string_with_null(FILE *fp)
6568 if ((ch = fgetc(fp)) == EOF)
6573 elog(FATAL, "invalid format of exec config params file");
6576 str = guc_malloc(FATAL, maxlen);
6577 else if (i == maxlen)
6578 str = guc_realloc(FATAL, str, maxlen *= 2);
6587 * This routine loads a previous postmaster dump of its non-default
6591 read_nondefault_variables(void)
6601 fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
6604 /* File not found is fine */
6605 if (errno != ENOENT)
6607 (errcode_for_file_access(),
6608 errmsg("could not read from file \"%s\": %m",
6609 CONFIG_EXEC_PARAMS)));
6615 struct config_generic *record;
6617 if ((varname = read_string_with_null(fp)) == NULL)
6620 if ((record = find_option(varname, true, FATAL)) == NULL)
6621 elog(FATAL, "failed to locate variable %s in exec config params file", varname);
6622 if ((varvalue = read_string_with_null(fp)) == NULL)
6623 elog(FATAL, "invalid format of exec config params file");
6624 if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
6625 elog(FATAL, "invalid format of exec config params file");
6627 (void) set_config_option(varname, varvalue, record->context,
6628 varsource, GUC_ACTION_SET, true);
6635 #endif /* EXEC_BACKEND */
6639 * A little "long argument" simulation, although not quite GNU
6640 * compliant. Takes a string of the form "some-option=some value" and
6641 * returns name = "some_option" and value = "some value" in malloc'ed
6642 * storage. Note that '-' is converted to '_' in the option name. If
6643 * there is no '=' in the input string then value will be NULL.
6646 ParseLongOption(const char *string, char **name, char **value)
6655 equal_pos = strcspn(string, "=");
6657 if (string[equal_pos] == '=')
6659 *name = guc_malloc(FATAL, equal_pos + 1);
6660 strlcpy(*name, string, equal_pos + 1);
6662 *value = guc_strdup(FATAL, &string[equal_pos + 1]);
6666 /* no equal sign in string */
6667 *name = guc_strdup(FATAL, string);
6671 for (cp = *name; *cp; cp++)
6678 * Handle options fetched from pg_database.datconfig, pg_authid.rolconfig,
6679 * pg_proc.proconfig, etc. Caller must specify proper context/source/action.
6681 * The array parameter must be an array of TEXT (it must not be NULL).
6684 ProcessGUCArray(ArrayType *array,
6685 GucContext context, GucSource source, GucAction action)
6689 Assert(array != NULL);
6690 Assert(ARR_ELEMTYPE(array) == TEXTOID);
6691 Assert(ARR_NDIM(array) == 1);
6692 Assert(ARR_LBOUND(array)[0] == 1);
6694 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6702 d = array_ref(array, 1, &i,
6703 -1 /* varlenarray */ ,
6704 -1 /* TEXT's typlen */ ,
6705 false /* TEXT's typbyval */ ,
6706 'i' /* TEXT's typalign */ ,
6712 s = TextDatumGetCString(d);
6714 ParseLongOption(s, &name, &value);
6718 (errcode(ERRCODE_SYNTAX_ERROR),
6719 errmsg("could not parse setting for parameter \"%s\"",
6725 (void) set_config_option(name, value, context, source, action, true);
6735 * Add an entry to an option array. The array parameter may be NULL
6736 * to indicate the current table entry is NULL.
6739 GUCArrayAdd(ArrayType *array, const char *name, const char *value)
6741 const char *varname;
6749 /* test if the option is valid */
6750 set_config_option(name, value,
6751 superuser() ? PGC_SUSET : PGC_USERSET,
6752 PGC_S_TEST, GUC_ACTION_SET, false);
6754 /* convert name to canonical spelling, so we can use plain strcmp */
6755 (void) GetConfigOptionByName(name, &varname);
6758 newval = palloc(strlen(name) + 1 + strlen(value) + 1);
6759 sprintf(newval, "%s=%s", name, value);
6760 datum = CStringGetTextDatum(newval);
6768 Assert(ARR_ELEMTYPE(array) == TEXTOID);
6769 Assert(ARR_NDIM(array) == 1);
6770 Assert(ARR_LBOUND(array)[0] == 1);
6772 index = ARR_DIMS(array)[0] + 1; /* add after end */
6774 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6779 d = array_ref(array, 1, &i,
6780 -1 /* varlenarray */ ,
6781 -1 /* TEXT's typlen */ ,
6782 false /* TEXT's typbyval */ ,
6783 'i' /* TEXT's typalign */ ,
6787 current = TextDatumGetCString(d);
6788 if (strncmp(current, newval, strlen(name) + 1) == 0)
6795 a = array_set(array, 1, &index,
6798 -1 /* varlena array */ ,
6799 -1 /* TEXT's typlen */ ,
6800 false /* TEXT's typbyval */ ,
6801 'i' /* TEXT's typalign */ );
6804 a = construct_array(&datum, 1,
6813 * Delete an entry from an option array. The array parameter may be NULL
6814 * to indicate the current table entry is NULL. Also, if the return value
6815 * is NULL then a null should be stored.
6818 GUCArrayDelete(ArrayType *array, const char *name)
6820 const char *varname;
6821 ArrayType *newarray;
6827 /* test if the option is valid */
6828 set_config_option(name, NULL,
6829 superuser() ? PGC_SUSET : PGC_USERSET,
6830 PGC_S_TEST, GUC_ACTION_SET, false);
6832 /* convert name to canonical spelling, so we can use plain strcmp */
6833 (void) GetConfigOptionByName(name, &varname);
6836 /* if array is currently null, then surely nothing to delete */
6843 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
6849 d = array_ref(array, 1, &i,
6850 -1 /* varlenarray */ ,
6851 -1 /* TEXT's typlen */ ,
6852 false /* TEXT's typbyval */ ,
6853 'i' /* TEXT's typalign */ ,
6857 val = TextDatumGetCString(d);
6859 /* ignore entry if it's what we want to delete */
6860 if (strncmp(val, name, strlen(name)) == 0
6861 && val[strlen(name)] == '=')
6864 /* else add it to the output array */
6867 newarray = array_set(newarray, 1, &index,
6870 -1 /* varlenarray */ ,
6871 -1 /* TEXT's typlen */ ,
6872 false /* TEXT's typbyval */ ,
6873 'i' /* TEXT's typalign */ );
6876 newarray = construct_array(&d, 1,
6888 * assign_hook and show_hook subroutines
6892 assign_log_destination(const char *value, bool doit, GucSource source)
6899 /* Need a modifiable copy of string */
6900 rawstring = pstrdup(value);
6902 /* Parse string into list of identifiers */
6903 if (!SplitIdentifierString(rawstring, ',', &elemlist))
6905 /* syntax error in list */
6907 list_free(elemlist);
6908 ereport(GUC_complaint_elevel(source),
6909 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6910 errmsg("invalid list syntax for parameter \"log_destination\"")));
6914 foreach(l, elemlist)
6916 char *tok = (char *) lfirst(l);
6918 if (pg_strcasecmp(tok, "stderr") == 0)
6919 newlogdest |= LOG_DESTINATION_STDERR;
6920 else if (pg_strcasecmp(tok, "csvlog") == 0)
6921 newlogdest |= LOG_DESTINATION_CSVLOG;
6923 else if (pg_strcasecmp(tok, "syslog") == 0)
6924 newlogdest |= LOG_DESTINATION_SYSLOG;
6927 else if (pg_strcasecmp(tok, "eventlog") == 0)
6928 newlogdest |= LOG_DESTINATION_EVENTLOG;
6932 ereport(GUC_complaint_elevel(source),
6933 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6934 errmsg("unrecognized \"log_destination\" key word: \"%s\"",
6937 list_free(elemlist);
6943 Log_destination = newlogdest;
6946 list_free(elemlist);
6954 assign_syslog_facility(int newval, bool doit, GucSource source)
6957 set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
6964 assign_syslog_ident(const char *ident, bool doit, GucSource source)
6967 set_syslog_parameters(ident, syslog_facility);
6971 #endif /* HAVE_SYSLOG */
6975 assign_session_replication_role(int newval, bool doit, GucSource source)
6978 * Must flush the plan cache when changing replication role; but don't
6979 * flush unnecessarily.
6981 if (doit && SessionReplicationRole != newval)
6990 show_num_temp_buffers(void)
6993 * We show the GUC var until local buffers have been initialized, and
6994 * NLocBuffer afterwards.
6996 static char nbuf[32];
6998 sprintf(nbuf, "%d", NLocBuffer ? NLocBuffer : num_temp_buffers);
7003 assign_phony_autocommit(bool newval, bool doit, GucSource source)
7007 ereport(GUC_complaint_elevel(source),
7008 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7009 errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
7016 assign_custom_variable_classes(const char *newval, bool doit, GucSource source)
7019 * Check syntax. newval must be a comma separated list of identifiers.
7020 * Whitespace is allowed but removed from the result.
7022 bool hasSpaceAfterToken = false;
7023 const char *cp = newval;
7028 initStringInfo(&buf);
7029 while ((c = *cp++) != '\0')
7031 if (isspace((unsigned char) c))
7034 hasSpaceAfterToken = true;
7040 if (symLen > 0) /* terminate identifier */
7042 appendStringInfoChar(&buf, ',');
7045 hasSpaceAfterToken = false;
7049 if (hasSpaceAfterToken || !isalnum((unsigned char) c))
7052 * Syntax error due to token following space after token or non
7053 * alpha numeric character
7058 appendStringInfoChar(&buf, c);
7062 /* Remove stray ',' at end */
7063 if (symLen == 0 && buf.len > 0)
7064 buf.data[--buf.len] = '\0';
7066 /* GUC wants the result malloc'd */
7067 newval = guc_strdup(LOG, buf.data);
7074 assign_debug_assertions(bool newval, bool doit, GucSource source)
7076 #ifndef USE_ASSERT_CHECKING
7079 ereport(GUC_complaint_elevel(source),
7080 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7081 errmsg("assertion checking is not supported by this build")));
7089 assign_ssl(bool newval, bool doit, GucSource source)
7094 ereport(GUC_complaint_elevel(source),
7095 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7096 errmsg("SSL is not supported by this build")));
7104 assign_stage_log_stats(bool newval, bool doit, GucSource source)
7106 if (newval && log_statement_stats)
7108 ereport(GUC_complaint_elevel(source),
7109 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7110 errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
7111 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
7112 if (source != PGC_S_OVERRIDE)
7119 assign_log_stats(bool newval, bool doit, GucSource source)
7122 (log_parser_stats || log_planner_stats || log_executor_stats))
7124 ereport(GUC_complaint_elevel(source),
7125 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7126 errmsg("cannot enable \"log_statement_stats\" when "
7127 "\"log_parser_stats\", \"log_planner_stats\", "
7128 "or \"log_executor_stats\" is true")));
7129 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
7130 if (source != PGC_S_OVERRIDE)
7137 assign_transaction_read_only(bool newval, bool doit, GucSource source)
7139 /* Can't go to r/w mode inside a r/o transaction */
7140 if (newval == false && XactReadOnly && IsSubTransaction())
7142 ereport(GUC_complaint_elevel(source),
7143 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7144 errmsg("cannot set transaction read-write mode inside a read-only transaction")));
7145 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
7146 if (source != PGC_S_OVERRIDE)
7153 assign_canonical_path(const char *newval, bool doit, GucSource source)
7157 char *canon_val = guc_strdup(ERROR, newval);
7159 canonicalize_path(canon_val);
7167 assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
7170 * The powerup value shown above for timezone_abbreviations is "UNKNOWN".
7171 * When we see this we just do nothing. If this value isn't overridden
7172 * from the config file then pg_timezone_abbrev_initialize() will
7173 * eventually replace it with "Default". This hack has two purposes: to
7174 * avoid wasting cycles loading values that might soon be overridden from
7175 * the config file, and to avoid trying to read the timezone abbrev files
7176 * during InitializeGUCOptions(). The latter doesn't work in an
7177 * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
7178 * we can't locate PGSHAREDIR. (Essentially the same hack is used to
7179 * delay initializing TimeZone ... if we have any more, we should try to
7180 * clean up and centralize this mechanism ...)
7182 if (strcmp(newval, "UNKNOWN") == 0)
7187 /* Loading abbrev file is expensive, so only do it when value changes */
7188 if (timezone_abbreviations_string == NULL ||
7189 strcmp(timezone_abbreviations_string, newval) != 0)
7194 * If reading config file, only the postmaster should bleat loudly
7195 * about problems. Otherwise, it's just this one process doing it,
7196 * and we use WARNING message level.
7198 if (source == PGC_S_FILE)
7199 elevel = IsUnderPostmaster ? DEBUG3 : LOG;
7202 if (!load_tzoffsets(newval, doit, elevel))
7209 * pg_timezone_abbrev_initialize --- set default value if not done already
7211 * This is called after initial loading of postgresql.conf. If no
7212 * timezone_abbreviations setting was found therein, select default.
7215 pg_timezone_abbrev_initialize(void)
7217 if (strcmp(timezone_abbreviations_string, "UNKNOWN") == 0)
7219 SetConfigOption("timezone_abbreviations", "Default",
7220 PGC_POSTMASTER, PGC_S_ARGV);
7225 show_archive_command(void)
7227 if (XLogArchiveMode)
7228 return XLogArchiveCommand;
7230 return "(disabled)";
7234 assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
7237 return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
7243 show_tcp_keepalives_idle(void)
7245 static char nbuf[16];
7247 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
7252 assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
7255 return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
7261 show_tcp_keepalives_interval(void)
7263 static char nbuf[16];
7265 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
7270 assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
7273 return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
7279 show_tcp_keepalives_count(void)
7281 static char nbuf[16];
7283 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
7288 assign_maxconnections(int newval, bool doit, GucSource source)
7290 if (newval + autovacuum_max_workers > INT_MAX / 4)
7294 MaxBackends = newval + autovacuum_max_workers;
7300 assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
7302 if (newval + MaxConnections > INT_MAX / 4)
7306 MaxBackends = newval + MaxConnections;
7311 #include "guc-file.c"