1 /*--------------------------------------------------------------------
4 * Support for grand unified configuration scheme, including SET
5 * command, configuration file, and command line options.
6 * See src/backend/utils/misc/README for more information.
9 * Copyright (c) 2000-2006, PostgreSQL Global Development Group
10 * Written by Peter Eisentraut <peter_e@gmx.net>.
13 * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.323 2006/06/27 19:07:50 momjian Exp $
15 *--------------------------------------------------------------------
28 #include "utils/guc.h"
29 #include "utils/guc_tables.h"
31 #include "access/twophase.h"
32 #include "catalog/namespace.h"
33 #include "catalog/pg_type.h"
34 #include "commands/async.h"
35 #include "commands/variable.h"
36 #include "commands/vacuum.h"
37 #include "executor/executor.h"
40 #include "libpq/auth.h"
41 #include "libpq/pqcomm.h"
42 #include "libpq/pqformat.h"
43 #include "mb/pg_wchar.h"
44 #include "miscadmin.h"
45 #include "optimizer/cost.h"
46 #include "optimizer/geqo.h"
47 #include "optimizer/paths.h"
48 #include "optimizer/planmain.h"
49 #include "parser/gramparse.h"
50 #include "parser/parse_expr.h"
51 #include "parser/parse_relation.h"
52 #include "parser/scansup.h"
53 #include "postmaster/autovacuum.h"
54 #include "postmaster/bgwriter.h"
55 #include "postmaster/syslogger.h"
56 #include "postmaster/postmaster.h"
57 #include "storage/bufmgr.h"
58 #include "storage/fd.h"
59 #include "storage/freespace.h"
60 #include "storage/lock.h"
61 #include "storage/proc.h"
62 #include "tcop/tcopprot.h"
63 #include "utils/array.h"
64 #include "utils/builtins.h"
65 #include "utils/memutils.h"
66 #include "utils/pg_locale.h"
68 #include "access/gin.h"
71 #define PG_KRB_SRVTAB ""
74 #define PG_KRB_SRVNAM ""
77 #define CONFIG_FILENAME "postgresql.conf"
78 #define HBA_FILENAME "pg_hba.conf"
79 #define IDENT_FILENAME "pg_ident.conf"
82 #define CONFIG_EXEC_PARAMS "global/config_exec_params"
83 #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
86 /* upper limit for GUC variables measured in kilobytes of memory */
88 #define MAX_KILOBYTES INT_MAX
90 #define MAX_KILOBYTES (INT_MAX / 1024)
93 /* XXX these should appear in other modules' header files */
94 extern bool Log_disconnections;
95 extern bool check_function_bodies;
96 extern int CommitDelay;
97 extern int CommitSiblings;
98 extern char *default_tablespace;
99 extern bool fullPageWrites;
102 extern bool trace_sort;
105 static const char *assign_log_destination(const char *value,
106 bool doit, GucSource source);
109 static int syslog_facility = LOG_LOCAL0;
111 static const char *assign_syslog_facility(const char *facility,
112 bool doit, GucSource source);
113 static const char *assign_syslog_ident(const char *ident,
114 bool doit, GucSource source);
117 static const char *assign_defaultxactisolevel(const char *newval, bool doit,
119 static const char *assign_log_min_messages(const char *newval, bool doit,
121 static const char *assign_client_min_messages(const char *newval,
122 bool doit, GucSource source);
123 static const char *assign_min_error_statement(const char *newval, bool doit,
125 static const char *assign_msglvl(int *var, const char *newval, bool doit,
127 static const char *assign_log_error_verbosity(const char *newval, bool doit,
129 static const char *assign_log_statement(const char *newval, bool doit,
131 static const char *show_num_temp_buffers(void);
132 static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);
133 static const char *assign_custom_variable_classes(const char *newval, bool doit,
135 static bool assign_debug_assertions(bool newval, bool doit, GucSource source);
136 static bool assign_ssl(bool newval, bool doit, GucSource source);
137 static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
138 static bool assign_log_stats(bool newval, bool doit, GucSource source);
139 static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
140 static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
141 static const char *assign_backslash_quote(const char *newval, bool doit, GucSource source);
143 static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);
144 static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);
145 static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source);
146 static const char *show_tcp_keepalives_idle(void);
147 static const char *show_tcp_keepalives_interval(void);
148 static const char *show_tcp_keepalives_count(void);
151 * GUC option variables that are exported from this module
153 #ifdef USE_ASSERT_CHECKING
154 bool assert_enabled = true;
156 bool assert_enabled = false;
158 bool log_duration = false;
159 bool Debug_print_plan = false;
160 bool Debug_print_parse = false;
161 bool Debug_print_rewritten = false;
162 bool Debug_pretty_print = false;
163 bool Explain_pretty_print = true;
165 bool log_parser_stats = false;
166 bool log_planner_stats = false;
167 bool log_executor_stats = false;
168 bool log_statement_stats = false; /* this is sort of all three
170 bool log_btree_build_stats = false;
172 bool SQL_inheritance = true;
174 bool Australian_timezones = false;
176 bool Password_encryption = true;
178 bool default_with_oids = false;
180 int log_min_error_statement = PANIC;
181 int log_min_messages = NOTICE;
182 int client_min_messages = NOTICE;
183 int log_min_duration_statement = -1;
185 int num_temp_buffers = 1000;
187 char *ConfigFileName;
190 char *external_pid_file;
192 int tcp_keepalives_idle;
193 int tcp_keepalives_interval;
194 int tcp_keepalives_count;
197 * These variables are all dummies that don't do anything, except in some
198 * cases provide the value for SHOW to display. The real state is elsewhere
199 * and is kept in sync by assign_hooks.
201 static char *client_min_messages_str;
202 static char *log_min_messages_str;
203 static char *log_error_verbosity_str;
204 static char *log_statement_str;
205 static char *log_min_error_statement_str;
206 static char *log_destination_string;
208 static char *syslog_facility_str;
209 static char *syslog_ident_str;
211 static bool phony_autocommit;
212 static bool session_auth_is_superuser;
213 static double phony_random_seed;
214 static char *backslash_quote_string;
215 static char *client_encoding_string;
216 static char *datestyle_string;
217 static char *default_iso_level_string;
218 static char *locale_collate;
219 static char *locale_ctype;
220 static char *regex_flavor_string;
221 static char *server_encoding_string;
222 static char *server_version_string;
223 static char *timezone_string;
224 static char *XactIsoLevel_string;
225 static char *data_directory;
226 static char *custom_variable_classes;
227 static int max_function_args;
228 static int max_index_keys;
229 static int max_identifier_length;
230 static int block_size;
231 static bool integer_datetimes;
233 /* should be static, but commands/variable.c needs to get at these */
235 char *session_authorization_string;
239 * Displayable names for context types (enum GucContext)
241 * Note: these strings are deliberately not localized.
243 const char *const GucContext_Names[] =
245 /* PGC_INTERNAL */ "internal",
246 /* PGC_POSTMASTER */ "postmaster",
247 /* PGC_SIGHUP */ "sighup",
248 /* PGC_BACKEND */ "backend",
249 /* PGC_SUSET */ "superuser",
250 /* PGC_USERSET */ "user"
254 * Displayable names for source types (enum GucSource)
256 * Note: these strings are deliberately not localized.
258 const char *const GucSource_Names[] =
260 /* PGC_S_DEFAULT */ "default",
261 /* PGC_S_ENV_VAR */ "environment variable",
262 /* PGC_S_FILE */ "configuration file",
263 /* PGC_S_ARGV */ "command line",
264 /* PGC_S_DATABASE */ "database",
265 /* PGC_S_USER */ "user",
266 /* PGC_S_CLIENT */ "client",
267 /* PGC_S_OVERRIDE */ "override",
268 /* PGC_S_INTERACTIVE */ "interactive",
269 /* PGC_S_TEST */ "test",
270 /* PGC_S_SESSION */ "session"
274 * Displayable names for the groupings defined in enum config_group
276 const char *const config_group_names[] =
279 gettext_noop("Ungrouped"),
281 gettext_noop("File Locations"),
283 gettext_noop("Connections and Authentication"),
284 /* CONN_AUTH_SETTINGS */
285 gettext_noop("Connections and Authentication / Connection Settings"),
286 /* CONN_AUTH_SECURITY */
287 gettext_noop("Connections and Authentication / Security and Authentication"),
289 gettext_noop("Resource Usage"),
291 gettext_noop("Resource Usage / Memory"),
293 gettext_noop("Resource Usage / Free Space Map"),
294 /* RESOURCES_KERNEL */
295 gettext_noop("Resource Usage / Kernel Resources"),
297 gettext_noop("Write-Ahead Log"),
299 gettext_noop("Write-Ahead Log / Settings"),
300 /* WAL_CHECKPOINTS */
301 gettext_noop("Write-Ahead Log / Checkpoints"),
303 gettext_noop("Query Tuning"),
304 /* QUERY_TUNING_METHOD */
305 gettext_noop("Query Tuning / Planner Method Configuration"),
306 /* QUERY_TUNING_COST */
307 gettext_noop("Query Tuning / Planner Cost Constants"),
308 /* QUERY_TUNING_GEQO */
309 gettext_noop("Query Tuning / Genetic Query Optimizer"),
310 /* QUERY_TUNING_OTHER */
311 gettext_noop("Query Tuning / Other Planner Options"),
313 gettext_noop("Reporting and Logging"),
315 gettext_noop("Reporting and Logging / Where to Log"),
317 gettext_noop("Reporting and Logging / When to Log"),
319 gettext_noop("Reporting and Logging / What to Log"),
321 gettext_noop("Statistics"),
322 /* STATS_MONITORING */
323 gettext_noop("Statistics / Monitoring"),
324 /* STATS_COLLECTOR */
325 gettext_noop("Statistics / Query and Index Statistics Collector"),
327 gettext_noop("Autovacuum"),
329 gettext_noop("Client Connection Defaults"),
330 /* CLIENT_CONN_STATEMENT */
331 gettext_noop("Client Connection Defaults / Statement Behavior"),
332 /* CLIENT_CONN_LOCALE */
333 gettext_noop("Client Connection Defaults / Locale and Formatting"),
334 /* CLIENT_CONN_OTHER */
335 gettext_noop("Client Connection Defaults / Other Defaults"),
336 /* LOCK_MANAGEMENT */
337 gettext_noop("Lock Management"),
339 gettext_noop("Version and Platform Compatibility"),
340 /* COMPAT_OPTIONS_PREVIOUS */
341 gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
342 /* COMPAT_OPTIONS_CLIENT */
343 gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
345 gettext_noop("Preset Options"),
347 gettext_noop("Customized Options"),
348 /* DEVELOPER_OPTIONS */
349 gettext_noop("Developer Options"),
350 /* help_config wants this array to be null-terminated */
355 * Displayable names for GUC variable types (enum config_type)
357 * Note: these strings are deliberately not localized.
359 const char *const config_type_names[] =
361 /* PGC_BOOL */ "bool",
362 /* PGC_INT */ "integer",
363 /* PGC_REAL */ "real",
364 /* PGC_STRING */ "string"
369 * Contents of GUC tables
371 * See src/backend/utils/misc/README for design notes.
375 * 1. Declare a global variable of type bool, int, double, or char*
376 * and make use of it.
378 * 2. Decide at what times it's safe to set the option. See guc.h for
381 * 3. Decide on a name, a default value, upper and lower bounds (if
384 * 4. Add a record below.
386 * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
389 * 6. Add it to src/bin/psql/tab-complete.c, if it's a USERSET option.
391 * 7. Don't forget to document the option.
393 * 8. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
394 * it is not single quoted at dump time.
398 /******** option records follow ********/
400 static struct config_bool ConfigureNamesBool[] =
403 {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
404 gettext_noop("Enables the planner's use of sequential-scan plans."),
411 {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
412 gettext_noop("Enables the planner's use of index-scan plans."),
419 {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
420 gettext_noop("Enables the planner's use of bitmap-scan plans."),
427 {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
428 gettext_noop("Enables the planner's use of TID scan plans."),
435 {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
436 gettext_noop("Enables the planner's use of explicit sort steps."),
443 {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
444 gettext_noop("Enables the planner's use of hashed aggregation plans."),
451 {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
452 gettext_noop("Enables the planner's use of nested-loop join plans."),
459 {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
460 gettext_noop("Enables the planner's use of merge join plans."),
467 {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
468 gettext_noop("Enables the planner's use of hash join plans."),
475 {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
476 gettext_noop("Enables the planner to use constraints to optimize queries."),
477 gettext_noop("Child table scans will be skipped if their "
478 "constraints guarantee that no rows match the query.")
480 &constraint_exclusion,
484 {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
485 gettext_noop("Enables genetic query optimization."),
486 gettext_noop("This algorithm attempts to do planning without "
487 "exhaustive searching.")
493 /* Not for general use --- used by SET SESSION AUTHORIZATION */
494 {"is_superuser", PGC_INTERNAL, UNGROUPED,
495 gettext_noop("Shows whether the current user is a superuser."),
497 GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
499 &session_auth_is_superuser,
503 {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY,
504 gettext_noop("Enables SSL connections."),
508 false, assign_ssl, NULL
511 {"fsync", PGC_SIGHUP, WAL_SETTINGS,
512 gettext_noop("Forces synchronization of updates to disk."),
513 gettext_noop("The server will use the fsync() system call in several places to make "
514 "sure that updates are physically written to disk. This insures "
515 "that a database cluster will recover to a consistent state after "
516 "an operating system or hardware crash.")
522 {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
523 gettext_noop("Continues processing past damaged page headers."),
524 gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
525 "report an error, aborting the current transaction. Setting "
526 "zero_damaged_pages to true causes the system to instead report a "
527 "warning, zero out the damaged page, and continue processing. This "
528 "behavior will destroy data, namely all the rows on the damaged page."),
535 {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
536 gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
537 gettext_noop("A page write in process during an operating system crash might be "
538 "only partially written to disk. During recovery, the row changes "
539 "stored in WAL are not enough to recover. This option writes "
540 "pages when first modified after a checkpoint to WAL so full recovery "
547 {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN,
548 gettext_noop("Runs the server silently."),
549 gettext_noop("If this parameter is set, the server will automatically run in the "
550 "background and any controlling terminals are dissociated.")
556 {"log_connections", PGC_BACKEND, LOGGING_WHAT,
557 gettext_noop("Logs each successful connection."),
564 {"log_disconnections", PGC_BACKEND, LOGGING_WHAT,
565 gettext_noop("Logs end of a session, including duration."),
572 {"debug_assertions", PGC_USERSET, DEVELOPER_OPTIONS,
573 gettext_noop("Turns on various assertion checks."),
574 gettext_noop("This is a debugging aid."),
578 #ifdef USE_ASSERT_CHECKING
583 assign_debug_assertions, NULL
586 /* currently undocumented, so don't show in SHOW ALL */
587 {"exit_on_error", PGC_USERSET, UNGROUPED,
588 gettext_noop("no description available"),
590 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
596 {"log_duration", PGC_SUSET, LOGGING_WHAT,
597 gettext_noop("Logs the duration of each completed SQL statement."),
604 {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
605 gettext_noop("Prints the parse tree to the server log."),
612 {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
613 gettext_noop("Prints the parse tree after rewriting to server log."),
616 &Debug_print_rewritten,
620 {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
621 gettext_noop("Prints the execution plan to server log."),
628 {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
629 gettext_noop("Indents parse and plan tree displays."),
636 {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
637 gettext_noop("Writes parser performance statistics to the server log."),
641 false, assign_stage_log_stats, NULL
644 {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
645 gettext_noop("Writes planner performance statistics to the server log."),
649 false, assign_stage_log_stats, NULL
652 {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
653 gettext_noop("Writes executor performance statistics to the server log."),
657 false, assign_stage_log_stats, NULL
660 {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
661 gettext_noop("Writes cumulative performance statistics to the server log."),
664 &log_statement_stats,
665 false, assign_log_stats, NULL
667 #ifdef BTREE_BUILD_STATS
669 {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
670 gettext_noop("no description available"),
674 &log_btree_build_stats,
680 {"explain_pretty_print", PGC_USERSET, CLIENT_CONN_OTHER,
681 gettext_noop("Uses the indented output format for EXPLAIN VERBOSE."),
684 &Explain_pretty_print,
688 {"stats_start_collector", PGC_POSTMASTER, STATS_COLLECTOR,
689 gettext_noop("Starts the server statistics-collection subprocess."),
692 &pgstat_collect_startcollector,
696 {"stats_reset_on_server_start", PGC_POSTMASTER, STATS_COLLECTOR,
697 gettext_noop("Zeroes collected statistics on server restart."),
700 &pgstat_collect_resetonpmstart,
704 {"stats_row_level", PGC_SUSET, STATS_COLLECTOR,
705 gettext_noop("Collects row-level statistics on database activity."),
708 &pgstat_collect_tuplelevel,
712 {"stats_block_level", PGC_SUSET, STATS_COLLECTOR,
713 gettext_noop("Collects block-level statistics on database activity."),
716 &pgstat_collect_blocklevel,
721 {"stats_command_string", PGC_SUSET, STATS_COLLECTOR,
722 gettext_noop("Collects information about executing commands."),
723 gettext_noop("Enables the collection of information on the currently "
724 "executing command of each session, along with the time "
725 "at which that command began execution.")
727 &pgstat_collect_querystring,
732 {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
733 gettext_noop("Starts the autovacuum subprocess."),
736 &autovacuum_start_daemon,
741 {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
742 gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
752 {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
753 gettext_noop("no description available"),
761 {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
762 gettext_noop("no description available"),
770 {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
771 gettext_noop("no description available"),
779 {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
780 gettext_noop("no description available"),
790 {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
791 gettext_noop("Logs the host name in the connection logs."),
792 gettext_noop("By default, connection logs only show the IP address "
793 "of the connecting host. If you want them to show the host name you "
794 "can turn this on, but depending on your host name resolution "
795 "setup it might impose a non-negligible performance penalty.")
801 {"sql_inheritance", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
802 gettext_noop("Causes subtables to be included by default in various commands."),
809 {"australian_timezones", PGC_USERSET, CLIENT_CONN_LOCALE,
810 gettext_noop("Interprets ACST, CST, EST, and SAT as Australian time zones."),
811 gettext_noop("Otherwise they are interpreted as North/South American "
812 "time zones and Saturday.")
814 &Australian_timezones,
815 false, ClearDateCache, NULL
818 {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
819 gettext_noop("Encrypt passwords."),
820 gettext_noop("When a password is specified in CREATE USER or "
821 "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
822 "this parameter determines whether the password is to be encrypted.")
824 &Password_encryption,
828 {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
829 gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
830 gettext_noop("When turned on, expressions of the form expr = NULL "
831 "(or NULL = expr) are treated as expr IS NULL, that is, they "
832 "return true if expr evaluates to the null value, and false "
833 "otherwise. The correct behavior of expr = NULL is to always "
834 "return null (unknown).")
836 &Transform_null_equals,
840 {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
841 gettext_noop("Enables per-database user names."),
848 /* only here for backwards compatibility */
849 {"autocommit", PGC_USERSET, CLIENT_CONN_STATEMENT,
850 gettext_noop("This parameter doesn't do anything."),
851 gettext_noop("It's just here so that we won't choke on SET AUTOCOMMIT TO ON from 7.3-vintage clients."),
852 GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
855 true, assign_phony_autocommit, NULL
858 {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
859 gettext_noop("Sets the default read-only status of new transactions."),
862 &DefaultXactReadOnly,
866 {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
867 gettext_noop("Sets the current transaction's read-only status."),
869 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
872 false, assign_transaction_read_only, NULL
875 {"add_missing_from", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
876 gettext_noop("Automatically adds missing table references to FROM clauses."),
883 {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
884 gettext_noop("Check function bodies during CREATE FUNCTION."),
887 &check_function_bodies,
891 {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
892 gettext_noop("Enable input of NULL elements in arrays."),
893 gettext_noop("When turned on, unquoted NULL in an array input "
894 "value means a NULL value; "
895 "otherwise it is taken literally.")
901 {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
902 gettext_noop("Create new tables with OIDs by default."),
909 {"redirect_stderr", PGC_POSTMASTER, LOGGING_WHERE,
910 gettext_noop("Start a subprocess to capture stderr output into log files."),
917 {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
918 gettext_noop("Truncate existing log files of same name during log rotation."),
921 &Log_truncate_on_rotation,
927 {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
928 gettext_noop("Emit information about resource usage in sorting."),
939 {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
940 gettext_noop("Emit WAL-related debugging output."),
950 {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
951 gettext_noop("Datetimes are integer based."),
953 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
956 #ifdef HAVE_INT64_TIMESTAMP
964 {"krb_caseins_users", PGC_POSTMASTER, CONN_AUTH_SECURITY,
965 gettext_noop("Sets whether Kerberos user names should be treated as case-insensitive."),
968 &pg_krb_caseins_users,
973 {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
974 gettext_noop("Warn about backslash escapes in ordinary string literals."),
977 &escape_string_warning,
982 {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
983 gettext_noop("'...' strings treat backslashes literally."),
987 &standard_conforming_strings,
992 {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
993 gettext_noop("Allows modifications of the structure of system tables."),
997 &allowSystemTableMods,
1002 {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
1003 gettext_noop("Disabled reading from system indexes."),
1004 gettext_noop("It does not prevent updating the indexes, so it is safe "
1005 "to use. The worst consequence is slowness."),
1008 &IgnoreSystemIndexes,
1012 /* End-of-list marker */
1014 {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
1019 static struct config_int ConfigureNamesInt[] =
1022 {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1023 gettext_noop("Waits N seconds on connection startup after authentication."),
1024 gettext_noop("This allows attaching a debugger to the process."),
1028 0, 0, INT_MAX, NULL, NULL
1031 {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1032 gettext_noop("Sets the default statistics target."),
1033 gettext_noop("This applies to table columns that have not had a "
1034 "column-specific target set via ALTER TABLE SET STATISTICS.")
1036 &default_statistics_target,
1037 10, 1, 1000, NULL, NULL
1040 {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1041 gettext_noop("Sets the FROM-list size beyond which subqueries are not "
1043 gettext_noop("The planner will merge subqueries into upper "
1044 "queries if the resulting FROM list would have no more than "
1047 &from_collapse_limit,
1048 8, 1, INT_MAX, NULL, NULL
1051 {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1052 gettext_noop("Sets the FROM-list size beyond which JOIN constructs are not "
1054 gettext_noop("The planner will flatten explicit JOIN "
1055 "constructs into lists of FROM items whenever a list of no more "
1056 "than this many items would result.")
1058 &join_collapse_limit,
1059 8, 1, INT_MAX, NULL, NULL
1062 {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1063 gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1067 12, 2, INT_MAX, NULL, NULL
1070 {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1071 gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1075 DEFAULT_GEQO_EFFORT, MIN_GEQO_EFFORT, MAX_GEQO_EFFORT, NULL, NULL
1078 {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1079 gettext_noop("GEQO: number of individuals in the population."),
1080 gettext_noop("Zero selects a suitable default value.")
1083 0, 0, INT_MAX, NULL, NULL
1086 {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1087 gettext_noop("GEQO: number of iterations of the algorithm."),
1088 gettext_noop("Zero selects a suitable default value.")
1091 0, 0, INT_MAX, NULL, NULL
1095 {"deadlock_timeout", PGC_SIGHUP, LOCK_MANAGEMENT,
1096 gettext_noop("The time in milliseconds to wait on lock before checking for deadlock."),
1100 1000, 0, INT_MAX, NULL, NULL
1104 * Note: There is some postprocessing done in PostmasterMain() to make
1105 * sure the buffers are at least twice the number of backends, so the
1106 * constraints here are partially unused. Similarly, the superuser
1107 * reserved number is checked to ensure it is less than the max backends
1110 * MaxBackends is limited to INT_MAX/4 because some places compute
1111 * 4*MaxBackends without any overflow check. Likewise we have to limit
1112 * NBuffers to INT_MAX/2.
1115 {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1116 gettext_noop("Sets the maximum number of concurrent connections."),
1120 100, 1, INT_MAX / 4, NULL, NULL
1124 {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1125 gettext_noop("Sets the number of connection slots reserved for superusers."),
1129 2, 0, INT_MAX / 4, NULL, NULL
1133 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1134 gettext_noop("Sets the number of shared memory buffers used by the server."),
1138 1000, 16, INT_MAX / 2, NULL, NULL
1142 {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1143 gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1147 1000, 100, INT_MAX / 2, NULL, show_num_temp_buffers
1151 {"port", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1152 gettext_noop("Sets the TCP port the server listens on."),
1156 DEF_PGPORT, 1, 65535, NULL, NULL
1160 {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1161 gettext_noop("Sets the access permissions of the Unix-domain socket."),
1162 gettext_noop("Unix-domain sockets use the usual Unix file system "
1163 "permission set. The parameter value is expected to be an numeric mode "
1164 "specification in the form accepted by the chmod and umask system "
1165 "calls. (To use the customary octal format the number must start with "
1168 &Unix_socket_permissions,
1169 0777, 0000, 0777, NULL, NULL
1173 {"work_mem", PGC_USERSET, RESOURCES_MEM,
1174 gettext_noop("Sets the maximum memory to be used for query workspaces."),
1175 gettext_noop("This much memory may be used by each internal "
1176 "sort operation and hash table before switching to "
1177 "temporary disk files.")
1180 1024, 8 * BLCKSZ / 1024, MAX_KILOBYTES, NULL, NULL
1184 {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1185 gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1186 gettext_noop("This includes operations such as VACUUM and CREATE INDEX.")
1188 &maintenance_work_mem,
1189 16384, 1024, MAX_KILOBYTES, NULL, NULL
1193 {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1194 gettext_noop("Sets the maximum stack depth, in kilobytes."),
1198 2048, 100, MAX_KILOBYTES, assign_max_stack_depth, NULL
1202 {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES,
1203 gettext_noop("Vacuum cost for a page found in the buffer cache."),
1207 1, 0, 10000, NULL, NULL
1211 {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES,
1212 gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1215 &VacuumCostPageMiss,
1216 10, 0, 10000, NULL, NULL
1220 {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES,
1221 gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1224 &VacuumCostPageDirty,
1225 20, 0, 10000, NULL, NULL
1229 {"vacuum_cost_limit", PGC_USERSET, RESOURCES,
1230 gettext_noop("Vacuum cost amount available before napping."),
1234 200, 1, 10000, NULL, NULL
1238 {"vacuum_cost_delay", PGC_USERSET, RESOURCES,
1239 gettext_noop("Vacuum cost delay in milliseconds."),
1243 0, 0, 1000, NULL, NULL
1247 {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
1248 gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
1251 &autovacuum_vac_cost_delay,
1252 -1, -1, 1000, NULL, NULL
1256 {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
1257 gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
1260 &autovacuum_vac_cost_limit,
1261 -1, -1, 10000, NULL, NULL
1265 {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
1266 gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
1269 &max_files_per_process,
1270 1000, 25, INT_MAX, NULL, NULL
1274 {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
1275 gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
1278 &max_prepared_xacts,
1279 5, 0, INT_MAX, NULL, NULL
1284 {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
1285 gettext_noop("no description available"),
1290 FirstNormalObjectId, 0, INT_MAX, NULL, NULL
1293 {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
1294 gettext_noop("no description available"),
1299 0, 0, INT_MAX, NULL, NULL
1304 {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
1305 gettext_noop("Sets the maximum allowed duration (in milliseconds) of any statement."),
1306 gettext_noop("A value of 0 turns off the timeout.")
1309 0, 0, INT_MAX, NULL, NULL
1313 {"max_fsm_relations", PGC_POSTMASTER, RESOURCES_FSM,
1314 gettext_noop("Sets the maximum number of tables and indexes for which free space is tracked."),
1318 1000, 100, INT_MAX, NULL, NULL
1321 {"max_fsm_pages", PGC_POSTMASTER, RESOURCES_FSM,
1322 gettext_noop("Sets the maximum number of disk pages for which free space is tracked."),
1326 20000, 1000, INT_MAX, NULL, NULL
1330 {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
1331 gettext_noop("Sets the maximum number of locks per transaction."),
1332 gettext_noop("The shared lock table is sized on the assumption that "
1333 "at most max_locks_per_transaction * max_connections distinct "
1334 "objects will need to be locked at any one time.")
1336 &max_locks_per_xact,
1337 64, 10, INT_MAX, NULL, NULL
1341 {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
1342 gettext_noop("Sets the maximum time in seconds to complete client authentication."),
1345 &AuthenticationTimeout,
1346 60, 1, 600, NULL, NULL
1350 /* Not for general use */
1351 {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
1352 gettext_noop("no description available"),
1357 0, 0, 60, NULL, NULL
1361 {"checkpoint_segments", PGC_SIGHUP, WAL_CHECKPOINTS,
1362 gettext_noop("Sets the maximum distance in log segments between automatic WAL checkpoints."),
1365 &CheckPointSegments,
1366 3, 1, INT_MAX, NULL, NULL
1370 {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
1371 gettext_noop("Sets the maximum time in seconds between automatic WAL checkpoints."),
1375 300, 30, 3600, NULL, NULL
1379 {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
1380 gettext_noop("Logs if filling of checkpoint segments happens more "
1381 "frequently than this (in seconds)."),
1382 gettext_noop("Write a message to the server log if checkpoints "
1383 "caused by the filling of checkpoint segment files happens more "
1384 "frequently than this number of seconds. Zero turns off the warning.")
1387 30, 0, INT_MAX, NULL, NULL
1391 {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
1392 gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
1396 8, 4, INT_MAX, NULL, NULL
1400 {"commit_delay", PGC_USERSET, WAL_CHECKPOINTS,
1401 gettext_noop("Sets the delay in microseconds between transaction commit and "
1402 "flushing WAL to disk."),
1406 0, 0, 100000, NULL, NULL
1410 {"commit_siblings", PGC_USERSET, WAL_CHECKPOINTS,
1411 gettext_noop("Sets the minimum concurrent open transactions before performing "
1416 5, 1, 1000, NULL, NULL
1420 {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
1421 gettext_noop("Sets the number of digits displayed for floating-point values."),
1422 gettext_noop("This affects real, double precision, and geometric data types. "
1423 "The parameter value is added to the standard number of digits "
1424 "(FLT_DIG or DBL_DIG as appropriate).")
1426 &extra_float_digits,
1427 0, -15, 2, NULL, NULL
1431 {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
1432 gettext_noop("Sets the minimum execution time in milliseconds above which statements will "
1434 gettext_noop("Zero prints all queries. The default is -1 (turning this feature off).")
1436 &log_min_duration_statement,
1437 -1, -1, INT_MAX / 1000, NULL, NULL
1441 {"bgwriter_delay", PGC_SIGHUP, RESOURCES,
1442 gettext_noop("Background writer sleep time between rounds in milliseconds"),
1446 200, 10, 10000, NULL, NULL
1450 {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES,
1451 gettext_noop("Background writer maximum number of LRU pages to flush per round"),
1454 &bgwriter_lru_maxpages,
1455 5, 0, 1000, NULL, NULL
1459 {"bgwriter_all_maxpages", PGC_SIGHUP, RESOURCES,
1460 gettext_noop("Background writer maximum number of all pages to flush per round"),
1463 &bgwriter_all_maxpages,
1464 5, 0, 1000, NULL, NULL
1468 {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
1469 gettext_noop("Automatic log file rotation will occur after N minutes"),
1473 HOURS_PER_DAY * MINS_PER_HOUR, 0, INT_MAX / MINS_PER_HOUR, NULL, NULL
1477 {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
1478 gettext_noop("Automatic log file rotation will occur after N kilobytes"),
1482 10 * 1024, 0, INT_MAX / 1024, NULL, NULL
1486 {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
1487 gettext_noop("Shows the maximum number of function arguments."),
1489 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1492 FUNC_MAX_ARGS, FUNC_MAX_ARGS, FUNC_MAX_ARGS, NULL, NULL
1496 {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
1497 gettext_noop("Shows the maximum number of index keys."),
1499 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1502 INDEX_MAX_KEYS, INDEX_MAX_KEYS, INDEX_MAX_KEYS, NULL, NULL
1506 {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
1507 gettext_noop("Shows the maximum identifier length"),
1509 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1511 &max_identifier_length,
1512 NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1, NULL, NULL
1516 {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
1517 gettext_noop("Shows size of a disk block"),
1519 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1522 BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
1526 {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
1527 gettext_noop("Time to sleep between autovacuum runs, in seconds."),
1530 &autovacuum_naptime,
1531 60, 1, INT_MAX, NULL, NULL
1534 {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
1535 gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
1538 &autovacuum_vac_thresh,
1539 1000, 0, INT_MAX, NULL, NULL
1542 {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
1543 gettext_noop("Minimum number of tuple inserts, updates or deletes prior to analyze."),
1546 &autovacuum_anl_thresh,
1547 500, 0, INT_MAX, NULL, NULL
1551 {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
1552 gettext_noop("Seconds between issuing TCP keepalives."),
1553 gettext_noop("A value of 0 uses the system default."),
1555 &tcp_keepalives_idle,
1556 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle
1560 {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
1561 gettext_noop("Seconds between TCP keepalive retransmits."),
1562 gettext_noop("A value of 0 uses the system default."),
1564 &tcp_keepalives_interval,
1565 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
1569 {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
1570 gettext_noop("Maximum number of TCP keepalive retransmits."),
1571 gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
1572 "lost before a connection is considered dead. A value of 0 uses the "
1575 &tcp_keepalives_count,
1576 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count
1580 {"gin_fuzzy_search_limit", PGC_USERSET, UNGROUPED,
1581 gettext_noop("Sets the maximum allowed result for exact search by gin."),
1585 &GinFuzzySearchLimit,
1586 0, 0, INT_MAX, NULL, NULL
1589 /* End-of-list marker */
1591 {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
1596 static struct config_real ConfigureNamesReal[] =
1599 {"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1600 gettext_noop("Sets the planner's estimate of the cost of a "
1601 "sequentially fetched disk page."),
1605 DEFAULT_SEQ_PAGE_COST, 0, DBL_MAX, NULL, NULL
1608 {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
1609 gettext_noop("Sets the planner's estimate of the cost of a "
1610 "nonsequentially fetched disk page."),
1614 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
1617 {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1618 gettext_noop("Sets the planner's estimate of the cost of "
1619 "processing each tuple (row)."),
1623 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1626 {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
1627 gettext_noop("Sets the planner's estimate of the cost of "
1628 "processing each index entry during an index scan."),
1631 &cpu_index_tuple_cost,
1632 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
1635 {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
1636 gettext_noop("Sets the planner's estimate of the cost of "
1637 "processing each operator or function call."),
1641 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
1645 {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
1646 gettext_noop("Sets the planner's assumption about size of the disk cache."),
1647 gettext_noop("That is, the portion of the kernel's disk cache that "
1648 "will be used for PostgreSQL data files. This is measured in disk "
1649 "pages, which are normally 8 kB each.")
1651 &effective_cache_size,
1652 DEFAULT_EFFECTIVE_CACHE_SIZE, 1, DBL_MAX, NULL, NULL
1656 {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
1657 gettext_noop("GEQO: selective pressure within the population."),
1660 &Geqo_selection_bias,
1661 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
1662 MAX_GEQO_SELECTION_BIAS, NULL, NULL
1666 {"bgwriter_lru_percent", PGC_SIGHUP, RESOURCES,
1667 gettext_noop("Background writer percentage of LRU buffers to flush per round"),
1670 &bgwriter_lru_percent,
1671 1.0, 0.0, 100.0, NULL, NULL
1675 {"bgwriter_all_percent", PGC_SIGHUP, RESOURCES,
1676 gettext_noop("Background writer percentage of all buffers to flush per round"),
1679 &bgwriter_all_percent,
1680 0.333, 0.0, 100.0, NULL, NULL
1684 {"seed", PGC_USERSET, UNGROUPED,
1685 gettext_noop("Sets the seed for random-number generation."),
1687 GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1690 0.5, 0.0, 1.0, assign_random_seed, show_random_seed
1694 {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1695 gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
1698 &autovacuum_vac_scale,
1699 0.4, 0.0, 100.0, NULL, NULL
1702 {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
1703 gettext_noop("Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples."),
1706 &autovacuum_anl_scale,
1707 0.2, 0.0, 100.0, NULL, NULL
1710 /* End-of-list marker */
1712 {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL
1717 static struct config_string ConfigureNamesString[] =
1720 {"archive_command", PGC_SIGHUP, WAL_SETTINGS,
1721 gettext_noop("WAL archiving command."),
1722 gettext_noop("The shell command that will be called to archive a WAL file.")
1724 &XLogArchiveCommand,
1729 {"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1730 gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
1731 gettext_noop("Valid values are ON, OFF, and SAFE_ENCODING.")
1733 &backslash_quote_string,
1734 "safe_encoding", assign_backslash_quote, NULL
1738 {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
1739 gettext_noop("Sets the client's character set encoding."),
1741 GUC_IS_NAME | GUC_REPORT
1743 &client_encoding_string,
1744 "SQL_ASCII", assign_client_encoding, NULL
1748 {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
1749 gettext_noop("Sets the message levels that are sent to the client."),
1750 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, "
1751 "DEBUG1, LOG, NOTICE, WARNING, and ERROR. Each level includes all the "
1752 "levels that follow it. The later the level, the fewer messages are "
1755 &client_min_messages_str,
1756 "notice", assign_client_min_messages, NULL
1760 {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
1761 gettext_noop("Sets the message levels that are logged."),
1762 gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, "
1763 "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level "
1764 "includes all the levels that follow it.")
1766 &log_min_messages_str,
1767 "notice", assign_log_min_messages, NULL
1771 {"log_error_verbosity", PGC_SUSET, LOGGING_WHEN,
1772 gettext_noop("Sets the verbosity of logged messages."),
1773 gettext_noop("Valid values are \"terse\", \"default\", and \"verbose\".")
1775 &log_error_verbosity_str,
1776 "default", assign_log_error_verbosity, NULL
1779 {"log_statement", PGC_SUSET, LOGGING_WHAT,
1780 gettext_noop("Sets the type of statements logged."),
1781 gettext_noop("Valid values are \"none\", \"ddl\", \"mod\", and \"all\".")
1784 "none", assign_log_statement, NULL
1788 {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
1789 gettext_noop("Causes all statements generating error at or above this level to be logged."),
1790 gettext_noop("All SQL statements that cause an error of the "
1791 "specified level or a higher level are logged.")
1793 &log_min_error_statement_str,
1794 "panic", assign_min_error_statement, NULL
1798 {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
1799 gettext_noop("Controls information prefixed to each log line"),
1800 gettext_noop("if blank no prefix is used")
1808 {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
1809 gettext_noop("Sets the display format for date and time values."),
1810 gettext_noop("Also controls interpretation of ambiguous "
1812 GUC_LIST_INPUT | GUC_REPORT
1815 "ISO, MDY", assign_datestyle, NULL
1819 {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
1820 gettext_noop("Sets the default tablespace to create tables and indexes in."),
1821 gettext_noop("An empty string selects the database's default tablespace."),
1824 &default_tablespace,
1825 "", assign_default_tablespace, NULL
1829 {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
1830 gettext_noop("Sets the transaction isolation level of each new transaction."),
1831 gettext_noop("Each SQL transaction has an isolation level, which "
1832 "can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
1834 &default_iso_level_string,
1835 "read committed", assign_defaultxactisolevel, NULL
1839 {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
1840 gettext_noop("Sets the path for dynamically loadable modules."),
1841 gettext_noop("If a dynamically loadable module needs to be opened and "
1842 "the specified name does not have a directory component (i.e., the "
1843 "name does not contain a slash), the system will search this path for "
1844 "the specified file."),
1847 &Dynamic_library_path,
1848 "$libdir", NULL, NULL
1852 {"krb_server_keyfile", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1853 gettext_noop("Sets the location of the Kerberos server key file."),
1857 &pg_krb_server_keyfile,
1858 PG_KRB_SRVTAB, NULL, NULL
1862 {"krb_srvname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1863 gettext_noop("Sets the name of the Kerberos service."),
1867 PG_KRB_SRVNAM, NULL, NULL
1871 {"krb_server_hostname", PGC_POSTMASTER, CONN_AUTH_SECURITY,
1872 gettext_noop("Sets the hostname of the Kerberos server."),
1875 &pg_krb_server_hostname,
1880 {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1881 gettext_noop("Sets the Bonjour broadcast service name."),
1888 /* See main.c about why defaults for LC_foo are not all alike */
1891 {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1892 gettext_noop("Shows the collation order locale."),
1894 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1901 {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1902 gettext_noop("Shows the character classification and case conversion locale."),
1904 GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1911 {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
1912 gettext_noop("Sets the language in which messages are displayed."),
1916 "", locale_messages_assign, NULL
1920 {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
1921 gettext_noop("Sets the locale for formatting monetary amounts."),
1925 "C", locale_monetary_assign, NULL
1929 {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
1930 gettext_noop("Sets the locale for formatting numbers."),
1934 "C", locale_numeric_assign, NULL
1938 {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
1939 gettext_noop("Sets the locale for formatting date and time values."),
1943 "C", locale_time_assign, NULL
1947 {"preload_libraries", PGC_POSTMASTER, RESOURCES_KERNEL,
1948 gettext_noop("Lists shared libraries to preload into server."),
1950 GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
1952 &preload_libraries_string,
1957 {"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1958 gettext_noop("Sets the regular expression \"flavor\"."),
1959 gettext_noop("This can be set to advanced, extended, or basic.")
1961 ®ex_flavor_string,
1962 "advanced", assign_regex_flavor, NULL
1966 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
1967 gettext_noop("Sets the schema search order for names that are not schema-qualified."),
1969 GUC_LIST_INPUT | GUC_LIST_QUOTE
1971 &namespace_search_path,
1972 "\"$user\",public", assign_search_path, NULL
1976 /* Can't be set in postgresql.conf */
1977 {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
1978 gettext_noop("Sets the server (database) character set encoding."),
1980 GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1982 &server_encoding_string,
1983 "SQL_ASCII", NULL, NULL
1987 /* Can't be set in postgresql.conf */
1988 {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
1989 gettext_noop("Shows the server version."),
1991 GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1993 &server_version_string,
1994 PG_VERSION, NULL, NULL
1998 /* Not for general use --- used by SET ROLE */
1999 {"role", PGC_USERSET, UNGROUPED,
2000 gettext_noop("Sets the current role."),
2002 GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2005 "none", assign_role, show_role
2009 /* Not for general use --- used by SET SESSION AUTHORIZATION */
2010 {"session_authorization", PGC_USERSET, UNGROUPED,
2011 gettext_noop("Sets the session user name."),
2013 GUC_IS_NAME | GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2015 &session_authorization_string,
2016 NULL, assign_session_authorization, show_session_authorization
2020 {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
2021 gettext_noop("Sets the destination for server log output."),
2022 gettext_noop("Valid values are combinations of \"stderr\", \"syslog\", "
2023 "and \"eventlog\", depending on the platform."),
2026 &log_destination_string,
2027 "stderr", assign_log_destination, NULL
2030 {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
2031 gettext_noop("Sets the destination directory for log files."),
2032 gettext_noop("May be specified as relative to the data directory "
2033 "or as absolute path."),
2037 "pg_log", assign_canonical_path, NULL
2040 {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
2041 gettext_noop("Sets the file name pattern for log files."),
2046 "postgresql-%Y-%m-%d_%H%M%S.log", NULL, NULL
2051 {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2052 gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2053 gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2054 "LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2056 &syslog_facility_str,
2057 "LOCAL0", assign_syslog_facility, NULL
2060 {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
2061 gettext_noop("Sets the program name used to identify PostgreSQL "
2062 "messages in syslog."),
2066 "postgres", assign_syslog_ident, NULL
2071 {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
2072 gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
2077 "UNKNOWN", assign_timezone, show_timezone
2081 {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
2082 gettext_noop("Sets the current transaction's isolation level."),
2084 GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
2086 &XactIsoLevel_string,
2087 NULL, assign_XactIsoLevel, show_XactIsoLevel
2091 {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2092 gettext_noop("Sets the owning group of the Unix-domain socket."),
2093 gettext_noop("(The owning user of the socket is always the user "
2094 "that starts the server.)")
2101 {"unix_socket_directory", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2102 gettext_noop("Sets the directory where the Unix-domain socket will be created."),
2107 "", assign_canonical_path, NULL
2111 {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
2112 gettext_noop("Sets the host name or IP address(es) to listen to."),
2117 "localhost", NULL, NULL
2121 {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
2122 gettext_noop("Selects the method used for forcing WAL updates out to disk."),
2126 XLOG_sync_method_default, assign_xlog_sync_method, NULL
2130 {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
2131 gettext_noop("Sets the list of known custom variable classes."),
2133 GUC_LIST_INPUT | GUC_LIST_QUOTE
2135 &custom_variable_classes,
2136 NULL, assign_custom_variable_classes, NULL
2140 {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
2141 gettext_noop("Sets the server's data directory."),
2150 {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
2151 gettext_noop("Sets the server's main configuration file."),
2153 GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY
2160 {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
2161 gettext_noop("Sets the server's \"hba\" configuration file"),
2170 {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
2171 gettext_noop("Sets the server's \"ident\" configuration file"),
2180 {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
2181 gettext_noop("Writes the postmaster PID to the specified file."),
2186 NULL, assign_canonical_path, NULL
2189 /* End-of-list marker */
2191 {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
2196 /******** end of options list ********/
2200 * To allow continued support of obsolete names for GUC variables, we apply
2201 * the following mappings to any unrecognized name. Note that an old name
2202 * should be mapped to a new one only if the new variable has very similar
2203 * semantics to the old.
2205 static const char *const map_old_guc_names[] = {
2206 "sort_mem", "work_mem",
2207 "vacuum_mem", "maintenance_work_mem",
2213 * Actual lookup of variables is done through this single, sorted array.
2215 static struct config_generic **guc_variables;
2217 /* Current number of variables contained in the vector */
2218 static int num_guc_variables;
2220 /* Vector capacity */
2221 static int size_guc_variables;
2224 static bool guc_dirty; /* TRUE if need to do commit/abort work */
2226 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
2229 static int guc_var_compare(const void *a, const void *b);
2230 static int guc_name_compare(const char *namea, const char *nameb);
2231 static void push_old_value(struct config_generic * gconf);
2232 static void ReportGUCOption(struct config_generic * record);
2233 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
2234 static void ShowAllGUCConfig(DestReceiver *dest);
2235 static char *_ShowOption(struct config_generic * record);
2236 static bool is_newvalue_equal(struct config_generic *record, const char *newvalue);
2240 * Some infrastructure for checking malloc/strdup/realloc calls
2243 guc_malloc(int elevel, size_t size)
2247 data = malloc(size);
2250 (errcode(ERRCODE_OUT_OF_MEMORY),
2251 errmsg("out of memory")));
2256 guc_realloc(int elevel, void *old, size_t size)
2260 data = realloc(old, size);
2263 (errcode(ERRCODE_OUT_OF_MEMORY),
2264 errmsg("out of memory")));
2269 guc_strdup(int elevel, const char *src)
2276 (errcode(ERRCODE_OUT_OF_MEMORY),
2277 errmsg("out of memory")));
2283 * Support for assigning to a field of a string GUC item. Free the prior
2284 * value if it's not referenced anywhere else in the item (including stacked
2288 set_string_field(struct config_string * conf, char **field, char *newval)
2290 char *oldval = *field;
2293 /* Do the assignment */
2296 /* Exit if any duplicate references, or if old value was NULL anyway */
2297 if (oldval == NULL ||
2298 oldval == *(conf->variable) ||
2299 oldval == conf->reset_val ||
2300 oldval == conf->tentative_val)
2302 for (stack = conf->gen.stack; stack; stack = stack->prev)
2304 if (oldval == stack->tentative_val.stringval ||
2305 oldval == stack->value.stringval)
2309 /* Not used anymore, so free it */
2314 * Detect whether strval is referenced anywhere in a GUC string item
2317 string_field_used(struct config_string * conf, char *strval)
2321 if (strval == *(conf->variable) ||
2322 strval == conf->reset_val ||
2323 strval == conf->tentative_val)
2325 for (stack = conf->gen.stack; stack; stack = stack->prev)
2327 if (strval == stack->tentative_val.stringval ||
2328 strval == stack->value.stringval)
2335 struct config_generic **
2336 get_guc_variables(void)
2338 return guc_variables;
2343 * Build the sorted array. This is split out so that it could be
2344 * re-executed after startup (eg, we could allow loadable modules to
2345 * add vars, and then we'd need to re-sort).
2348 build_guc_variables(void)
2352 struct config_generic **guc_vars;
2355 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2357 struct config_bool *conf = &ConfigureNamesBool[i];
2359 /* Rather than requiring vartype to be filled in by hand, do this: */
2360 conf->gen.vartype = PGC_BOOL;
2364 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2366 struct config_int *conf = &ConfigureNamesInt[i];
2368 conf->gen.vartype = PGC_INT;
2372 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2374 struct config_real *conf = &ConfigureNamesReal[i];
2376 conf->gen.vartype = PGC_REAL;
2380 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2382 struct config_string *conf = &ConfigureNamesString[i];
2384 conf->gen.vartype = PGC_STRING;
2389 * Create table with 20% slack
2391 size_vars = num_vars + num_vars / 4;
2393 guc_vars = (struct config_generic **)
2394 guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
2398 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
2399 guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
2401 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
2402 guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
2404 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
2405 guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
2407 for (i = 0; ConfigureNamesString[i].gen.name; i++)
2408 guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
2411 free(guc_variables);
2412 guc_variables = guc_vars;
2413 num_guc_variables = num_vars;
2414 size_guc_variables = size_vars;
2415 qsort((void *) guc_variables, num_guc_variables,
2416 sizeof(struct config_generic *), guc_var_compare);
2420 is_custom_class(const char *name, int dotPos)
2423 * assign_custom_variable_classes() has made sure no empty identifiers or
2424 * whitespace exists in the variable
2426 bool result = false;
2427 const char *ccs = GetConfigOption("custom_variable_classes");
2431 const char *start = ccs;
2437 if (c == 0 || c == ',')
2439 if (dotPos == ccs - start && strncmp(start, name, dotPos) == 0)
2454 * Add a new GUC variable to the list of known variables. The
2455 * list is expanded if needed.
2458 add_guc_variable(struct config_generic * var, int elevel)
2460 if (num_guc_variables + 1 >= size_guc_variables)
2463 * Increase the vector by 25%
2465 int size_vars = size_guc_variables + size_guc_variables / 4;
2466 struct config_generic **guc_vars;
2471 guc_vars = (struct config_generic **)
2472 guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
2476 guc_vars = (struct config_generic **)
2477 guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
2480 if (guc_vars == NULL)
2481 return false; /* out of memory */
2483 guc_variables = guc_vars;
2484 size_guc_variables = size_vars;
2486 guc_variables[num_guc_variables++] = var;
2487 qsort((void *) guc_variables, num_guc_variables,
2488 sizeof(struct config_generic *), guc_var_compare);
2493 * Create and add a placeholder variable. It's presumed to belong
2494 * to a valid custom variable class at this point.
2496 static struct config_string *
2497 add_placeholder_variable(const char *name, int elevel)
2499 size_t sz = sizeof(struct config_string) + sizeof(char *);
2500 struct config_string *var;
2501 struct config_generic *gen;
2503 var = (struct config_string *) guc_malloc(elevel, sz);
2510 gen->name = guc_strdup(elevel, name);
2511 if (gen->name == NULL)
2517 gen->context = PGC_USERSET;
2518 gen->group = CUSTOM_OPTIONS;
2519 gen->short_desc = "GUC placeholder variable";
2520 gen->flags = GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_CUSTOM_PLACEHOLDER;
2521 gen->vartype = PGC_STRING;
2524 * The char* is allocated at the end of the struct since we have no
2525 * 'static' place to point to.
2527 var->variable = (char **) (var + 1);
2529 if (!add_guc_variable((struct config_generic *) var, elevel))
2531 free((void *) gen->name);
2540 * Look up option NAME. If it exists, return a pointer to its record,
2543 static struct config_generic *
2544 find_option(const char *name, int elevel)
2547 const char **key = &name;
2548 struct config_generic **res;
2554 * By equating const char ** with struct config_generic *, we are assuming
2555 * the name field is first in config_generic.
2557 res = (struct config_generic **) bsearch((void *) &key,
2558 (void *) guc_variables,
2560 sizeof(struct config_generic *),
2566 * See if the name is an obsolete name for a variable. We assume that the
2567 * set of supported old names is short enough that a brute-force search is
2570 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
2572 if (guc_name_compare(name, map_old_guc_names[i]) == 0)
2573 return find_option(map_old_guc_names[i + 1], elevel);
2577 * Check if the name is qualified, and if so, check if the qualifier maps
2578 * to a custom variable class.
2580 dot = strchr(name, GUC_QUALIFIER_SEPARATOR);
2581 if (dot != NULL && is_custom_class(name, dot - name))
2582 /* Add a placeholder variable for this name */
2583 return (struct config_generic *) add_placeholder_variable(name, elevel);
2591 * comparator for qsorting and bsearching guc_variables array
2594 guc_var_compare(const void *a, const void *b)
2596 struct config_generic *confa = *(struct config_generic **) a;
2597 struct config_generic *confb = *(struct config_generic **) b;
2599 return guc_name_compare(confa->name, confb->name);
2604 guc_name_compare(const char *namea, const char *nameb)
2607 * The temptation to use strcasecmp() here must be resisted, because the
2608 * array ordering has to remain stable across setlocale() calls. So, build
2609 * our own with a simple ASCII-only downcasing.
2611 while (*namea && *nameb)
2613 char cha = *namea++;
2614 char chb = *nameb++;
2616 if (cha >= 'A' && cha <= 'Z')
2618 if (chb >= 'A' && chb <= 'Z')
2624 return 1; /* a is longer */
2626 return -1; /* b is longer */
2632 * Initialize GUC options during program startup.
2634 * Note that we cannot read the config file yet, since we have not yet
2635 * processed command-line switches.
2638 InitializeGUCOptions(void)
2644 * Build sorted array of all GUC variables.
2646 build_guc_variables();
2649 * Load all variables with their compiled-in defaults, and initialize
2650 * status fields as needed.
2652 for (i = 0; i < num_guc_variables; i++)
2654 struct config_generic *gconf = guc_variables[i];
2657 gconf->reset_source = PGC_S_DEFAULT;
2658 gconf->tentative_source = PGC_S_DEFAULT;
2659 gconf->source = PGC_S_DEFAULT;
2660 gconf->stack = NULL;
2662 switch (gconf->vartype)
2666 struct config_bool *conf = (struct config_bool *) gconf;
2668 if (conf->assign_hook)
2669 if (!(*conf->assign_hook) (conf->reset_val, true,
2671 elog(FATAL, "failed to initialize %s to %d",
2672 conf->gen.name, (int) conf->reset_val);
2673 *conf->variable = conf->reset_val;
2678 struct config_int *conf = (struct config_int *) gconf;
2680 Assert(conf->reset_val >= conf->min);
2681 Assert(conf->reset_val <= conf->max);
2682 if (conf->assign_hook)
2683 if (!(*conf->assign_hook) (conf->reset_val, true,
2685 elog(FATAL, "failed to initialize %s to %d",
2686 conf->gen.name, conf->reset_val);
2687 *conf->variable = conf->reset_val;
2692 struct config_real *conf = (struct config_real *) gconf;
2694 Assert(conf->reset_val >= conf->min);
2695 Assert(conf->reset_val <= conf->max);
2696 if (conf->assign_hook)
2697 if (!(*conf->assign_hook) (conf->reset_val, true,
2699 elog(FATAL, "failed to initialize %s to %g",
2700 conf->gen.name, conf->reset_val);
2701 *conf->variable = conf->reset_val;
2706 struct config_string *conf = (struct config_string *) gconf;
2709 *conf->variable = NULL;
2710 conf->reset_val = NULL;
2711 conf->tentative_val = NULL;
2713 if (conf->boot_val == NULL)
2715 /* Cannot set value yet */
2719 str = guc_strdup(FATAL, conf->boot_val);
2720 conf->reset_val = str;
2722 if (conf->assign_hook)
2726 newstr = (*conf->assign_hook) (str, true,
2730 elog(FATAL, "failed to initialize %s to \"%s\"",
2731 conf->gen.name, str);
2733 else if (newstr != str)
2738 * See notes in set_config_option about casting
2740 str = (char *) newstr;
2741 conf->reset_val = str;
2744 *conf->variable = str;
2752 reporting_enabled = false;
2755 * Prevent any attempt to override the transaction modes from
2756 * non-interactive sources.
2758 SetConfigOption("transaction_isolation", "default",
2759 PGC_POSTMASTER, PGC_S_OVERRIDE);
2760 SetConfigOption("transaction_read_only", "no",
2761 PGC_POSTMASTER, PGC_S_OVERRIDE);
2764 * For historical reasons, some GUC parameters can receive defaults from
2765 * environment variables. Process those settings.
2768 env = getenv("PGPORT");
2770 SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2772 env = getenv("PGDATESTYLE");
2774 SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2776 env = getenv("PGCLIENTENCODING");
2778 SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
2783 * Select the configuration files and data directory to be used, and
2784 * do the initial read of postgresql.conf.
2786 * This is called after processing command-line switches.
2787 * userDoption is the -D switch value if any (NULL if unspecified).
2788 * progname is just for use in error messages.
2790 * Returns true on success; on failure, prints a suitable error message
2791 * to stderr and returns false.
2794 SelectConfigFiles(const char *userDoption, const char *progname)
2798 struct stat stat_buf;
2800 /* configdir is -D option, or $PGDATA if no -D */
2802 configdir = make_absolute_path(userDoption);
2804 configdir = make_absolute_path(getenv("PGDATA"));
2807 * Find the configuration file: if config_file was specified on the
2808 * command line, use it, else use configdir/postgresql.conf. In any case
2809 * ensure the result is an absolute path, so that it will be interpreted
2810 * the same way by future backends.
2813 fname = make_absolute_path(ConfigFileName);
2816 fname = guc_malloc(FATAL,
2817 strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
2818 sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
2822 write_stderr("%s does not know where to find the server configuration file.\n"
2823 "You must specify the --config-file or -D invocation "
2824 "option or set the PGDATA environment variable.\n",
2830 * Set the ConfigFileName GUC variable to its final value, ensuring that
2831 * it can't be overridden later.
2833 SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2837 * Now read the config file for the first time.
2839 if (stat(ConfigFileName, &stat_buf) != 0)
2841 write_stderr("%s cannot access the server configuration file \"%s\": %s\n",
2842 progname, ConfigFileName, strerror(errno));
2846 ProcessConfigFile(PGC_POSTMASTER);
2849 * If the data_directory GUC variable has been set, use that as DataDir;
2850 * otherwise use configdir if set; else punt.
2852 * Note: SetDataDir will copy and absolute-ize its argument, so we don't
2856 SetDataDir(data_directory);
2858 SetDataDir(configdir);
2861 write_stderr("%s does not know where to find the database system data.\n"
2862 "This can be specified as \"data_directory\" in \"%s\", "
2863 "or by the -D invocation option, or by the "
2864 "PGDATA environment variable.\n",
2865 progname, ConfigFileName);
2870 * Reflect the final DataDir value back into the data_directory GUC var.
2871 * (If you are wondering why we don't just make them a single variable,
2872 * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
2873 * child backends specially. XXX is that still true? Given that we now
2874 * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
2875 * DataDir in advance.)
2877 SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
2880 * Figure out where pg_hba.conf is, and make sure the path is absolute.
2883 fname = make_absolute_path(HbaFileName);
2886 fname = guc_malloc(FATAL,
2887 strlen(configdir) + strlen(HBA_FILENAME) + 2);
2888 sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
2892 write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
2893 "This can be specified as \"hba_file\" in \"%s\", "
2894 "or by the -D invocation option, or by the "
2895 "PGDATA environment variable.\n",
2896 progname, ConfigFileName);
2899 SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2903 * Likewise for pg_ident.conf.
2906 fname = make_absolute_path(IdentFileName);
2909 fname = guc_malloc(FATAL,
2910 strlen(configdir) + strlen(IDENT_FILENAME) + 2);
2911 sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
2915 write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
2916 "This can be specified as \"ident_file\" in \"%s\", "
2917 "or by the -D invocation option, or by the "
2918 "PGDATA environment variable.\n",
2919 progname, ConfigFileName);
2922 SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
2932 * Reset all options to their saved default values (implements RESET ALL)
2935 ResetAllOptions(void)
2939 for (i = 0; i < num_guc_variables; i++)
2941 struct config_generic *gconf = guc_variables[i];
2943 /* Don't reset non-SET-able values */
2944 if (gconf->context != PGC_SUSET &&
2945 gconf->context != PGC_USERSET)
2947 /* Don't reset if special exclusion from RESET ALL */
2948 if (gconf->flags & GUC_NO_RESET_ALL)
2950 /* No need to reset if wasn't SET */
2951 if (gconf->source <= PGC_S_OVERRIDE)
2954 /* Save old value to support transaction abort */
2955 push_old_value(gconf);
2957 switch (gconf->vartype)
2961 struct config_bool *conf = (struct config_bool *) gconf;
2963 if (conf->assign_hook)
2964 if (!(*conf->assign_hook) (conf->reset_val, true,
2966 elog(ERROR, "failed to reset %s", conf->gen.name);
2967 *conf->variable = conf->reset_val;
2968 conf->tentative_val = conf->reset_val;
2969 conf->gen.source = conf->gen.reset_source;
2970 conf->gen.tentative_source = conf->gen.reset_source;
2971 conf->gen.status |= GUC_HAVE_TENTATIVE;
2977 struct config_int *conf = (struct config_int *) gconf;
2979 if (conf->assign_hook)
2980 if (!(*conf->assign_hook) (conf->reset_val, true,
2982 elog(ERROR, "failed to reset %s", conf->gen.name);
2983 *conf->variable = conf->reset_val;
2984 conf->tentative_val = conf->reset_val;
2985 conf->gen.source = conf->gen.reset_source;
2986 conf->gen.tentative_source = conf->gen.reset_source;
2987 conf->gen.status |= GUC_HAVE_TENTATIVE;
2993 struct config_real *conf = (struct config_real *) gconf;
2995 if (conf->assign_hook)
2996 if (!(*conf->assign_hook) (conf->reset_val, true,
2998 elog(ERROR, "failed to reset %s", conf->gen.name);
2999 *conf->variable = conf->reset_val;
3000 conf->tentative_val = conf->reset_val;
3001 conf->gen.source = conf->gen.reset_source;
3002 conf->gen.tentative_source = conf->gen.reset_source;
3003 conf->gen.status |= GUC_HAVE_TENTATIVE;
3009 struct config_string *conf = (struct config_string *) gconf;
3012 if (conf->reset_val == NULL)
3014 /* Nothing to reset to, as yet; so do nothing */
3018 /* We need not strdup here */
3019 str = conf->reset_val;
3021 if (conf->assign_hook)
3025 newstr = (*conf->assign_hook) (str, true,
3028 elog(ERROR, "failed to reset %s", conf->gen.name);
3029 else if (newstr != str)
3032 * See notes in set_config_option about casting
3034 str = (char *) newstr;
3038 set_string_field(conf, conf->variable, str);
3039 set_string_field(conf, &conf->tentative_val, str);
3040 conf->gen.source = conf->gen.reset_source;
3041 conf->gen.tentative_source = conf->gen.reset_source;
3042 conf->gen.status |= GUC_HAVE_TENTATIVE;
3048 if (gconf->flags & GUC_REPORT)
3049 ReportGUCOption(gconf);
3056 * Push previous state during first assignment to a GUC variable
3057 * within a particular transaction.
3059 * We have to be willing to "back-fill" the state stack if the first
3060 * assignment occurs within a subtransaction nested several levels deep.
3061 * This ensures that if an intermediate transaction aborts, it will have
3062 * the proper value available to restore the setting to.
3065 push_old_value(struct config_generic * gconf)
3067 int my_level = GetCurrentTransactionNestLevel();
3070 /* If we're not inside a transaction, do nothing */
3076 /* Done if we already pushed it at this nesting depth */
3077 if (gconf->stack && gconf->stack->nest_level >= my_level)
3081 * We keep all the stack entries in TopTransactionContext so as to
3082 * avoid allocation problems when a subtransaction back-fills stack
3083 * entries for upper transaction levels.
3085 stack = (GucStack *) MemoryContextAlloc(TopTransactionContext,
3088 stack->prev = gconf->stack;
3089 stack->nest_level = stack->prev ? stack->prev->nest_level + 1 : 1;
3090 stack->status = gconf->status;
3091 stack->tentative_source = gconf->tentative_source;
3092 stack->source = gconf->source;
3094 switch (gconf->vartype)
3097 stack->tentative_val.boolval =
3098 ((struct config_bool *) gconf)->tentative_val;
3099 stack->value.boolval =
3100 *((struct config_bool *) gconf)->variable;
3104 stack->tentative_val.intval =
3105 ((struct config_int *) gconf)->tentative_val;
3106 stack->value.intval =
3107 *((struct config_int *) gconf)->variable;
3111 stack->tentative_val.realval =
3112 ((struct config_real *) gconf)->tentative_val;
3113 stack->value.realval =
3114 *((struct config_real *) gconf)->variable;
3118 stack->tentative_val.stringval =
3119 ((struct config_string *) gconf)->tentative_val;
3120 stack->value.stringval =
3121 *((struct config_string *) gconf)->variable;
3125 gconf->stack = stack;
3127 /* Set state to indicate nothing happened yet within this level */
3128 gconf->status = GUC_HAVE_STACK;
3130 /* Ensure we remember to pop at end of xact */
3136 * Do GUC processing at transaction or subtransaction commit or abort.
3139 AtEOXact_GUC(bool isCommit, bool isSubXact)
3144 /* Quick exit if nothing's changed in this transaction */
3148 my_level = GetCurrentTransactionNestLevel();
3149 Assert(isSubXact ? (my_level > 1) : (my_level == 1));
3151 for (i = 0; i < num_guc_variables; i++)
3153 struct config_generic *gconf = guc_variables[i];
3154 int my_status = gconf->status;
3155 GucStack *stack = gconf->stack;
3160 * Skip if nothing's happened to this var in this transaction
3164 Assert(stack == NULL);
3167 /* Assert that we stacked old value before changing it */
3168 Assert(stack != NULL && (my_status & GUC_HAVE_STACK));
3169 /* However, the last change may have been at an outer xact level */
3170 if (stack->nest_level < my_level)
3172 Assert(stack->nest_level == my_level);
3175 * We will pop the stack entry. Start by restoring outer xact status
3176 * (since we may want to modify it below). Be careful to use
3177 * my_status to reference the inner xact status below this point...
3179 gconf->status = stack->status;
3182 * We have two cases:
3184 * If commit and HAVE_TENTATIVE, set actual value to tentative (this
3185 * is to override a SET LOCAL if one occurred later than SET). We keep
3186 * the tentative value and propagate HAVE_TENTATIVE to the parent
3187 * status, allowing the SET's effect to percolate up. (But if we're
3188 * exiting the outermost transaction, we'll drop the HAVE_TENTATIVE
3191 * Otherwise, we have a transaction that aborted or executed only SET
3192 * LOCAL (or no SET at all). In either case it should have no further
3193 * effect, so restore both tentative and actual values from the stack
3197 useTentative = isCommit && (my_status & GUC_HAVE_TENTATIVE) != 0;
3200 switch (gconf->vartype)
3204 struct config_bool *conf = (struct config_bool *) gconf;
3206 GucSource newsource;
3210 newval = conf->tentative_val;
3211 newsource = conf->gen.tentative_source;
3212 conf->gen.status |= GUC_HAVE_TENTATIVE;
3216 newval = stack->value.boolval;
3217 newsource = stack->source;
3218 conf->tentative_val = stack->tentative_val.boolval;
3219 conf->gen.tentative_source = stack->tentative_source;
3222 if (*conf->variable != newval)
3224 if (conf->assign_hook)
3225 if (!(*conf->assign_hook) (newval,
3226 true, PGC_S_OVERRIDE))
3227 elog(LOG, "failed to commit %s",
3229 *conf->variable = newval;
3232 conf->gen.source = newsource;
3237 struct config_int *conf = (struct config_int *) gconf;
3239 GucSource newsource;
3243 newval = conf->tentative_val;
3244 newsource = conf->gen.tentative_source;
3245 conf->gen.status |= GUC_HAVE_TENTATIVE;
3249 newval = stack->value.intval;
3250 newsource = stack->source;
3251 conf->tentative_val = stack->tentative_val.intval;
3252 conf->gen.tentative_source = stack->tentative_source;
3255 if (*conf->variable != newval)
3257 if (conf->assign_hook)
3258 if (!(*conf->assign_hook) (newval,
3259 true, PGC_S_OVERRIDE))
3260 elog(LOG, "failed to commit %s",
3262 *conf->variable = newval;
3265 conf->gen.source = newsource;
3270 struct config_real *conf = (struct config_real *) gconf;
3272 GucSource newsource;
3276 newval = conf->tentative_val;
3277 newsource = conf->gen.tentative_source;
3278 conf->gen.status |= GUC_HAVE_TENTATIVE;
3282 newval = stack->value.realval;
3283 newsource = stack->source;
3284 conf->tentative_val = stack->tentative_val.realval;
3285 conf->gen.tentative_source = stack->tentative_source;
3288 if (*conf->variable != newval)
3290 if (conf->assign_hook)
3291 if (!(*conf->assign_hook) (newval,
3292 true, PGC_S_OVERRIDE))
3293 elog(LOG, "failed to commit %s",
3295 *conf->variable = newval;
3298 conf->gen.source = newsource;
3303 struct config_string *conf = (struct config_string *) gconf;
3305 GucSource newsource;
3309 newval = conf->tentative_val;
3310 newsource = conf->gen.tentative_source;
3311 conf->gen.status |= GUC_HAVE_TENTATIVE;
3315 newval = stack->value.stringval;
3316 newsource = stack->source;
3317 set_string_field(conf, &conf->tentative_val,
3318 stack->tentative_val.stringval);
3319 conf->gen.tentative_source = stack->tentative_source;
3322 if (*conf->variable != newval)
3324 if (conf->assign_hook)
3328 newstr = (*conf->assign_hook) (newval, true,
3331 elog(LOG, "failed to commit %s",
3333 else if (newstr != newval)
3336 * If newval should now be freed, it'll be
3337 * taken care of below.
3339 * See notes in set_config_option about
3342 newval = (char *) newstr;
3346 set_string_field(conf, conf->variable, newval);
3349 conf->gen.source = newsource;
3350 /* Release stacked values if not used anymore */
3351 set_string_field(conf, &stack->value.stringval,
3353 set_string_field(conf, &stack->tentative_val.stringval,
3355 /* Don't store tentative value separately after commit */
3357 set_string_field(conf, &conf->tentative_val, NULL);
3362 /* Finish popping the state stack */
3363 gconf->stack = stack->prev;
3367 * If we're now out of all xact levels, forget TENTATIVE status bit;
3368 * there's nothing tentative about the value anymore.
3372 Assert(gconf->stack == NULL);
3376 /* Report new value if we changed it */
3377 if (changed && (gconf->flags & GUC_REPORT))
3378 ReportGUCOption(gconf);
3382 * If we're now out of all xact levels, we can clear guc_dirty. (Note: we
3383 * cannot reset guc_dirty when exiting a subtransaction, because we know
3384 * that all outer transaction levels will have stacked values to deal
3393 * Start up automatic reporting of changes to variables marked GUC_REPORT.
3394 * This is executed at completion of backend startup.
3397 BeginReportingGUCOptions(void)
3402 * Don't do anything unless talking to an interactive frontend of protocol
3405 if (whereToSendOutput != DestRemote ||
3406 PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
3409 reporting_enabled = true;
3411 /* Transmit initial values of interesting variables */
3412 for (i = 0; i < num_guc_variables; i++)
3414 struct config_generic *conf = guc_variables[i];
3416 if (conf->flags & GUC_REPORT)
3417 ReportGUCOption(conf);
3422 * ReportGUCOption: if appropriate, transmit option value to frontend
3425 ReportGUCOption(struct config_generic * record)
3427 if (reporting_enabled && (record->flags & GUC_REPORT))
3429 char *val = _ShowOption(record);
3430 StringInfoData msgbuf;
3432 pq_beginmessage(&msgbuf, 'S');
3433 pq_sendstring(&msgbuf, record->name);
3434 pq_sendstring(&msgbuf, val);
3435 pq_endmessage(&msgbuf);
3443 * Try to interpret value as boolean value. Valid values are: true,
3444 * false, yes, no, on, off, 1, 0. If the string parses okay, return
3445 * true, else false. If result is not NULL, return the parsing result
3449 parse_bool(const char *value, bool *result)
3451 size_t len = strlen(value);
3453 if (pg_strncasecmp(value, "true", len) == 0)
3458 else if (pg_strncasecmp(value, "false", len) == 0)
3464 else if (pg_strncasecmp(value, "yes", len) == 0)
3469 else if (pg_strncasecmp(value, "no", len) == 0)
3475 else if (pg_strcasecmp(value, "on") == 0)
3480 else if (pg_strcasecmp(value, "off") == 0)
3486 else if (pg_strcasecmp(value, "1") == 0)
3491 else if (pg_strcasecmp(value, "0") == 0)
3500 *result = false; /* suppress compiler warning */
3509 * Try to parse value as an integer. The accepted formats are the
3510 * usual decimal, octal, or hexadecimal formats. If the string parses
3511 * okay, return true, else false. If result is not NULL, return the
3515 parse_int(const char *value, int *result)
3521 val = strtol(value, &endptr, 0);
3522 if (endptr == value || *endptr != '\0' || errno == ERANGE
3523 #ifdef HAVE_LONG_INT_64
3524 /* if long > 32 bits, check for overflow of int4 */
3525 || val != (long) ((int32) val)
3530 *result = 0; /* suppress compiler warning */
3534 *result = (int) val;
3541 * Try to parse value as a floating point constant in the usual
3542 * format. If the value parsed okay return true, else false. If
3543 * result is not NULL, return the semantic value there.
3546 parse_real(const char *value, double *result)
3552 val = strtod(value, &endptr);
3553 if (endptr == value || *endptr != '\0' || errno == ERANGE)
3556 *result = 0; /* suppress compiler warning */
3566 * Call a GucStringAssignHook function, being careful to free the
3567 * "newval" string if the hook ereports.
3569 * This is split out of set_config_option just to avoid the "volatile"
3570 * qualifiers that would otherwise have to be plastered all over.
3573 call_string_assign_hook(GucStringAssignHook assign_hook,
3574 char *newval, bool doit, GucSource source)
3580 result = (*assign_hook) (newval, doit, source);
3594 * Sets option `name' to given value. The value should be a string
3595 * which is going to be parsed and converted to the appropriate data
3596 * type. The context and source parameters indicate in which context this
3597 * function is being called so it can apply the access restrictions
3600 * If value is NULL, set the option to its default value. If the
3601 * parameter changeVal is false then don't really set the option but do all
3602 * the checks to see if it would work.
3604 * If there is an error (non-existing option, invalid value) then an
3605 * ereport(ERROR) is thrown *unless* this is called in a context where we
3606 * don't want to ereport (currently, startup or SIGHUP config file reread).
3607 * In that case we write a suitable error message via ereport(DEBUG) and
3608 * return false. This is working around the deficiencies in the ereport
3609 * mechanism, so don't blame me. In all other cases, the function
3610 * returns true, including cases where the input is valid but we chose
3611 * not to apply it because of context or source-priority considerations.
3613 * See also SetConfigOption for an external interface.
3616 set_config_option(const char *name, const char *value,
3617 GucContext context, GucSource source,
3618 bool isLocal, bool changeVal)
3620 struct config_generic *record;
3624 if (context == PGC_SIGHUP || source == PGC_S_DEFAULT)
3627 * To avoid cluttering the log, only the postmaster bleats loudly
3628 * about problems with the config file.
3630 elevel = IsUnderPostmaster ? DEBUG2 : LOG;
3632 else if (source == PGC_S_DATABASE || source == PGC_S_USER)
3637 record = find_option(name, elevel);
3641 (errcode(ERRCODE_UNDEFINED_OBJECT),
3642 errmsg("unrecognized configuration parameter \"%s\"", name)));
3647 * Check if the option can be set at this time. See guc.h for the precise
3648 * rules. Note that we don't want to throw errors if we're in the SIGHUP
3649 * context. In that case we just ignore the attempt and return true.
3651 switch (record->context)
3654 if (context == PGC_SIGHUP)
3656 if (context != PGC_INTERNAL)
3659 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3660 errmsg("parameter \"%s\" cannot be changed",
3665 case PGC_POSTMASTER:
3666 if (context == PGC_SIGHUP)
3668 if (changeVal && !is_newvalue_equal(record, value))
3670 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3671 errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
3676 if (context != PGC_POSTMASTER)
3679 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3680 errmsg("parameter \"%s\" cannot be changed after server start",
3686 if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
3689 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3690 errmsg("parameter \"%s\" cannot be changed now",
3696 * Hmm, the idea of the SIGHUP context is "ought to be global, but
3697 * can be changed after postmaster start". But there's nothing
3698 * that prevents a crafty administrator from sending SIGHUP
3699 * signals to individual backends only.
3703 if (context == PGC_SIGHUP)
3706 * If a PGC_BACKEND parameter is changed in the config file,
3707 * we want to accept the new value in the postmaster (whence
3708 * it will propagate to subsequently-started backends), but
3709 * ignore it in existing backends. This is a tad klugy, but
3710 * necessary because we don't re-read the config file during
3713 if (IsUnderPostmaster)
3716 else if (context != PGC_BACKEND && context != PGC_POSTMASTER)
3719 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3720 errmsg("parameter \"%s\" cannot be set after connection start",
3726 if (context == PGC_USERSET || context == PGC_BACKEND)
3729 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3730 errmsg("permission denied to set parameter \"%s\"",
3741 * Should we set reset/stacked values? (If so, the behavior is not
3744 makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL);
3747 * Ignore attempted set if overridden by previously processed setting.
3748 * However, if changeVal is false then plow ahead anyway since we are
3749 * trying to find out if the value is potentially good, not actually use
3750 * it. Also keep going if makeDefault is true, since we may want to set
3751 * the reset/stacked values even if we can't set the variable itself.
3753 if (record->source > source)
3755 if (changeVal && !makeDefault)
3757 elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
3765 * Evaluate value and set variable.
3767 switch (record->vartype)
3771 struct config_bool *conf = (struct config_bool *) record;
3776 if (!parse_bool(value, &newval))
3779 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3780 errmsg("parameter \"%s\" requires a Boolean value",
3787 newval = conf->reset_val;
3788 source = conf->gen.reset_source;
3791 if (conf->assign_hook)
3792 if (!(*conf->assign_hook) (newval, changeVal, source))
3795 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3796 errmsg("invalid value for parameter \"%s\": %d",
3797 name, (int) newval)));
3801 if (changeVal || makeDefault)
3803 /* Save old value to support transaction abort */
3805 push_old_value(&conf->gen);
3808 *conf->variable = newval;
3809 conf->gen.source = source;
3815 if (conf->gen.reset_source <= source)
3817 conf->reset_val = newval;
3818 conf->gen.reset_source = source;
3820 for (stack = conf->gen.stack; stack; stack = stack->prev)
3822 if (stack->source <= source)
3824 stack->value.boolval = newval;
3825 stack->source = source;
3831 conf->gen.status |= GUC_HAVE_LOCAL;
3836 conf->tentative_val = newval;
3837 conf->gen.tentative_source = source;
3838 conf->gen.status |= GUC_HAVE_TENTATIVE;
3847 struct config_int *conf = (struct config_int *) record;
3852 if (!parse_int(value, &newval))
3855 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3856 errmsg("parameter \"%s\" requires an integer value",
3860 if (newval < conf->min || newval > conf->max)
3863 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3864 errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)",
3865 newval, name, conf->min, conf->max)));
3871 newval = conf->reset_val;
3872 source = conf->gen.reset_source;
3875 if (conf->assign_hook)
3876 if (!(*conf->assign_hook) (newval, changeVal, source))
3879 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3880 errmsg("invalid value for parameter \"%s\": %d",
3885 if (changeVal || makeDefault)
3887 /* Save old value to support transaction abort */
3889 push_old_value(&conf->gen);
3892 *conf->variable = newval;
3893 conf->gen.source = source;
3899 if (conf->gen.reset_source <= source)
3901 conf->reset_val = newval;
3902 conf->gen.reset_source = source;
3904 for (stack = conf->gen.stack; stack; stack = stack->prev)
3906 if (stack->source <= source)
3908 stack->value.intval = newval;
3909 stack->source = source;
3915 conf->gen.status |= GUC_HAVE_LOCAL;
3920 conf->tentative_val = newval;
3921 conf->gen.tentative_source = source;
3922 conf->gen.status |= GUC_HAVE_TENTATIVE;
3931 struct config_real *conf = (struct config_real *) record;
3936 if (!parse_real(value, &newval))
3939 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3940 errmsg("parameter \"%s\" requires a numeric value",
3944 if (newval < conf->min || newval > conf->max)
3947 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3948 errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)",
3949 newval, name, conf->min, conf->max)));
3955 newval = conf->reset_val;
3956 source = conf->gen.reset_source;
3959 if (conf->assign_hook)
3960 if (!(*conf->assign_hook) (newval, changeVal, source))
3963 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3964 errmsg("invalid value for parameter \"%s\": %g",
3969 if (changeVal || makeDefault)
3971 /* Save old value to support transaction abort */
3973 push_old_value(&conf->gen);
3976 *conf->variable = newval;
3977 conf->gen.source = source;
3983 if (conf->gen.reset_source <= source)
3985 conf->reset_val = newval;
3986 conf->gen.reset_source = source;
3988 for (stack = conf->gen.stack; stack; stack = stack->prev)
3990 if (stack->source <= source)
3992 stack->value.realval = newval;
3993 stack->source = source;
3999 conf->gen.status |= GUC_HAVE_LOCAL;
4004 conf->tentative_val = newval;
4005 conf->gen.tentative_source = source;
4006 conf->gen.status |= GUC_HAVE_TENTATIVE;
4015 struct config_string *conf = (struct config_string *) record;
4020 newval = guc_strdup(elevel, value);
4024 * The only sort of "parsing" check we need to do is
4025 * apply truncation if GUC_IS_NAME.
4027 if (conf->gen.flags & GUC_IS_NAME)
4028 truncate_identifier(newval, strlen(newval), true);
4030 else if (conf->reset_val)
4033 * We could possibly avoid strdup here, but easier to make
4034 * this case work the same as the normal assignment case.
4036 newval = guc_strdup(elevel, conf->reset_val);
4039 source = conf->gen.reset_source;
4043 /* Nothing to reset to, as yet; so do nothing */
4047 if (conf->assign_hook)
4049 const char *hookresult;
4052 * If the hook ereports, we have to make sure we free
4053 * newval, else it will be a permanent memory leak.
4055 hookresult = call_string_assign_hook(conf->assign_hook,
4059 if (hookresult == NULL)
4063 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4064 errmsg("invalid value for parameter \"%s\": \"%s\"",
4065 name, value ? value : "")));
4068 else if (hookresult != newval)
4073 * Having to cast away const here is annoying, but the
4074 * alternative is to declare assign_hooks as returning
4075 * char*, which would mean they'd have to cast away
4076 * const, or as both taking and returning char*, which
4077 * doesn't seem attractive either --- we don't want
4078 * them to scribble on the passed str.
4080 newval = (char *) hookresult;
4084 if (changeVal || makeDefault)
4086 /* Save old value to support transaction abort */
4088 push_old_value(&conf->gen);
4091 set_string_field(conf, conf->variable, newval);
4092 conf->gen.source = source;
4098 if (conf->gen.reset_source <= source)
4100 set_string_field(conf, &conf->reset_val, newval);
4101 conf->gen.reset_source = source;
4103 for (stack = conf->gen.stack; stack; stack = stack->prev)
4105 if (stack->source <= source)
4107 set_string_field(conf, &stack->value.stringval,
4109 stack->source = source;
4112 /* Perhaps we didn't install newval anywhere */
4113 if (!string_field_used(conf, newval))
4118 conf->gen.status |= GUC_HAVE_LOCAL;
4123 set_string_field(conf, &conf->tentative_val, newval);
4124 conf->gen.tentative_source = source;
4125 conf->gen.status |= GUC_HAVE_TENTATIVE;
4135 if (changeVal && (record->flags & GUC_REPORT))
4136 ReportGUCOption(record);
4143 * Set a config option to the given value. See also set_config_option,
4144 * this is just the wrapper to be called from outside GUC. NB: this
4145 * is used only for non-transactional operations.
4148 SetConfigOption(const char *name, const char *value,
4149 GucContext context, GucSource source)
4151 (void) set_config_option(name, value, context, source, false, true);
4157 * Fetch the current value of the option `name'. If the option doesn't exist,
4158 * throw an ereport and don't return.
4160 * The string is *not* allocated for modification and is really only
4161 * valid until the next call to configuration related functions.
4164 GetConfigOption(const char *name)
4166 struct config_generic *record;
4167 static char buffer[256];
4169 record = find_option(name, ERROR);
4172 (errcode(ERRCODE_UNDEFINED_OBJECT),
4173 errmsg("unrecognized configuration parameter \"%s\"", name)));
4174 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4176 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4177 errmsg("must be superuser to examine \"%s\"", name)));
4179 switch (record->vartype)
4182 return *((struct config_bool *) record)->variable ? "on" : "off";
4185 snprintf(buffer, sizeof(buffer), "%d",
4186 *((struct config_int *) record)->variable);
4190 snprintf(buffer, sizeof(buffer), "%g",
4191 *((struct config_real *) record)->variable);
4195 return *((struct config_string *) record)->variable;
4201 * Get the RESET value associated with the given option.
4204 GetConfigOptionResetString(const char *name)
4206 struct config_generic *record;
4207 static char buffer[256];
4209 record = find_option(name, ERROR);
4212 (errcode(ERRCODE_UNDEFINED_OBJECT),
4213 errmsg("unrecognized configuration parameter \"%s\"", name)));
4214 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4216 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4217 errmsg("must be superuser to examine \"%s\"", name)));
4219 switch (record->vartype)
4222 return ((struct config_bool *) record)->reset_val ? "on" : "off";
4225 snprintf(buffer, sizeof(buffer), "%d",
4226 ((struct config_int *) record)->reset_val);
4230 snprintf(buffer, sizeof(buffer), "%g",
4231 ((struct config_real *) record)->reset_val);
4235 return ((struct config_string *) record)->reset_val;
4241 * Detect whether the given configuration option can only be set by
4245 IsSuperuserConfigOption(const char *name)
4247 struct config_generic *record;
4249 record = find_option(name, ERROR);
4250 /* On an unrecognized name, don't error, just return false. */
4253 return (record->context == PGC_SUSET);
4258 * flatten_set_variable_args
4259 * Given a parsenode List as emitted by the grammar for SET,
4260 * convert to the flat string representation used by GUC.
4262 * We need to be told the name of the variable the args are for, because
4263 * the flattening rules vary (ugh).
4265 * The result is NULL if input is NIL (ie, SET ... TO DEFAULT), otherwise
4266 * a palloc'd string.
4269 flatten_set_variable_args(const char *name, List *args)
4271 struct config_generic *record;
4277 * Fast path if just DEFAULT. We do not check the variable name in this
4278 * case --- necessary for RESET ALL to work correctly.
4283 /* Else get flags for the variable */
4284 record = find_option(name, ERROR);
4287 (errcode(ERRCODE_UNDEFINED_OBJECT),
4288 errmsg("unrecognized configuration parameter \"%s\"", name)));
4290 flags = record->flags;
4292 /* Complain if list input and non-list variable */
4293 if ((flags & GUC_LIST_INPUT) == 0 &&
4294 list_length(args) != 1)
4296 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4297 errmsg("SET %s takes only one argument", name)));
4299 initStringInfo(&buf);
4303 A_Const *arg = (A_Const *) lfirst(l);
4306 if (l != list_head(args))
4307 appendStringInfo(&buf, ", ");
4309 if (!IsA(arg, A_Const))
4310 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
4312 switch (nodeTag(&arg->val))
4315 appendStringInfo(&buf, "%ld", intVal(&arg->val));
4318 /* represented as a string, so just copy it */
4319 appendStringInfoString(&buf, strVal(&arg->val));
4322 val = strVal(&arg->val);
4323 if (arg->typename != NULL)
4326 * Must be a ConstInterval argument for TIME ZONE. Coerce
4327 * to interval and back to normalize the value and account
4334 DirectFunctionCall3(interval_in,
4335 CStringGetDatum(val),
4336 ObjectIdGetDatum(InvalidOid),
4337 Int32GetDatum(arg->typename->typmod));
4340 DatumGetCString(DirectFunctionCall1(interval_out,
4342 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
4347 * Plain string literal or identifier. For quote mode,
4348 * quote it if it's not a vanilla identifier.
4350 if (flags & GUC_LIST_QUOTE)
4351 appendStringInfoString(&buf, quote_identifier(val));
4353 appendStringInfoString(&buf, val);
4357 elog(ERROR, "unrecognized node type: %d",
4358 (int) nodeTag(&arg->val));
4371 SetPGVariable(const char *name, List *args, bool is_local)
4373 char *argstring = flatten_set_variable_args(name, args);
4375 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4376 set_config_option(name,
4378 (superuser() ? PGC_SUSET : PGC_USERSET),
4385 * SET command wrapped as a SQL callable function.
4388 set_config_by_name(PG_FUNCTION_ARGS)
4396 if (PG_ARGISNULL(0))
4398 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
4399 errmsg("SET requires parameter name")));
4401 /* Get the GUC variable name */
4402 name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4404 /* Get the desired value or set to NULL for a reset request */
4405 if (PG_ARGISNULL(1))
4408 value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
4411 * Get the desired state of is_local. Default to false if provided value
4414 if (PG_ARGISNULL(2))
4417 is_local = PG_GETARG_BOOL(2);
4419 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
4420 set_config_option(name,
4422 (superuser() ? PGC_SUSET : PGC_USERSET),
4427 /* get the new current value */
4428 new_value = GetConfigOptionByName(name, NULL);
4430 /* Convert return string to text */
4431 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
4434 PG_RETURN_TEXT_P(result_text);
4438 define_custom_variable(struct config_generic * variable)
4440 const char *name = variable->name;
4441 const char **nameAddr = &name;
4443 struct config_string *pHolder;
4444 struct config_generic **res = (struct config_generic **) bsearch(
4446 (void *) guc_variables,
4448 sizeof(struct config_generic *),
4453 add_guc_variable(variable, ERROR);
4458 * This better be a placeholder
4460 if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
4462 (errcode(ERRCODE_INTERNAL_ERROR),
4463 errmsg("attempt to redefine parameter \"%s\"", name)));
4465 Assert((*res)->vartype == PGC_STRING);
4466 pHolder = (struct config_string *) * res;
4468 /* We have the same name, no sorting is necessary */
4471 value = *pHolder->variable;
4474 * Assign the string value stored in the placeholder to the real variable.
4476 * XXX this is not really good enough --- it should be a nontransactional
4477 * assignment, since we don't want it to roll back if the current xact
4480 set_config_option(name, value,
4481 pHolder->gen.context, pHolder->gen.source,
4485 * Free up as much as we conveniently can of the placeholder structure
4486 * (this neglects any stack items...)
4488 set_string_field(pHolder, pHolder->variable, NULL);
4489 set_string_field(pHolder, &pHolder->reset_val, NULL);
4490 set_string_field(pHolder, &pHolder->tentative_val, NULL);
4496 init_custom_variable(struct config_generic * gen,
4498 const char *short_desc,
4499 const char *long_desc,
4501 enum config_type type)
4503 gen->name = guc_strdup(ERROR, name);
4504 gen->context = context;
4505 gen->group = CUSTOM_OPTIONS;
4506 gen->short_desc = short_desc;
4507 gen->long_desc = long_desc;
4508 gen->vartype = type;
4512 DefineCustomBoolVariable(const char *name,
4513 const char *short_desc,
4514 const char *long_desc,
4517 GucBoolAssignHook assign_hook,
4518 GucShowHook show_hook)
4520 size_t sz = sizeof(struct config_bool);
4521 struct config_bool *var = (struct config_bool *) guc_malloc(ERROR, sz);
4524 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_BOOL);
4526 var->variable = valueAddr;
4527 var->reset_val = *valueAddr;
4528 var->assign_hook = assign_hook;
4529 var->show_hook = show_hook;
4530 define_custom_variable(&var->gen);
4534 DefineCustomIntVariable(const char *name,
4535 const char *short_desc,
4536 const char *long_desc,
4541 GucIntAssignHook assign_hook,
4542 GucShowHook show_hook)
4544 size_t sz = sizeof(struct config_int);
4545 struct config_int *var = (struct config_int *) guc_malloc(ERROR, sz);
4548 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_INT);
4550 var->variable = valueAddr;
4551 var->reset_val = *valueAddr;
4552 var->min = minValue;
4553 var->max = maxValue;
4554 var->assign_hook = assign_hook;
4555 var->show_hook = show_hook;
4556 define_custom_variable(&var->gen);
4560 DefineCustomRealVariable(const char *name,
4561 const char *short_desc,
4562 const char *long_desc,
4567 GucRealAssignHook assign_hook,
4568 GucShowHook show_hook)
4570 size_t sz = sizeof(struct config_real);
4571 struct config_real *var = (struct config_real *) guc_malloc(ERROR, sz);
4574 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_REAL);
4576 var->variable = valueAddr;
4577 var->reset_val = *valueAddr;
4578 var->min = minValue;
4579 var->max = maxValue;
4580 var->assign_hook = assign_hook;
4581 var->show_hook = show_hook;
4582 define_custom_variable(&var->gen);
4586 DefineCustomStringVariable(const char *name,
4587 const char *short_desc,
4588 const char *long_desc,
4591 GucStringAssignHook assign_hook,
4592 GucShowHook show_hook)
4594 size_t sz = sizeof(struct config_string);
4595 struct config_string *var = (struct config_string *) guc_malloc(ERROR, sz);
4598 init_custom_variable(&var->gen, name, short_desc, long_desc, context, PGC_STRING);
4600 var->variable = valueAddr;
4601 var->reset_val = *valueAddr;
4602 var->assign_hook = assign_hook;
4603 var->show_hook = show_hook;
4604 define_custom_variable(&var->gen);
4608 EmitWarningsOnPlaceholders(const char *className)
4610 struct config_generic **vars = guc_variables;
4611 struct config_generic **last = vars + num_guc_variables;
4613 int nameLen = strlen(className);
4617 struct config_generic *var = *vars++;
4619 if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
4620 strncmp(className, var->name, nameLen) == 0 &&
4621 var->name[nameLen] == GUC_QUALIFIER_SEPARATOR)
4624 (errcode(ERRCODE_UNDEFINED_OBJECT),
4625 errmsg("unrecognized configuration parameter \"%s\"", var->name)));
4635 GetPGVariable(const char *name, DestReceiver *dest)
4637 if (pg_strcasecmp(name, "all") == 0)
4638 ShowAllGUCConfig(dest);
4640 ShowGUCConfigOption(name, dest);
4644 GetPGVariableResultDesc(const char *name)
4648 if (pg_strcasecmp(name, "all") == 0)
4650 /* need a tuple descriptor representing three TEXT columns */
4651 tupdesc = CreateTemplateTupleDesc(3, false);
4652 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4654 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4656 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4662 const char *varname;
4664 /* Get the canonical spelling of name */
4665 (void) GetConfigOptionByName(name, &varname);
4667 /* need a tuple descriptor representing a single TEXT column */
4668 tupdesc = CreateTemplateTupleDesc(1, false);
4669 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4679 ResetPGVariable(const char *name)
4681 if (pg_strcasecmp(name, "all") == 0)
4684 set_config_option(name,
4686 (superuser() ? PGC_SUSET : PGC_USERSET),
4697 ShowGUCConfigOption(const char *name, DestReceiver *dest)
4699 TupOutputState *tstate;
4701 const char *varname;
4704 /* Get the value and canonical spelling of name */
4705 value = GetConfigOptionByName(name, &varname);
4707 /* need a tuple descriptor representing a single TEXT column */
4708 tupdesc = CreateTemplateTupleDesc(1, false);
4709 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
4712 /* prepare for projection of tuples */
4713 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4716 do_text_output_oneline(tstate, value);
4718 end_tup_output(tstate);
4725 ShowAllGUCConfig(DestReceiver *dest)
4727 bool am_superuser = superuser();
4729 TupOutputState *tstate;
4733 /* need a tuple descriptor representing three TEXT columns */
4734 tupdesc = CreateTemplateTupleDesc(3, false);
4735 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4737 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4739 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
4743 /* prepare for projection of tuples */
4744 tstate = begin_tup_output_tupdesc(dest, tupdesc);
4746 for (i = 0; i < num_guc_variables; i++)
4748 struct config_generic *conf = guc_variables[i];
4750 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4751 ((conf->flags & GUC_SUPERUSER_ONLY) && !am_superuser))
4754 /* assign to the values array */
4755 values[0] = (char *) conf->name;
4756 values[1] = _ShowOption(conf);
4757 values[2] = (char *) conf->short_desc;
4759 /* send it to dest */
4760 do_tup_output(tstate, values);
4763 if (values[1] != NULL)
4767 end_tup_output(tstate);
4771 * Return GUC variable value by name; optionally return canonical
4772 * form of name. Return value is palloc'd.
4775 GetConfigOptionByName(const char *name, const char **varname)
4777 struct config_generic *record;
4779 record = find_option(name, ERROR);
4782 (errcode(ERRCODE_UNDEFINED_OBJECT),
4783 errmsg("unrecognized configuration parameter \"%s\"", name)));
4784 if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser())
4786 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4787 errmsg("must be superuser to examine \"%s\"", name)));
4790 *varname = record->name;
4792 return _ShowOption(record);
4796 * Return GUC variable value by variable number; optionally return canonical
4797 * form of name. Return value is palloc'd.
4800 GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
4803 struct config_generic *conf;
4805 /* check requested variable number valid */
4806 Assert((varnum >= 0) && (varnum < num_guc_variables));
4808 conf = guc_variables[varnum];
4812 if ((conf->flags & GUC_NO_SHOW_ALL) ||
4813 ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser()))
4819 /* first get the generic attributes */
4822 values[0] = conf->name;
4824 /* setting : use _ShowOption in order to avoid duplicating the logic */
4825 values[1] = _ShowOption(conf);
4828 values[2] = config_group_names[conf->group];
4831 values[3] = conf->short_desc;
4834 values[4] = conf->long_desc;
4837 values[5] = GucContext_Names[conf->context];
4840 values[6] = config_type_names[conf->vartype];
4843 values[7] = GucSource_Names[conf->source];
4845 /* now get the type specifc attributes */
4846 switch (conf->vartype)
4860 struct config_int *lconf = (struct config_int *) conf;
4863 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
4864 values[8] = pstrdup(buffer);
4867 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
4868 values[9] = pstrdup(buffer);
4874 struct config_real *lconf = (struct config_real *) conf;
4877 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
4878 values[8] = pstrdup(buffer);
4881 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
4882 values[9] = pstrdup(buffer);
4899 * should never get here, but in case we do, set 'em to NULL
4913 * Return the total number of GUC variables
4916 GetNumConfigOptions(void)
4918 return num_guc_variables;
4922 * show_config_by_name - equiv to SHOW X command but implemented as
4926 show_config_by_name(PG_FUNCTION_ARGS)
4932 /* Get the GUC variable name */
4933 varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
4936 varval = GetConfigOptionByName(varname, NULL);
4938 /* Convert to text */
4939 result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));
4942 PG_RETURN_TEXT_P(result_text);
4946 * show_all_settings - equiv to SHOW ALL command but implemented as
4949 #define NUM_PG_SETTINGS_ATTS 10
4952 show_all_settings(PG_FUNCTION_ARGS)
4954 FuncCallContext *funcctx;
4958 AttInMetadata *attinmeta;
4959 MemoryContext oldcontext;
4961 /* stuff done only on the first call of the function */
4962 if (SRF_IS_FIRSTCALL())
4964 /* create a function context for cross-call persistence */
4965 funcctx = SRF_FIRSTCALL_INIT();
4968 * switch to memory context appropriate for multiple function calls
4970 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
4973 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
4974 * of the appropriate types
4976 tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
4977 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
4979 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
4981 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "category",
4983 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "short_desc",
4985 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "extra_desc",
4987 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "context",
4989 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "vartype",
4991 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "source",
4993 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "min_val",
4995 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "max_val",
4999 * Generate attribute metadata needed later to produce tuples from raw
5002 attinmeta = TupleDescGetAttInMetadata(tupdesc);
5003 funcctx->attinmeta = attinmeta;
5005 /* total number of tuples to be returned */
5006 funcctx->max_calls = GetNumConfigOptions();
5008 MemoryContextSwitchTo(oldcontext);
5011 /* stuff done on every call of the function */
5012 funcctx = SRF_PERCALL_SETUP();
5014 call_cntr = funcctx->call_cntr;
5015 max_calls = funcctx->max_calls;
5016 attinmeta = funcctx->attinmeta;
5018 if (call_cntr < max_calls) /* do when there is more left to send */
5020 char *values[NUM_PG_SETTINGS_ATTS];
5026 * Get the next visible GUC variable name and value
5030 GetConfigOptionByNum(call_cntr, (const char **) values, &noshow);
5033 /* bump the counter and get the next config setting */
5034 call_cntr = ++funcctx->call_cntr;
5036 /* make sure we haven't gone too far now */
5037 if (call_cntr >= max_calls)
5038 SRF_RETURN_DONE(funcctx);
5043 tuple = BuildTupleFromCStrings(attinmeta, values);
5045 /* make the tuple into a datum */
5046 result = HeapTupleGetDatum(tuple);
5048 SRF_RETURN_NEXT(funcctx, result);
5052 /* do when there is no more left */
5053 SRF_RETURN_DONE(funcctx);
5058 _ShowOption(struct config_generic * record)
5063 switch (record->vartype)
5067 struct config_bool *conf = (struct config_bool *) record;
5069 if (conf->show_hook)
5070 val = (*conf->show_hook) ();
5072 val = *conf->variable ? "on" : "off";
5078 struct config_int *conf = (struct config_int *) record;
5080 if (conf->show_hook)
5081 val = (*conf->show_hook) ();
5084 snprintf(buffer, sizeof(buffer), "%d",
5093 struct config_real *conf = (struct config_real *) record;
5095 if (conf->show_hook)
5096 val = (*conf->show_hook) ();
5099 snprintf(buffer, sizeof(buffer), "%g",
5108 struct config_string *conf = (struct config_string *) record;
5110 if (conf->show_hook)
5111 val = (*conf->show_hook) ();
5112 else if (*conf->variable && **conf->variable)
5113 val = *conf->variable;
5120 /* just to keep compiler quiet */
5125 return pstrdup(val);
5130 is_newvalue_equal(struct config_generic *record, const char *newvalue)
5132 switch (record->vartype)
5136 struct config_bool *conf = (struct config_bool *) record;
5139 return parse_bool(newvalue, &newval) && *conf->variable == newval;
5143 struct config_int *conf = (struct config_int *) record;
5146 return parse_int(newvalue, &newval) && *conf->variable == newval;
5150 struct config_real *conf = (struct config_real *) record;
5153 return parse_real(newvalue, &newval) && *conf->variable == newval;
5157 struct config_string *conf = (struct config_string *) record;
5159 return strcmp(*conf->variable, newvalue) == 0;
5170 * This routine dumps out all non-default GUC options into a binary
5171 * file that is read by all exec'ed backends. The format is:
5173 * variable name, string, null terminated
5174 * variable value, string, null terminated
5175 * variable source, integer
5178 write_nondefault_variables(GucContext context)
5184 Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
5186 elevel = (context == PGC_SIGHUP) ? LOG : ERROR;
5191 fp = AllocateFile(CONFIG_EXEC_PARAMS_NEW, "w");
5195 (errcode_for_file_access(),
5196 errmsg("could not write to file \"%s\": %m",
5197 CONFIG_EXEC_PARAMS_NEW)));
5201 for (i = 0; i < num_guc_variables; i++)
5203 struct config_generic *gconf = guc_variables[i];
5205 if (gconf->source != PGC_S_DEFAULT)
5207 fprintf(fp, "%s", gconf->name);
5210 switch (gconf->vartype)
5214 struct config_bool *conf = (struct config_bool *) gconf;
5216 if (*conf->variable == 0)
5217 fprintf(fp, "false");
5219 fprintf(fp, "true");
5225 struct config_int *conf = (struct config_int *) gconf;
5227 fprintf(fp, "%d", *conf->variable);
5233 struct config_real *conf = (struct config_real *) gconf;
5235 /* Could lose precision here? */
5236 fprintf(fp, "%f", *conf->variable);
5242 struct config_string *conf = (struct config_string *) gconf;
5244 fprintf(fp, "%s", *conf->variable);
5251 fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
5258 (errcode_for_file_access(),
5259 errmsg("could not write to file \"%s\": %m",
5260 CONFIG_EXEC_PARAMS_NEW)));
5265 * Put new file in place. This could delay on Win32, but we don't hold
5266 * any exclusive locks.
5268 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5273 * Read string, including null byte from file
5275 * Return NULL on EOF and nothing read
5278 read_string_with_null(FILE *fp)
5287 if ((ch = fgetc(fp)) == EOF)
5292 elog(FATAL, "invalid format of exec config params file");
5295 str = guc_malloc(FATAL, maxlen);
5296 else if (i == maxlen)
5297 str = guc_realloc(FATAL, str, maxlen *= 2);
5306 * This routine loads a previous postmaster dump of its non-default
5310 read_nondefault_variables(void)
5320 fp = AllocateFile(CONFIG_EXEC_PARAMS, "r");
5323 /* File not found is fine */
5324 if (errno != ENOENT)
5326 (errcode_for_file_access(),
5327 errmsg("could not read from file \"%s\": %m",
5328 CONFIG_EXEC_PARAMS)));
5334 struct config_generic *record;
5336 if ((varname = read_string_with_null(fp)) == NULL)
5339 if ((record = find_option(varname, FATAL)) == NULL)
5340 elog(FATAL, "failed to locate variable %s in exec config params file", varname);
5341 if ((varvalue = read_string_with_null(fp)) == NULL)
5342 elog(FATAL, "invalid format of exec config params file");
5343 if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
5344 elog(FATAL, "invalid format of exec config params file");
5346 (void) set_config_option(varname, varvalue, record->context,
5347 varsource, false, true);
5354 #endif /* EXEC_BACKEND */
5358 * A little "long argument" simulation, although not quite GNU
5359 * compliant. Takes a string of the form "some-option=some value" and
5360 * returns name = "some_option" and value = "some value" in malloc'ed
5361 * storage. Note that '-' is converted to '_' in the option name. If
5362 * there is no '=' in the input string then value will be NULL.
5365 ParseLongOption(const char *string, char **name, char **value)
5374 equal_pos = strcspn(string, "=");
5376 if (string[equal_pos] == '=')
5378 *name = guc_malloc(FATAL, equal_pos + 1);
5379 strncpy(*name, string, equal_pos);
5380 (*name)[equal_pos] = '\0';
5382 *value = guc_strdup(FATAL, &string[equal_pos + 1]);
5386 /* no equal sign in string */
5387 *name = guc_strdup(FATAL, string);
5391 for (cp = *name; *cp; cp++)
5398 * Handle options fetched from pg_database.datconfig or pg_authid.rolconfig.
5399 * The array parameter must be an array of TEXT (it must not be NULL).
5402 ProcessGUCArray(ArrayType *array, GucSource source)
5406 Assert(array != NULL);
5407 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5408 Assert(ARR_NDIM(array) == 1);
5409 Assert(ARR_LBOUND(array)[0] == 1);
5410 Assert(source == PGC_S_DATABASE || source == PGC_S_USER);
5412 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5420 d = array_ref(array, 1, &i,
5421 -1 /* varlenarray */ ,
5422 -1 /* TEXT's typlen */ ,
5423 false /* TEXT's typbyval */ ,
5424 'i' /* TEXT's typalign */ ,
5430 s = DatumGetCString(DirectFunctionCall1(textout, d));
5432 ParseLongOption(s, &name, &value);
5436 (errcode(ERRCODE_SYNTAX_ERROR),
5437 errmsg("could not parse setting for parameter \"%s\"", name)));
5443 * We process all these options at SUSET level. We assume that the
5444 * right to insert an option into pg_database or pg_authid was checked
5445 * when it was inserted.
5447 SetConfigOption(name, value, PGC_SUSET, source);
5457 * Add an entry to an option array. The array parameter may be NULL
5458 * to indicate the current table entry is NULL.
5461 GUCArrayAdd(ArrayType *array, const char *name, const char *value)
5463 const char *varname;
5471 /* test if the option is valid */
5472 set_config_option(name, value,
5473 superuser() ? PGC_SUSET : PGC_USERSET,
5474 PGC_S_TEST, false, false);
5476 /* convert name to canonical spelling, so we can use plain strcmp */
5477 (void) GetConfigOptionByName(name, &varname);
5480 newval = palloc(strlen(name) + 1 + strlen(value) + 1);
5481 sprintf(newval, "%s=%s", name, value);
5482 datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
5490 Assert(ARR_ELEMTYPE(array) == TEXTOID);
5491 Assert(ARR_NDIM(array) == 1);
5492 Assert(ARR_LBOUND(array)[0] == 1);
5494 index = ARR_DIMS(array)[0] + 1; /* add after end */
5496 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5501 d = array_ref(array, 1, &i,
5502 -1 /* varlenarray */ ,
5503 -1 /* TEXT's typlen */ ,
5504 false /* TEXT's typbyval */ ,
5505 'i' /* TEXT's typalign */ ,
5509 current = DatumGetCString(DirectFunctionCall1(textout, d));
5510 if (strncmp(current, newval, strlen(name) + 1) == 0)
5517 a = array_set(array, 1, &index,
5520 -1 /* varlena array */ ,
5521 -1 /* TEXT's typlen */ ,
5522 false /* TEXT's typbyval */ ,
5523 'i' /* TEXT's typalign */ );
5526 a = construct_array(&datum, 1,
5535 * Delete an entry from an option array. The array parameter may be NULL
5536 * to indicate the current table entry is NULL. Also, if the return value
5537 * is NULL then a null should be stored.
5540 GUCArrayDelete(ArrayType *array, const char *name)
5542 const char *varname;
5543 ArrayType *newarray;
5549 /* test if the option is valid */
5550 set_config_option(name, NULL,
5551 superuser() ? PGC_SUSET : PGC_USERSET,
5552 PGC_S_TEST, false, false);
5554 /* convert name to canonical spelling, so we can use plain strcmp */
5555 (void) GetConfigOptionByName(name, &varname);
5558 /* if array is currently null, then surely nothing to delete */
5565 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
5571 d = array_ref(array, 1, &i,
5572 -1 /* varlenarray */ ,
5573 -1 /* TEXT's typlen */ ,
5574 false /* TEXT's typbyval */ ,
5575 'i' /* TEXT's typalign */ ,
5579 val = DatumGetCString(DirectFunctionCall1(textout, d));
5581 /* ignore entry if it's what we want to delete */
5582 if (strncmp(val, name, strlen(name)) == 0
5583 && val[strlen(name)] == '=')
5586 /* else add it to the output array */
5589 newarray = array_set(newarray, 1, &index,
5592 -1 /* varlenarray */ ,
5593 -1 /* TEXT's typlen */ ,
5594 false /* TEXT's typbyval */ ,
5595 'i' /* TEXT's typalign */ );
5598 newarray = construct_array(&d, 1,
5610 * assign_hook subroutines
5614 assign_log_destination(const char *value, bool doit, GucSource source)
5621 /* Need a modifiable copy of string */
5622 rawstring = pstrdup(value);
5624 /* Parse string into list of identifiers */
5625 if (!SplitIdentifierString(rawstring, ',', &elemlist))
5627 /* syntax error in list */
5629 list_free(elemlist);
5630 if (source >= PGC_S_INTERACTIVE)
5632 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5633 errmsg("invalid list syntax for parameter \"log_destination\"")));
5637 foreach(l, elemlist)
5639 char *tok = (char *) lfirst(l);
5641 if (pg_strcasecmp(tok, "stderr") == 0)
5642 newlogdest |= LOG_DESTINATION_STDERR;
5644 else if (pg_strcasecmp(tok, "syslog") == 0)
5645 newlogdest |= LOG_DESTINATION_SYSLOG;
5648 else if (pg_strcasecmp(tok, "eventlog") == 0)
5649 newlogdest |= LOG_DESTINATION_EVENTLOG;
5653 if (source >= PGC_S_INTERACTIVE)
5655 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5656 errmsg("unrecognized \"log_destination\" key word: \"%s\"",
5659 list_free(elemlist);
5665 Log_destination = newlogdest;
5668 list_free(elemlist);
5676 assign_syslog_facility(const char *facility, bool doit, GucSource source)
5680 if (pg_strcasecmp(facility, "LOCAL0") == 0)
5681 syslog_fac = LOG_LOCAL0;
5682 else if (pg_strcasecmp(facility, "LOCAL1") == 0)
5683 syslog_fac = LOG_LOCAL1;
5684 else if (pg_strcasecmp(facility, "LOCAL2") == 0)
5685 syslog_fac = LOG_LOCAL2;
5686 else if (pg_strcasecmp(facility, "LOCAL3") == 0)
5687 syslog_fac = LOG_LOCAL3;
5688 else if (pg_strcasecmp(facility, "LOCAL4") == 0)
5689 syslog_fac = LOG_LOCAL4;
5690 else if (pg_strcasecmp(facility, "LOCAL5") == 0)
5691 syslog_fac = LOG_LOCAL5;
5692 else if (pg_strcasecmp(facility, "LOCAL6") == 0)
5693 syslog_fac = LOG_LOCAL6;
5694 else if (pg_strcasecmp(facility, "LOCAL7") == 0)
5695 syslog_fac = LOG_LOCAL7;
5697 return NULL; /* reject */
5701 syslog_facility = syslog_fac;
5702 set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
5710 assign_syslog_ident(const char *ident, bool doit, GucSource source)
5713 set_syslog_parameters(ident, syslog_facility);
5717 #endif /* HAVE_SYSLOG */
5721 assign_defaultxactisolevel(const char *newval, bool doit, GucSource source)
5723 if (pg_strcasecmp(newval, "serializable") == 0)
5726 DefaultXactIsoLevel = XACT_SERIALIZABLE;
5728 else if (pg_strcasecmp(newval, "repeatable read") == 0)
5731 DefaultXactIsoLevel = XACT_REPEATABLE_READ;
5733 else if (pg_strcasecmp(newval, "read committed") == 0)
5736 DefaultXactIsoLevel = XACT_READ_COMMITTED;
5738 else if (pg_strcasecmp(newval, "read uncommitted") == 0)
5741 DefaultXactIsoLevel = XACT_READ_UNCOMMITTED;
5749 assign_log_min_messages(const char *newval,
5750 bool doit, GucSource source)
5752 return (assign_msglvl(&log_min_messages, newval, doit, source));
5756 assign_client_min_messages(const char *newval, bool doit, GucSource source)
5758 return (assign_msglvl(&client_min_messages, newval, doit, source));
5762 assign_min_error_statement(const char *newval, bool doit, GucSource source)
5764 return (assign_msglvl(&log_min_error_statement, newval, doit, source));
5768 assign_msglvl(int *var, const char *newval, bool doit, GucSource source)
5770 if (pg_strcasecmp(newval, "debug") == 0)
5775 else if (pg_strcasecmp(newval, "debug5") == 0)
5780 else if (pg_strcasecmp(newval, "debug4") == 0)
5785 else if (pg_strcasecmp(newval, "debug3") == 0)
5790 else if (pg_strcasecmp(newval, "debug2") == 0)
5795 else if (pg_strcasecmp(newval, "debug1") == 0)
5800 else if (pg_strcasecmp(newval, "log") == 0)
5807 * Client_min_messages always prints 'info', but we allow it as a value
5810 else if (pg_strcasecmp(newval, "info") == 0)
5815 else if (pg_strcasecmp(newval, "notice") == 0)
5820 else if (pg_strcasecmp(newval, "warning") == 0)
5825 else if (pg_strcasecmp(newval, "error") == 0)
5830 /* We allow FATAL/PANIC for client-side messages too. */
5831 else if (pg_strcasecmp(newval, "fatal") == 0)
5836 else if (pg_strcasecmp(newval, "panic") == 0)
5842 return NULL; /* fail */
5843 return newval; /* OK */
5847 assign_log_error_verbosity(const char *newval, bool doit, GucSource source)
5849 if (pg_strcasecmp(newval, "terse") == 0)
5852 Log_error_verbosity = PGERROR_TERSE;
5854 else if (pg_strcasecmp(newval, "default") == 0)
5857 Log_error_verbosity = PGERROR_DEFAULT;
5859 else if (pg_strcasecmp(newval, "verbose") == 0)
5862 Log_error_verbosity = PGERROR_VERBOSE;
5865 return NULL; /* fail */
5866 return newval; /* OK */
5870 assign_log_statement(const char *newval, bool doit, GucSource source)
5872 if (pg_strcasecmp(newval, "none") == 0)
5875 log_statement = LOGSTMT_NONE;
5877 else if (pg_strcasecmp(newval, "ddl") == 0)
5880 log_statement = LOGSTMT_DDL;
5882 else if (pg_strcasecmp(newval, "mod") == 0)
5885 log_statement = LOGSTMT_MOD;
5887 else if (pg_strcasecmp(newval, "all") == 0)
5890 log_statement = LOGSTMT_ALL;
5893 return NULL; /* fail */
5894 return newval; /* OK */
5898 show_num_temp_buffers(void)
5901 * We show the GUC var until local buffers have been initialized, and
5902 * NLocBuffer afterwards.
5904 static char nbuf[32];
5906 sprintf(nbuf, "%d", NLocBuffer ? NLocBuffer : num_temp_buffers);
5911 assign_phony_autocommit(bool newval, bool doit, GucSource source)
5915 if (doit && source >= PGC_S_INTERACTIVE)
5917 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5918 errmsg("SET AUTOCOMMIT TO OFF is no longer supported")));
5925 assign_custom_variable_classes(const char *newval, bool doit, GucSource source)
5928 * Check syntax. newval must be a comma separated list of identifiers.
5929 * Whitespace is allowed but skipped.
5931 bool hasSpaceAfterToken = false;
5932 const char *cp = newval;
5937 initStringInfo(&buf);
5938 while ((c = *cp++) != 0)
5943 hasSpaceAfterToken = true;
5949 hasSpaceAfterToken = false;
5953 appendStringInfoChar(&buf, ',');
5958 if (hasSpaceAfterToken || !isalnum(c))
5961 * Syntax error due to token following space after token or non
5962 * alpha numeric character
5965 (errcode(ERRCODE_SYNTAX_ERROR),
5966 errmsg("invalid syntax for \"custom_variable_classes\": \"%s\"", newval)));
5971 appendStringInfoChar(&buf, (char) c);
5974 /* Remove stray ',' at end */
5975 if (symLen == 0 && buf.len > 0)
5976 buf.data[--buf.len] = '\0';
5981 newval = strdup(buf.data);
5988 assign_debug_assertions(bool newval, bool doit, GucSource source)
5990 #ifndef USE_ASSERT_CHECKING
5993 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5994 errmsg("assertion checking is not supported by this build")));
6000 assign_ssl(bool newval, bool doit, GucSource source)
6005 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6006 errmsg("SSL is not supported by this build")));
6012 assign_stage_log_stats(bool newval, bool doit, GucSource source)
6014 if (newval && log_statement_stats)
6016 if (source >= PGC_S_INTERACTIVE)
6018 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6019 errmsg("cannot enable parameter when \"log_statement_stats\" is true")));
6020 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6021 else if (source != PGC_S_OVERRIDE)
6028 assign_log_stats(bool newval, bool doit, GucSource source)
6031 (log_parser_stats || log_planner_stats || log_executor_stats))
6033 if (source >= PGC_S_INTERACTIVE)
6035 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6036 errmsg("cannot enable \"log_statement_stats\" when "
6037 "\"log_parser_stats\", \"log_planner_stats\", "
6038 "or \"log_executor_stats\" is true")));
6039 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6040 else if (source != PGC_S_OVERRIDE)
6047 assign_transaction_read_only(bool newval, bool doit, GucSource source)
6049 /* Can't go to r/w mode inside a r/o transaction */
6050 if (newval == false && XactReadOnly && IsSubTransaction())
6052 if (source >= PGC_S_INTERACTIVE)
6054 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6055 errmsg("cannot set transaction read-write mode inside a read-only transaction")));
6056 /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
6057 else if (source != PGC_S_OVERRIDE)
6064 assign_canonical_path(const char *newval, bool doit, GucSource source)
6068 char *canon_val = guc_strdup(ERROR, newval);
6070 canonicalize_path(canon_val);
6078 assign_backslash_quote(const char *newval, bool doit, GucSource source)
6080 BackslashQuoteType bq;
6084 * Although only "on", "off", and "safe_encoding" are documented,
6085 * we use parse_bool so we can accept all the likely variants of
6088 if (pg_strcasecmp(newval, "safe_encoding") == 0)
6089 bq = BACKSLASH_QUOTE_SAFE_ENCODING;
6090 else if (parse_bool(newval, &bqbool))
6092 bq = bqbool ? BACKSLASH_QUOTE_ON : BACKSLASH_QUOTE_OFF;
6095 return NULL; /* reject */
6098 backslash_quote = bq;
6104 assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
6107 return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
6113 show_tcp_keepalives_idle(void)
6115 static char nbuf[16];
6117 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
6122 assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
6125 return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
6131 show_tcp_keepalives_interval(void)
6133 static char nbuf[16];
6135 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
6140 assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
6143 return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
6149 show_tcp_keepalives_count(void)
6151 static char nbuf[16];
6153 snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
6158 #include "guc-file.c"