PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
guc.c
Go to the documentation of this file.
1 /*--------------------------------------------------------------------
2  * guc.c
3  *
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.
7  *
8  *
9  * Copyright (c) 2000-2017, PostgreSQL Global Development Group
10  * Written by Peter Eisentraut <peter_e@gmx.net>.
11  *
12  * IDENTIFICATION
13  * src/backend/utils/misc/guc.c
14  *
15  *--------------------------------------------------------------------
16  */
17 #include "postgres.h"
18 
19 #include <ctype.h>
20 #include <float.h>
21 #include <math.h>
22 #include <limits.h>
23 #include <unistd.h>
24 #include <sys/stat.h>
25 #ifdef HAVE_SYSLOG
26 #include <syslog.h>
27 #endif
28 
29 #include "access/commit_ts.h"
30 #include "access/gin.h"
31 #include "access/rmgr.h"
32 #include "access/transam.h"
33 #include "access/twophase.h"
34 #include "access/xact.h"
35 #include "access/xlog_internal.h"
36 #include "catalog/namespace.h"
37 #include "catalog/pg_authid.h"
38 #include "commands/async.h"
39 #include "commands/prepare.h"
40 #include "commands/user.h"
41 #include "commands/vacuum.h"
42 #include "commands/variable.h"
43 #include "commands/trigger.h"
44 #include "funcapi.h"
45 #include "libpq/auth.h"
46 #include "libpq/be-fsstubs.h"
47 #include "libpq/libpq.h"
48 #include "libpq/pqformat.h"
49 #include "miscadmin.h"
50 #include "optimizer/cost.h"
51 #include "optimizer/geqo.h"
52 #include "optimizer/paths.h"
53 #include "optimizer/planmain.h"
54 #include "parser/parse_expr.h"
55 #include "parser/parse_type.h"
56 #include "parser/parser.h"
57 #include "parser/scansup.h"
58 #include "pgstat.h"
59 #include "postmaster/autovacuum.h"
61 #include "postmaster/bgwriter.h"
62 #include "postmaster/postmaster.h"
63 #include "postmaster/syslogger.h"
64 #include "postmaster/walwriter.h"
66 #include "replication/slot.h"
67 #include "replication/syncrep.h"
69 #include "replication/walsender.h"
70 #include "storage/bufmgr.h"
71 #include "storage/dsm_impl.h"
72 #include "storage/standby.h"
73 #include "storage/fd.h"
74 #include "storage/pg_shmem.h"
75 #include "storage/proc.h"
76 #include "storage/predicate.h"
77 #include "tcop/tcopprot.h"
78 #include "tsearch/ts_cache.h"
79 #include "utils/builtins.h"
80 #include "utils/bytea.h"
81 #include "utils/guc_tables.h"
82 #include "utils/memutils.h"
83 #include "utils/pg_locale.h"
84 #include "utils/plancache.h"
85 #include "utils/portal.h"
86 #include "utils/ps_status.h"
87 #include "utils/rls.h"
88 #include "utils/snapmgr.h"
89 #include "utils/tzparser.h"
90 #include "utils/varlena.h"
91 #include "utils/xml.h"
92 
93 #ifndef PG_KRB_SRVTAB
94 #define PG_KRB_SRVTAB ""
95 #endif
96 
97 #define CONFIG_FILENAME "postgresql.conf"
98 #define HBA_FILENAME "pg_hba.conf"
99 #define IDENT_FILENAME "pg_ident.conf"
100 
101 #ifdef EXEC_BACKEND
102 #define CONFIG_EXEC_PARAMS "global/config_exec_params"
103 #define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
104 #endif
105 
106 /*
107  * Precision with which REAL type guc values are to be printed for GUC
108  * serialization.
109  */
110 #define REALTYPE_PRECISION 17
111 
112 /* XXX these should appear in other modules' header files */
113 extern bool Log_disconnections;
114 extern int CommitDelay;
115 extern int CommitSiblings;
116 extern char *default_tablespace;
117 extern char *temp_tablespaces;
118 extern bool ignore_checksum_failure;
119 extern bool synchronize_seqscans;
120 
121 #ifdef TRACE_SYNCSCAN
122 extern bool trace_syncscan;
123 #endif
124 #ifdef DEBUG_BOUNDED_SORT
125 extern bool optimize_bounded_sort;
126 #endif
127 
129 
130 /* global variables for check hook support */
134 
135 static void do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3, 4);
136 
137 static void set_config_sourcefile(const char *name, char *sourcefile,
138  int sourceline);
139 static bool call_bool_check_hook(struct config_bool * conf, bool *newval,
140  void **extra, GucSource source, int elevel);
141 static bool call_int_check_hook(struct config_int * conf, int *newval,
142  void **extra, GucSource source, int elevel);
143 static bool call_real_check_hook(struct config_real * conf, double *newval,
144  void **extra, GucSource source, int elevel);
145 static bool call_string_check_hook(struct config_string * conf, char **newval,
146  void **extra, GucSource source, int elevel);
147 static bool call_enum_check_hook(struct config_enum * conf, int *newval,
148  void **extra, GucSource source, int elevel);
149 
150 static bool check_log_destination(char **newval, void **extra, GucSource source);
151 static void assign_log_destination(const char *newval, void *extra);
152 
153 static bool check_wal_consistency_checking(char **newval, void **extra,
154  GucSource source);
155 static void assign_wal_consistency_checking(const char *newval, void *extra);
156 
157 #ifdef HAVE_SYSLOG
158 static int syslog_facility = LOG_LOCAL0;
159 #else
160 static int syslog_facility = 0;
161 #endif
162 
163 static void assign_syslog_facility(int newval, void *extra);
164 static void assign_syslog_ident(const char *newval, void *extra);
165 static void assign_session_replication_role(int newval, void *extra);
166 static bool check_temp_buffers(int *newval, void **extra, GucSource source);
167 static bool check_bonjour(bool *newval, void **extra, GucSource source);
168 static bool check_ssl(bool *newval, void **extra, GucSource source);
169 static bool check_stage_log_stats(bool *newval, void **extra, GucSource source);
170 static bool check_log_stats(bool *newval, void **extra, GucSource source);
171 static bool check_canonical_path(char **newval, void **extra, GucSource source);
172 static bool check_timezone_abbreviations(char **newval, void **extra, GucSource source);
173 static void assign_timezone_abbreviations(const char *newval, void *extra);
174 static void pg_timezone_abbrev_initialize(void);
175 static const char *show_archive_command(void);
176 static void assign_tcp_keepalives_idle(int newval, void *extra);
177 static void assign_tcp_keepalives_interval(int newval, void *extra);
178 static void assign_tcp_keepalives_count(int newval, void *extra);
179 static const char *show_tcp_keepalives_idle(void);
180 static const char *show_tcp_keepalives_interval(void);
181 static const char *show_tcp_keepalives_count(void);
182 static bool check_maxconnections(int *newval, void **extra, GucSource source);
183 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
184 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
185 static bool check_autovacuum_work_mem(int *newval, void **extra, GucSource source);
186 static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source);
187 static void assign_effective_io_concurrency(int newval, void *extra);
188 static void assign_pgstat_temp_directory(const char *newval, void *extra);
189 static bool check_application_name(char **newval, void **extra, GucSource source);
190 static void assign_application_name(const char *newval, void *extra);
191 static bool check_cluster_name(char **newval, void **extra, GucSource source);
192 static const char *show_unix_socket_permissions(void);
193 static const char *show_log_file_mode(void);
194 
195 /* Private functions in guc-file.l that need to be called from guc.c */
197  bool applySettings, int elevel);
198 
199 
200 /*
201  * Options for enum values defined in this module.
202  *
203  * NOTE! Option values may not contain double quotes!
204  */
205 
206 static const struct config_enum_entry bytea_output_options[] = {
207  {"escape", BYTEA_OUTPUT_ESCAPE, false},
208  {"hex", BYTEA_OUTPUT_HEX, false},
209  {NULL, 0, false}
210 };
211 
212 /*
213  * We have different sets for client and server message level options because
214  * they sort slightly different (see "log" level)
215  */
217  {"debug", DEBUG2, true},
218  {"debug5", DEBUG5, false},
219  {"debug4", DEBUG4, false},
220  {"debug3", DEBUG3, false},
221  {"debug2", DEBUG2, false},
222  {"debug1", DEBUG1, false},
223  {"log", LOG, false},
224  {"info", INFO, true},
225  {"notice", NOTICE, false},
226  {"warning", WARNING, false},
227  {"error", ERROR, false},
228  {"fatal", FATAL, true},
229  {"panic", PANIC, true},
230  {NULL, 0, false}
231 };
232 
234  {"debug", DEBUG2, true},
235  {"debug5", DEBUG5, false},
236  {"debug4", DEBUG4, false},
237  {"debug3", DEBUG3, false},
238  {"debug2", DEBUG2, false},
239  {"debug1", DEBUG1, false},
240  {"info", INFO, false},
241  {"notice", NOTICE, false},
242  {"warning", WARNING, false},
243  {"error", ERROR, false},
244  {"log", LOG, false},
245  {"fatal", FATAL, false},
246  {"panic", PANIC, false},
247  {NULL, 0, false}
248 };
249 
250 static const struct config_enum_entry intervalstyle_options[] = {
251  {"postgres", INTSTYLE_POSTGRES, false},
252  {"postgres_verbose", INTSTYLE_POSTGRES_VERBOSE, false},
253  {"sql_standard", INTSTYLE_SQL_STANDARD, false},
254  {"iso_8601", INTSTYLE_ISO_8601, false},
255  {NULL, 0, false}
256 };
257 
259  {"terse", PGERROR_TERSE, false},
260  {"default", PGERROR_DEFAULT, false},
261  {"verbose", PGERROR_VERBOSE, false},
262  {NULL, 0, false}
263 };
264 
265 static const struct config_enum_entry log_statement_options[] = {
266  {"none", LOGSTMT_NONE, false},
267  {"ddl", LOGSTMT_DDL, false},
268  {"mod", LOGSTMT_MOD, false},
269  {"all", LOGSTMT_ALL, false},
270  {NULL, 0, false}
271 };
272 
274  {"serializable", XACT_SERIALIZABLE, false},
275  {"repeatable read", XACT_REPEATABLE_READ, false},
276  {"read committed", XACT_READ_COMMITTED, false},
277  {"read uncommitted", XACT_READ_UNCOMMITTED, false},
278  {NULL, 0}
279 };
280 
282  {"origin", SESSION_REPLICATION_ROLE_ORIGIN, false},
283  {"replica", SESSION_REPLICATION_ROLE_REPLICA, false},
284  {"local", SESSION_REPLICATION_ROLE_LOCAL, false},
285  {NULL, 0, false}
286 };
287 
289 #ifdef HAVE_SYSLOG
290  {"local0", LOG_LOCAL0, false},
291  {"local1", LOG_LOCAL1, false},
292  {"local2", LOG_LOCAL2, false},
293  {"local3", LOG_LOCAL3, false},
294  {"local4", LOG_LOCAL4, false},
295  {"local5", LOG_LOCAL5, false},
296  {"local6", LOG_LOCAL6, false},
297  {"local7", LOG_LOCAL7, false},
298 #else
299  {"none", 0, false},
300 #endif
301  {NULL, 0}
302 };
303 
304 static const struct config_enum_entry track_function_options[] = {
305  {"none", TRACK_FUNC_OFF, false},
306  {"pl", TRACK_FUNC_PL, false},
307  {"all", TRACK_FUNC_ALL, false},
308  {NULL, 0, false}
309 };
310 
311 static const struct config_enum_entry xmlbinary_options[] = {
312  {"base64", XMLBINARY_BASE64, false},
313  {"hex", XMLBINARY_HEX, false},
314  {NULL, 0, false}
315 };
316 
317 static const struct config_enum_entry xmloption_options[] = {
318  {"content", XMLOPTION_CONTENT, false},
319  {"document", XMLOPTION_DOCUMENT, false},
320  {NULL, 0, false}
321 };
322 
323 /*
324  * Although only "on", "off", and "safe_encoding" are documented, we
325  * accept all the likely variants of "on" and "off".
326  */
328  {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING, false},
329  {"on", BACKSLASH_QUOTE_ON, false},
330  {"off", BACKSLASH_QUOTE_OFF, false},
331  {"true", BACKSLASH_QUOTE_ON, true},
332  {"false", BACKSLASH_QUOTE_OFF, true},
333  {"yes", BACKSLASH_QUOTE_ON, true},
334  {"no", BACKSLASH_QUOTE_OFF, true},
335  {"1", BACKSLASH_QUOTE_ON, true},
336  {"0", BACKSLASH_QUOTE_OFF, true},
337  {NULL, 0, false}
338 };
339 
340 /*
341  * Although only "on", "off", and "partition" are documented, we
342  * accept all the likely variants of "on" and "off".
343  */
345  {"partition", CONSTRAINT_EXCLUSION_PARTITION, false},
346  {"on", CONSTRAINT_EXCLUSION_ON, false},
347  {"off", CONSTRAINT_EXCLUSION_OFF, false},
348  {"true", CONSTRAINT_EXCLUSION_ON, true},
349  {"false", CONSTRAINT_EXCLUSION_OFF, true},
350  {"yes", CONSTRAINT_EXCLUSION_ON, true},
351  {"no", CONSTRAINT_EXCLUSION_OFF, true},
352  {"1", CONSTRAINT_EXCLUSION_ON, true},
353  {"0", CONSTRAINT_EXCLUSION_OFF, true},
354  {NULL, 0, false}
355 };
356 
357 /*
358  * Although only "on", "off", "remote_apply", "remote_write", and "local" are
359  * documented, we accept all the likely variants of "on" and "off".
360  */
362  {"local", SYNCHRONOUS_COMMIT_LOCAL_FLUSH, false},
363  {"remote_write", SYNCHRONOUS_COMMIT_REMOTE_WRITE, false},
364  {"remote_apply", SYNCHRONOUS_COMMIT_REMOTE_APPLY, false},
365  {"on", SYNCHRONOUS_COMMIT_ON, false},
366  {"off", SYNCHRONOUS_COMMIT_OFF, false},
367  {"true", SYNCHRONOUS_COMMIT_ON, true},
368  {"false", SYNCHRONOUS_COMMIT_OFF, true},
369  {"yes", SYNCHRONOUS_COMMIT_ON, true},
370  {"no", SYNCHRONOUS_COMMIT_OFF, true},
371  {"1", SYNCHRONOUS_COMMIT_ON, true},
372  {"0", SYNCHRONOUS_COMMIT_OFF, true},
373  {NULL, 0, false}
374 };
375 
376 /*
377  * Although only "on", "off", "try" are documented, we accept all the likely
378  * variants of "on" and "off".
379  */
380 static const struct config_enum_entry huge_pages_options[] = {
381  {"off", HUGE_PAGES_OFF, false},
382  {"on", HUGE_PAGES_ON, false},
383  {"try", HUGE_PAGES_TRY, false},
384  {"true", HUGE_PAGES_ON, true},
385  {"false", HUGE_PAGES_OFF, true},
386  {"yes", HUGE_PAGES_ON, true},
387  {"no", HUGE_PAGES_OFF, true},
388  {"1", HUGE_PAGES_ON, true},
389  {"0", HUGE_PAGES_OFF, true},
390  {NULL, 0, false}
391 };
392 
394  {"off", FORCE_PARALLEL_OFF, false},
395  {"on", FORCE_PARALLEL_ON, false},
396  {"regress", FORCE_PARALLEL_REGRESS, false},
397  {"true", FORCE_PARALLEL_ON, true},
398  {"false", FORCE_PARALLEL_OFF, true},
399  {"yes", FORCE_PARALLEL_ON, true},
400  {"no", FORCE_PARALLEL_OFF, true},
401  {"1", FORCE_PARALLEL_ON, true},
402  {"0", FORCE_PARALLEL_OFF, true},
403  {NULL, 0, false}
404 };
405 
406 /*
407  * password_encryption used to be a boolean, so accept all the likely
408  * variants of "on" and "off", too.
409  */
411  {"plain", PASSWORD_TYPE_PLAINTEXT, false},
412  {"md5", PASSWORD_TYPE_MD5, false},
413  {"scram-sha-256", PASSWORD_TYPE_SCRAM_SHA_256, false},
414  {"off", PASSWORD_TYPE_PLAINTEXT, false},
415  {"on", PASSWORD_TYPE_MD5, false},
416  {"true", PASSWORD_TYPE_MD5, true},
417  {"false", PASSWORD_TYPE_PLAINTEXT, true},
418  {"yes", PASSWORD_TYPE_MD5, true},
419  {"no", PASSWORD_TYPE_PLAINTEXT, true},
420  {"1", PASSWORD_TYPE_MD5, true},
421  {"0", PASSWORD_TYPE_PLAINTEXT, true},
422  {NULL, 0, false}
423 };
424 
425 /*
426  * Options for enum values stored in other modules
427  */
428 extern const struct config_enum_entry wal_level_options[];
429 extern const struct config_enum_entry archive_mode_options[];
430 extern const struct config_enum_entry sync_method_options[];
432 
433 /*
434  * GUC option variables that are exported from this module
435  */
436 bool log_duration = false;
437 bool Debug_print_plan = false;
438 bool Debug_print_parse = false;
440 bool Debug_pretty_print = true;
441 
442 bool log_parser_stats = false;
443 bool log_planner_stats = false;
444 bool log_executor_stats = false;
445 bool log_statement_stats = false; /* this is sort of all three
446  * above together */
449 
452 bool default_with_oids = false;
453 
458 int log_temp_files = -1;
460 
462 
463 int num_temp_buffers = 1024;
464 
465 char *cluster_name = "";
470 
472 
474 
478 
479 /*
480  * SSL renegotiation was been removed in PostgreSQL 9.5, but we tolerate it
481  * being set to zero (meaning never renegotiate) for backward compatibility.
482  * This avoids breaking compatibility with clients that have never supported
483  * renegotiation and therefore always try to zero it.
484  */
486 
487 /*
488  * This really belongs in pg_shmem.c, but is defined here so that it doesn't
489  * need to be duplicated in all the different implementations of pg_shmem.c.
490  */
492 
493 /*
494  * These variables are all dummies that don't do anything, except in some
495  * cases provide the value for SHOW to display. The real state is elsewhere
496  * and is kept in sync by assign_hooks.
497  */
498 static char *syslog_ident_str;
500 static double phony_random_seed;
502 static char *datestyle_string;
503 static char *locale_collate;
504 static char *locale_ctype;
508 static char *timezone_string;
509 static char *log_timezone_string;
511 static char *XactIsoLevel_string;
512 static char *data_directory;
514 static int max_function_args;
515 static int max_index_keys;
517 static int block_size;
518 static int segment_size;
519 static int wal_block_size;
520 static bool data_checksums;
521 static int wal_segment_size;
522 static bool integer_datetimes;
523 static bool assert_enabled;
524 
525 /* should be static, but commands/variable.c needs to get at this */
527 
528 
529 /*
530  * Displayable names for context types (enum GucContext)
531  *
532  * Note: these strings are deliberately not localized.
533  */
534 const char *const GucContext_Names[] =
535 {
536  /* PGC_INTERNAL */ "internal",
537  /* PGC_POSTMASTER */ "postmaster",
538  /* PGC_SIGHUP */ "sighup",
539  /* PGC_SU_BACKEND */ "superuser-backend",
540  /* PGC_BACKEND */ "backend",
541  /* PGC_SUSET */ "superuser",
542  /* PGC_USERSET */ "user"
543 };
544 
545 /*
546  * Displayable names for source types (enum GucSource)
547  *
548  * Note: these strings are deliberately not localized.
549  */
550 const char *const GucSource_Names[] =
551 {
552  /* PGC_S_DEFAULT */ "default",
553  /* PGC_S_DYNAMIC_DEFAULT */ "default",
554  /* PGC_S_ENV_VAR */ "environment variable",
555  /* PGC_S_FILE */ "configuration file",
556  /* PGC_S_ARGV */ "command line",
557  /* PGC_S_GLOBAL */ "global",
558  /* PGC_S_DATABASE */ "database",
559  /* PGC_S_USER */ "user",
560  /* PGC_S_DATABASE_USER */ "database user",
561  /* PGC_S_CLIENT */ "client",
562  /* PGC_S_OVERRIDE */ "override",
563  /* PGC_S_INTERACTIVE */ "interactive",
564  /* PGC_S_TEST */ "test",
565  /* PGC_S_SESSION */ "session"
566 };
567 
568 /*
569  * Displayable names for the groupings defined in enum config_group
570  */
571 const char *const config_group_names[] =
572 {
573  /* UNGROUPED */
574  gettext_noop("Ungrouped"),
575  /* FILE_LOCATIONS */
576  gettext_noop("File Locations"),
577  /* CONN_AUTH */
578  gettext_noop("Connections and Authentication"),
579  /* CONN_AUTH_SETTINGS */
580  gettext_noop("Connections and Authentication / Connection Settings"),
581  /* CONN_AUTH_SECURITY */
582  gettext_noop("Connections and Authentication / Security and Authentication"),
583  /* RESOURCES */
584  gettext_noop("Resource Usage"),
585  /* RESOURCES_MEM */
586  gettext_noop("Resource Usage / Memory"),
587  /* RESOURCES_DISK */
588  gettext_noop("Resource Usage / Disk"),
589  /* RESOURCES_KERNEL */
590  gettext_noop("Resource Usage / Kernel Resources"),
591  /* RESOURCES_VACUUM_DELAY */
592  gettext_noop("Resource Usage / Cost-Based Vacuum Delay"),
593  /* RESOURCES_BGWRITER */
594  gettext_noop("Resource Usage / Background Writer"),
595  /* RESOURCES_ASYNCHRONOUS */
596  gettext_noop("Resource Usage / Asynchronous Behavior"),
597  /* WAL */
598  gettext_noop("Write-Ahead Log"),
599  /* WAL_SETTINGS */
600  gettext_noop("Write-Ahead Log / Settings"),
601  /* WAL_CHECKPOINTS */
602  gettext_noop("Write-Ahead Log / Checkpoints"),
603  /* WAL_ARCHIVING */
604  gettext_noop("Write-Ahead Log / Archiving"),
605  /* REPLICATION */
606  gettext_noop("Replication"),
607  /* REPLICATION_SENDING */
608  gettext_noop("Replication / Sending Servers"),
609  /* REPLICATION_MASTER */
610  gettext_noop("Replication / Master Server"),
611  /* REPLICATION_STANDBY */
612  gettext_noop("Replication / Standby Servers"),
613  /* REPLICATION_SUBSCRIBERS */
614  gettext_noop("Replication / Subscribers"),
615  /* QUERY_TUNING */
616  gettext_noop("Query Tuning"),
617  /* QUERY_TUNING_METHOD */
618  gettext_noop("Query Tuning / Planner Method Configuration"),
619  /* QUERY_TUNING_COST */
620  gettext_noop("Query Tuning / Planner Cost Constants"),
621  /* QUERY_TUNING_GEQO */
622  gettext_noop("Query Tuning / Genetic Query Optimizer"),
623  /* QUERY_TUNING_OTHER */
624  gettext_noop("Query Tuning / Other Planner Options"),
625  /* LOGGING */
626  gettext_noop("Reporting and Logging"),
627  /* LOGGING_WHERE */
628  gettext_noop("Reporting and Logging / Where to Log"),
629  /* LOGGING_WHEN */
630  gettext_noop("Reporting and Logging / When to Log"),
631  /* LOGGING_WHAT */
632  gettext_noop("Reporting and Logging / What to Log"),
633  /* PROCESS_TITLE */
634  gettext_noop("Process Title"),
635  /* STATS */
636  gettext_noop("Statistics"),
637  /* STATS_MONITORING */
638  gettext_noop("Statistics / Monitoring"),
639  /* STATS_COLLECTOR */
640  gettext_noop("Statistics / Query and Index Statistics Collector"),
641  /* AUTOVACUUM */
642  gettext_noop("Autovacuum"),
643  /* CLIENT_CONN */
644  gettext_noop("Client Connection Defaults"),
645  /* CLIENT_CONN_STATEMENT */
646  gettext_noop("Client Connection Defaults / Statement Behavior"),
647  /* CLIENT_CONN_LOCALE */
648  gettext_noop("Client Connection Defaults / Locale and Formatting"),
649  /* CLIENT_CONN_PRELOAD */
650  gettext_noop("Client Connection Defaults / Shared Library Preloading"),
651  /* CLIENT_CONN_OTHER */
652  gettext_noop("Client Connection Defaults / Other Defaults"),
653  /* LOCK_MANAGEMENT */
654  gettext_noop("Lock Management"),
655  /* COMPAT_OPTIONS */
656  gettext_noop("Version and Platform Compatibility"),
657  /* COMPAT_OPTIONS_PREVIOUS */
658  gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"),
659  /* COMPAT_OPTIONS_CLIENT */
660  gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"),
661  /* ERROR_HANDLING */
662  gettext_noop("Error Handling"),
663  /* PRESET_OPTIONS */
664  gettext_noop("Preset Options"),
665  /* CUSTOM_OPTIONS */
666  gettext_noop("Customized Options"),
667  /* DEVELOPER_OPTIONS */
668  gettext_noop("Developer Options"),
669  /* help_config wants this array to be null-terminated */
670  NULL
671 };
672 
673 /*
674  * Displayable names for GUC variable types (enum config_type)
675  *
676  * Note: these strings are deliberately not localized.
677  */
678 const char *const config_type_names[] =
679 {
680  /* PGC_BOOL */ "bool",
681  /* PGC_INT */ "integer",
682  /* PGC_REAL */ "real",
683  /* PGC_STRING */ "string",
684  /* PGC_ENUM */ "enum"
685 };
686 
687 /*
688  * Unit conversion tables.
689  *
690  * There are two tables, one for memory units, and another for time units.
691  * For each supported conversion from one unit to another, we have an entry
692  * in the table.
693  *
694  * To keep things simple, and to avoid intermediate-value overflows,
695  * conversions are never chained. There needs to be a direct conversion
696  * between all units (of the same type).
697  *
698  * The conversions from each base unit must be kept in order from greatest
699  * to smallest unit; convert_from_base_unit() relies on that. (The order of
700  * the base units does not matter.)
701  */
702 #define MAX_UNIT_LEN 3 /* length of longest recognized unit string */
703 
704 typedef struct
705 {
706  char unit[MAX_UNIT_LEN + 1]; /* unit, as a string, like "kB" or
707  * "min" */
708  int base_unit; /* GUC_UNIT_XXX */
709  int multiplier; /* If positive, multiply the value with this
710  * for unit -> base_unit conversion. If
711  * negative, divide (with the absolute value) */
713 
714 /* Ensure that the constants in the tables don't overflow or underflow */
715 #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
716 #error BLCKSZ must be between 1KB and 1MB
717 #endif
718 #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
719 #error XLOG_BLCKSZ must be between 1KB and 1MB
720 #endif
721 #if XLOG_SEG_SIZE < (1024*1024) || XLOG_SEG_SIZE > (1024*1024*1024)
722 #error XLOG_SEG_SIZE must be between 1MB and 1GB
723 #endif
724 
725 static const char *memory_units_hint = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", \"GB\", and \"TB\".");
726 
728 {
729  {"TB", GUC_UNIT_KB, 1024 * 1024 * 1024},
730  {"GB", GUC_UNIT_KB, 1024 * 1024},
731  {"MB", GUC_UNIT_KB, 1024},
732  {"kB", GUC_UNIT_KB, 1},
733 
734  {"TB", GUC_UNIT_MB, 1024 * 1024},
735  {"GB", GUC_UNIT_MB, 1024},
736  {"MB", GUC_UNIT_MB, 1},
737  {"kB", GUC_UNIT_MB, -1024},
738 
739  {"TB", GUC_UNIT_BLOCKS, (1024 * 1024 * 1024) / (BLCKSZ / 1024)},
740  {"GB", GUC_UNIT_BLOCKS, (1024 * 1024) / (BLCKSZ / 1024)},
741  {"MB", GUC_UNIT_BLOCKS, 1024 / (BLCKSZ / 1024)},
742  {"kB", GUC_UNIT_BLOCKS, -(BLCKSZ / 1024)},
743 
744  {"TB", GUC_UNIT_XBLOCKS, (1024 * 1024 * 1024) / (XLOG_BLCKSZ / 1024)},
745  {"GB", GUC_UNIT_XBLOCKS, (1024 * 1024) / (XLOG_BLCKSZ / 1024)},
746  {"MB", GUC_UNIT_XBLOCKS, 1024 / (XLOG_BLCKSZ / 1024)},
747  {"kB", GUC_UNIT_XBLOCKS, -(XLOG_BLCKSZ / 1024)},
748 
749  {""} /* end of table marker */
750 };
751 
752 static const char *time_units_hint = gettext_noop("Valid units for this parameter are \"ms\", \"s\", \"min\", \"h\", and \"d\".");
753 
755 {
756  {"d", GUC_UNIT_MS, 1000 * 60 * 60 * 24},
757  {"h", GUC_UNIT_MS, 1000 * 60 * 60},
758  {"min", GUC_UNIT_MS, 1000 * 60},
759  {"s", GUC_UNIT_MS, 1000},
760  {"ms", GUC_UNIT_MS, 1},
761 
762  {"d", GUC_UNIT_S, 60 * 60 * 24},
763  {"h", GUC_UNIT_S, 60 * 60},
764  {"min", GUC_UNIT_S, 60},
765  {"s", GUC_UNIT_S, 1},
766  {"ms", GUC_UNIT_S, -1000},
767 
768  {"d", GUC_UNIT_MIN, 60 * 24},
769  {"h", GUC_UNIT_MIN, 60},
770  {"min", GUC_UNIT_MIN, 1},
771  {"s", GUC_UNIT_MIN, -60},
772  {"ms", GUC_UNIT_MIN, -1000 * 60},
773 
774  {""} /* end of table marker */
775 };
776 
777 /*
778  * Contents of GUC tables
779  *
780  * See src/backend/utils/misc/README for design notes.
781  *
782  * TO ADD AN OPTION:
783  *
784  * 1. Declare a global variable of type bool, int, double, or char*
785  * and make use of it.
786  *
787  * 2. Decide at what times it's safe to set the option. See guc.h for
788  * details.
789  *
790  * 3. Decide on a name, a default value, upper and lower bounds (if
791  * applicable), etc.
792  *
793  * 4. Add a record below.
794  *
795  * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
796  * appropriate.
797  *
798  * 6. Don't forget to document the option (at least in config.sgml).
799  *
800  * 7. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
801  * it is not single quoted at dump time.
802  */
803 
804 
805 /******** option records follow ********/
806 
808 {
809  {
810  {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
811  gettext_noop("Enables the planner's use of sequential-scan plans."),
812  NULL
813  },
815  true,
816  NULL, NULL, NULL
817  },
818  {
819  {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
820  gettext_noop("Enables the planner's use of index-scan plans."),
821  NULL
822  },
824  true,
825  NULL, NULL, NULL
826  },
827  {
828  {"enable_indexonlyscan", PGC_USERSET, QUERY_TUNING_METHOD,
829  gettext_noop("Enables the planner's use of index-only-scan plans."),
830  NULL
831  },
833  true,
834  NULL, NULL, NULL
835  },
836  {
837  {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
838  gettext_noop("Enables the planner's use of bitmap-scan plans."),
839  NULL
840  },
842  true,
843  NULL, NULL, NULL
844  },
845  {
846  {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
847  gettext_noop("Enables the planner's use of TID scan plans."),
848  NULL
849  },
851  true,
852  NULL, NULL, NULL
853  },
854  {
855  {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
856  gettext_noop("Enables the planner's use of explicit sort steps."),
857  NULL
858  },
859  &enable_sort,
860  true,
861  NULL, NULL, NULL
862  },
863  {
864  {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
865  gettext_noop("Enables the planner's use of hashed aggregation plans."),
866  NULL
867  },
869  true,
870  NULL, NULL, NULL
871  },
872  {
873  {"enable_material", PGC_USERSET, QUERY_TUNING_METHOD,
874  gettext_noop("Enables the planner's use of materialization."),
875  NULL
876  },
878  true,
879  NULL, NULL, NULL
880  },
881  {
882  {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
883  gettext_noop("Enables the planner's use of nested-loop join plans."),
884  NULL
885  },
887  true,
888  NULL, NULL, NULL
889  },
890  {
891  {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
892  gettext_noop("Enables the planner's use of merge join plans."),
893  NULL
894  },
896  true,
897  NULL, NULL, NULL
898  },
899  {
900  {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
901  gettext_noop("Enables the planner's use of hash join plans."),
902  NULL
903  },
905  true,
906  NULL, NULL, NULL
907  },
908  {
909  {"enable_gathermerge", PGC_USERSET, QUERY_TUNING_METHOD,
910  gettext_noop("Enables the planner's use of gather merge plans."),
911  NULL
912  },
914  true,
915  NULL, NULL, NULL
916  },
917 
918  {
919  {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
920  gettext_noop("Enables genetic query optimization."),
921  gettext_noop("This algorithm attempts to do planning without "
922  "exhaustive searching.")
923  },
924  &enable_geqo,
925  true,
926  NULL, NULL, NULL
927  },
928  {
929  /* Not for general use --- used by SET SESSION AUTHORIZATION */
930  {"is_superuser", PGC_INTERNAL, UNGROUPED,
931  gettext_noop("Shows whether the current user is a superuser."),
932  NULL,
934  },
936  false,
937  NULL, NULL, NULL
938  },
939  {
940  {"bonjour", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
941  gettext_noop("Enables advertising the server via Bonjour."),
942  NULL
943  },
945  false,
946  check_bonjour, NULL, NULL
947  },
948  {
949  {"track_commit_timestamp", PGC_POSTMASTER, REPLICATION,
950  gettext_noop("Collects transaction commit time."),
951  NULL
952  },
954  false,
955  NULL, NULL, NULL
956  },
957  {
959  gettext_noop("Enables SSL connections."),
960  NULL
961  },
962  &EnableSSL,
963  false,
964  check_ssl, NULL, NULL
965  },
966  {
967  {"ssl_prefer_server_ciphers", PGC_SIGHUP, CONN_AUTH_SECURITY,
968  gettext_noop("Give priority to server ciphersuite order."),
969  NULL
970  },
972  true,
973  NULL, NULL, NULL
974  },
975  {
976  {"fsync", PGC_SIGHUP, WAL_SETTINGS,
977  gettext_noop("Forces synchronization of updates to disk."),
978  gettext_noop("The server will use the fsync() system call in several places to make "
979  "sure that updates are physically written to disk. This insures "
980  "that a database cluster will recover to a consistent state after "
981  "an operating system or hardware crash.")
982  },
983  &enableFsync,
984  true,
985  NULL, NULL, NULL
986  },
987  {
988  {"ignore_checksum_failure", PGC_SUSET, DEVELOPER_OPTIONS,
989  gettext_noop("Continues processing after a checksum failure."),
990  gettext_noop("Detection of a checksum failure normally causes PostgreSQL to "
991  "report an error, aborting the current transaction. Setting "
992  "ignore_checksum_failure to true causes the system to ignore the failure "
993  "(but still report a warning), and continue processing. This "
994  "behavior could cause crashes or other serious problems. Only "
995  "has an effect if checksums are enabled."),
997  },
999  false,
1000  NULL, NULL, NULL
1001  },
1002  {
1003  {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
1004  gettext_noop("Continues processing past damaged page headers."),
1005  gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
1006  "report an error, aborting the current transaction. Setting "
1007  "zero_damaged_pages to true causes the system to instead report a "
1008  "warning, zero out the damaged page, and continue processing. This "
1009  "behavior will destroy data, namely all the rows on the damaged page."),
1011  },
1013  false,
1014  NULL, NULL, NULL
1015  },
1016  {
1017  {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
1018  gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
1019  gettext_noop("A page write in process during an operating system crash might be "
1020  "only partially written to disk. During recovery, the row changes "
1021  "stored in WAL are not enough to recover. This option writes "
1022  "pages when first modified after a checkpoint to WAL so full recovery "
1023  "is possible.")
1024  },
1025  &fullPageWrites,
1026  true,
1027  NULL, NULL, NULL
1028  },
1029 
1030  {
1031  {"wal_log_hints", PGC_POSTMASTER, WAL_SETTINGS,
1032  gettext_noop("Writes full pages to WAL when first modified after a checkpoint, even for a non-critical modifications."),
1033  NULL
1034  },
1035  &wal_log_hints,
1036  false,
1037  NULL, NULL, NULL
1038  },
1039 
1040  {
1041  {"wal_compression", PGC_SUSET, WAL_SETTINGS,
1042  gettext_noop("Compresses full-page writes written in WAL file."),
1043  NULL
1044  },
1045  &wal_compression,
1046  false,
1047  NULL, NULL, NULL
1048  },
1049 
1050  {
1051  {"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
1052  gettext_noop("Logs each checkpoint."),
1053  NULL
1054  },
1055  &log_checkpoints,
1056  false,
1057  NULL, NULL, NULL
1058  },
1059  {
1060  {"log_connections", PGC_SU_BACKEND, LOGGING_WHAT,
1061  gettext_noop("Logs each successful connection."),
1062  NULL
1063  },
1064  &Log_connections,
1065  false,
1066  NULL, NULL, NULL
1067  },
1068  {
1069  {"log_disconnections", PGC_SU_BACKEND, LOGGING_WHAT,
1070  gettext_noop("Logs end of a session, including duration."),
1071  NULL
1072  },
1074  false,
1075  NULL, NULL, NULL
1076  },
1077  {
1078  {"log_replication_commands", PGC_SUSET, LOGGING_WHAT,
1079  gettext_noop("Logs each replication command."),
1080  NULL
1081  },
1083  false,
1084  NULL, NULL, NULL
1085  },
1086  {
1087  {"debug_assertions", PGC_INTERNAL, PRESET_OPTIONS,
1088  gettext_noop("Shows whether the running server has assertion checks enabled."),
1089  NULL,
1091  },
1092  &assert_enabled,
1093 #ifdef USE_ASSERT_CHECKING
1094  true,
1095 #else
1096  false,
1097 #endif
1098  NULL, NULL, NULL
1099  },
1100 
1101  {
1102  {"exit_on_error", PGC_USERSET, ERROR_HANDLING_OPTIONS,
1103  gettext_noop("Terminate session on any error."),
1104  NULL
1105  },
1106  &ExitOnAnyError,
1107  false,
1108  NULL, NULL, NULL
1109  },
1110  {
1111  {"restart_after_crash", PGC_SIGHUP, ERROR_HANDLING_OPTIONS,
1112  gettext_noop("Reinitialize server after backend crash."),
1113  NULL
1114  },
1116  true,
1117  NULL, NULL, NULL
1118  },
1119 
1120  {
1121  {"log_duration", PGC_SUSET, LOGGING_WHAT,
1122  gettext_noop("Logs the duration of each completed SQL statement."),
1123  NULL
1124  },
1125  &log_duration,
1126  false,
1127  NULL, NULL, NULL
1128  },
1129  {
1130  {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
1131  gettext_noop("Logs each query's parse tree."),
1132  NULL
1133  },
1135  false,
1136  NULL, NULL, NULL
1137  },
1138  {
1139  {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
1140  gettext_noop("Logs each query's rewritten parse tree."),
1141  NULL
1142  },
1144  false,
1145  NULL, NULL, NULL
1146  },
1147  {
1148  {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
1149  gettext_noop("Logs each query's execution plan."),
1150  NULL
1151  },
1153  false,
1154  NULL, NULL, NULL
1155  },
1156  {
1157  {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
1158  gettext_noop("Indents parse and plan tree displays."),
1159  NULL
1160  },
1162  true,
1163  NULL, NULL, NULL
1164  },
1165  {
1166  {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
1167  gettext_noop("Writes parser performance statistics to the server log."),
1168  NULL
1169  },
1171  false,
1173  },
1174  {
1175  {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
1176  gettext_noop("Writes planner performance statistics to the server log."),
1177  NULL
1178  },
1180  false,
1182  },
1183  {
1184  {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
1185  gettext_noop("Writes executor performance statistics to the server log."),
1186  NULL
1187  },
1189  false,
1191  },
1192  {
1193  {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
1194  gettext_noop("Writes cumulative performance statistics to the server log."),
1195  NULL
1196  },
1198  false,
1199  check_log_stats, NULL, NULL
1200  },
1201 #ifdef BTREE_BUILD_STATS
1202  {
1203  {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
1204  gettext_noop("Logs system resource usage statistics (memory and CPU) on various B-tree operations."),
1205  NULL,
1207  },
1209  false,
1210  NULL, NULL, NULL
1211  },
1212 #endif
1213 
1214  {
1215  {"track_activities", PGC_SUSET, STATS_COLLECTOR,
1216  gettext_noop("Collects information about executing commands."),
1217  gettext_noop("Enables the collection of information on the currently "
1218  "executing command of each session, along with "
1219  "the time at which that command began execution.")
1220  },
1222  true,
1223  NULL, NULL, NULL
1224  },
1225  {
1226  {"track_counts", PGC_SUSET, STATS_COLLECTOR,
1227  gettext_noop("Collects statistics on database activity."),
1228  NULL
1229  },
1231  true,
1232  NULL, NULL, NULL
1233  },
1234  {
1235  {"track_io_timing", PGC_SUSET, STATS_COLLECTOR,
1236  gettext_noop("Collects timing statistics for database I/O activity."),
1237  NULL
1238  },
1239  &track_io_timing,
1240  false,
1241  NULL, NULL, NULL
1242  },
1243 
1244  {
1245  {"update_process_title", PGC_SUSET, PROCESS_TITLE,
1246  gettext_noop("Updates the process title to show the active SQL command."),
1247  gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.")
1248  },
1250 #ifdef WIN32
1251  false,
1252 #else
1253  true,
1254 #endif
1255  NULL, NULL, NULL
1256  },
1257 
1258  {
1259  {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
1260  gettext_noop("Starts the autovacuum subprocess."),
1261  NULL
1262  },
1264  true,
1265  NULL, NULL, NULL
1266  },
1267 
1268  {
1269  {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
1270  gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
1271  NULL,
1273  },
1274  &Trace_notify,
1275  false,
1276  NULL, NULL, NULL
1277  },
1278 
1279 #ifdef LOCK_DEBUG
1280  {
1281  {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
1282  gettext_noop("Emits information about lock usage."),
1283  NULL,
1285  },
1286  &Trace_locks,
1287  false,
1288  NULL, NULL, NULL
1289  },
1290  {
1291  {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1292  gettext_noop("Emits information about user lock usage."),
1293  NULL,
1295  },
1296  &Trace_userlocks,
1297  false,
1298  NULL, NULL, NULL
1299  },
1300  {
1301  {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1302  gettext_noop("Emits information about lightweight lock usage."),
1303  NULL,
1305  },
1306  &Trace_lwlocks,
1307  false,
1308  NULL, NULL, NULL
1309  },
1310  {
1311  {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1312  gettext_noop("Dumps information about all current locks when a deadlock timeout occurs."),
1313  NULL,
1315  },
1316  &Debug_deadlocks,
1317  false,
1318  NULL, NULL, NULL
1319  },
1320 #endif
1321 
1322  {
1323  {"log_lock_waits", PGC_SUSET, LOGGING_WHAT,
1324  gettext_noop("Logs long lock waits."),
1325  NULL
1326  },
1327  &log_lock_waits,
1328  false,
1329  NULL, NULL, NULL
1330  },
1331 
1332  {
1333  {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
1334  gettext_noop("Logs the host name in the connection logs."),
1335  gettext_noop("By default, connection logs only show the IP address "
1336  "of the connecting host. If you want them to show the host name you "
1337  "can turn this on, but depending on your host name resolution "
1338  "setup it might impose a non-negligible performance penalty.")
1339  },
1340  &log_hostname,
1341  false,
1342  NULL, NULL, NULL
1343  },
1344  {
1345  {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
1346  gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
1347  gettext_noop("When turned on, expressions of the form expr = NULL "
1348  "(or NULL = expr) are treated as expr IS NULL, that is, they "
1349  "return true if expr evaluates to the null value, and false "
1350  "otherwise. The correct behavior of expr = NULL is to always "
1351  "return null (unknown).")
1352  },
1354  false,
1355  NULL, NULL, NULL
1356  },
1357  {
1358  {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
1359  gettext_noop("Enables per-database user names."),
1360  NULL
1361  },
1363  false,
1364  NULL, NULL, NULL
1365  },
1366  {
1367  {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
1368  gettext_noop("Sets the default read-only status of new transactions."),
1369  NULL
1370  },
1372  false,
1373  NULL, NULL, NULL
1374  },
1375  {
1376  {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
1377  gettext_noop("Sets the current transaction's read-only status."),
1378  NULL,
1380  },
1381  &XactReadOnly,
1382  false,
1384  },
1385  {
1386  {"default_transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
1387  gettext_noop("Sets the default deferrable status of new transactions."),
1388  NULL
1389  },
1391  false,
1392  NULL, NULL, NULL
1393  },
1394  {
1395  {"transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
1396  gettext_noop("Whether to defer a read-only serializable transaction until it can be executed with no possible serialization failures."),
1397  NULL,
1399  },
1400  &XactDeferrable,
1401  false,
1403  },
1404  {
1405  {"row_security", PGC_USERSET, CONN_AUTH_SECURITY,
1406  gettext_noop("Enable row security."),
1407  gettext_noop("When enabled, row security will be applied to all users.")
1408  },
1409  &row_security,
1410  true,
1411  NULL, NULL, NULL
1412  },
1413  {
1414  {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
1415  gettext_noop("Check function bodies during CREATE FUNCTION."),
1416  NULL
1417  },
1419  true,
1420  NULL, NULL, NULL
1421  },
1422  {
1423  {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1424  gettext_noop("Enable input of NULL elements in arrays."),
1425  gettext_noop("When turned on, unquoted NULL in an array input "
1426  "value means a null value; "
1427  "otherwise it is taken literally.")
1428  },
1429  &Array_nulls,
1430  true,
1431  NULL, NULL, NULL
1432  },
1433  {
1434  {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1435  gettext_noop("Create new tables with OIDs by default."),
1436  NULL
1437  },
1439  false,
1440  NULL, NULL, NULL
1441  },
1442  {
1443  {"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
1444  gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
1445  NULL
1446  },
1448  false,
1449  NULL, NULL, NULL
1450  },
1451  {
1452  {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
1453  gettext_noop("Truncate existing log files of same name during log rotation."),
1454  NULL
1455  },
1457  false,
1458  NULL, NULL, NULL
1459  },
1460 
1461 #ifdef TRACE_SORT
1462  {
1463  {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
1464  gettext_noop("Emit information about resource usage in sorting."),
1465  NULL,
1467  },
1468  &trace_sort,
1469  false,
1470  NULL, NULL, NULL
1471  },
1472 #endif
1473 
1474 #ifdef TRACE_SYNCSCAN
1475  /* this is undocumented because not exposed in a standard build */
1476  {
1477  {"trace_syncscan", PGC_USERSET, DEVELOPER_OPTIONS,
1478  gettext_noop("Generate debugging output for synchronized scanning."),
1479  NULL,
1481  },
1482  &trace_syncscan,
1483  false,
1484  NULL, NULL, NULL
1485  },
1486 #endif
1487 
1488 #ifdef DEBUG_BOUNDED_SORT
1489  /* this is undocumented because not exposed in a standard build */
1490  {
1491  {
1492  "optimize_bounded_sort", PGC_USERSET, QUERY_TUNING_METHOD,
1493  gettext_noop("Enable bounded sorting using heap sort."),
1494  NULL,
1496  },
1497  &optimize_bounded_sort,
1498  true,
1499  NULL, NULL, NULL
1500  },
1501 #endif
1502 
1503 #ifdef WAL_DEBUG
1504  {
1505  {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
1506  gettext_noop("Emit WAL-related debugging output."),
1507  NULL,
1509  },
1510  &XLOG_DEBUG,
1511  false,
1512  NULL, NULL, NULL
1513  },
1514 #endif
1515 
1516  {
1517  {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
1518  gettext_noop("Datetimes are integer based."),
1519  NULL,
1521  },
1523  true,
1524  NULL, NULL, NULL
1525  },
1526 
1527  {
1528  {"krb_caseins_users", PGC_SIGHUP, CONN_AUTH_SECURITY,
1529  gettext_noop("Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive."),
1530  NULL
1531  },
1533  false,
1534  NULL, NULL, NULL
1535  },
1536 
1537  {
1538  {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1539  gettext_noop("Warn about backslash escapes in ordinary string literals."),
1540  NULL
1541  },
1543  true,
1544  NULL, NULL, NULL
1545  },
1546 
1547  {
1548  {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1549  gettext_noop("Causes '...' strings to treat backslashes literally."),
1550  NULL,
1551  GUC_REPORT
1552  },
1554  true,
1555  NULL, NULL, NULL
1556  },
1557 
1558  {
1559  {"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1560  gettext_noop("Enable synchronized sequential scans."),
1561  NULL
1562  },
1564  true,
1565  NULL, NULL, NULL
1566  },
1567 
1568  {
1569  {"hot_standby", PGC_POSTMASTER, REPLICATION_STANDBY,
1570  gettext_noop("Allows connections and queries during recovery."),
1571  NULL
1572  },
1574  false,
1575  NULL, NULL, NULL
1576  },
1577 
1578  {
1579  {"hot_standby_feedback", PGC_SIGHUP, REPLICATION_STANDBY,
1580  gettext_noop("Allows feedback from a hot standby to the primary that will avoid query conflicts."),
1581  NULL
1582  },
1584  false,
1585  NULL, NULL, NULL
1586  },
1587 
1588  {
1589  {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
1590  gettext_noop("Allows modifications of the structure of system tables."),
1591  NULL,
1593  },
1595  false,
1596  NULL, NULL, NULL
1597  },
1598 
1599  {
1600  {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
1601  gettext_noop("Disables reading from system indexes."),
1602  gettext_noop("It does not prevent updating the indexes, so it is safe "
1603  "to use. The worst consequence is slowness."),
1605  },
1607  false,
1608  NULL, NULL, NULL
1609  },
1610 
1611  {
1612  {"lo_compat_privileges", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
1613  gettext_noop("Enables backward compatibility mode for privilege checks on large objects."),
1614  gettext_noop("Skips privilege checks when reading or modifying large objects, "
1615  "for compatibility with PostgreSQL releases prior to 9.0.")
1616  },
1618  false,
1619  NULL, NULL, NULL
1620  },
1621 
1622  {
1623  {"operator_precedence_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1624  gettext_noop("Emit a warning for constructs that changed meaning since PostgreSQL 9.4."),
1625  NULL,
1626  },
1628  false,
1629  NULL, NULL, NULL
1630  },
1631 
1632  {
1633  {"quote_all_identifiers", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1634  gettext_noop("When generating SQL fragments, quote all identifiers."),
1635  NULL,
1636  },
1638  false,
1639  NULL, NULL, NULL
1640  },
1641 
1642  {
1643  {"data_checksums", PGC_INTERNAL, PRESET_OPTIONS,
1644  gettext_noop("Shows whether data checksums are turned on for this cluster."),
1645  NULL,
1647  },
1648  &data_checksums,
1649  false,
1650  NULL, NULL, NULL
1651  },
1652 
1653  {
1654  {"syslog_sequence_numbers", PGC_SIGHUP, LOGGING_WHERE,
1655  gettext_noop("Add sequence number to syslog messages to avoid duplicate suppression."),
1656  NULL
1657  },
1659  true,
1660  NULL, NULL, NULL
1661  },
1662 
1663  {
1664  {"syslog_split_messages", PGC_SIGHUP, LOGGING_WHERE,
1665  gettext_noop("Split messages sent to syslog by lines and to fit into 1024 bytes."),
1666  NULL
1667  },
1669  true,
1670  NULL, NULL, NULL
1671  },
1672 
1673  /* End-of-list marker */
1674  {
1675  {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
1676  }
1677 };
1678 
1679 
1681 {
1682  {
1683  {"archive_timeout", PGC_SIGHUP, WAL_ARCHIVING,
1684  gettext_noop("Forces a switch to the next WAL file if a "
1685  "new file has not been started within N seconds."),
1686  NULL,
1687  GUC_UNIT_S
1688  },
1690  0, 0, INT_MAX / 2,
1691  NULL, NULL, NULL
1692  },
1693  {
1694  {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1695  gettext_noop("Waits N seconds on connection startup after authentication."),
1696  gettext_noop("This allows attaching a debugger to the process."),
1698  },
1699  &PostAuthDelay,
1700  0, 0, INT_MAX / 1000000,
1701  NULL, NULL, NULL
1702  },
1703  {
1704  {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1705  gettext_noop("Sets the default statistics target."),
1706  gettext_noop("This applies to table columns that have not had a "
1707  "column-specific target set via ALTER TABLE SET STATISTICS.")
1708  },
1710  100, 1, 10000,
1711  NULL, NULL, NULL
1712  },
1713  {
1714  {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1715  gettext_noop("Sets the FROM-list size beyond which subqueries "
1716  "are not collapsed."),
1717  gettext_noop("The planner will merge subqueries into upper "
1718  "queries if the resulting FROM list would have no more than "
1719  "this many items.")
1720  },
1722  8, 1, INT_MAX,
1723  NULL, NULL, NULL
1724  },
1725  {
1726  {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1727  gettext_noop("Sets the FROM-list size beyond which JOIN "
1728  "constructs are not flattened."),
1729  gettext_noop("The planner will flatten explicit JOIN "
1730  "constructs into lists of FROM items whenever a "
1731  "list of no more than this many items would result.")
1732  },
1734  8, 1, INT_MAX,
1735  NULL, NULL, NULL
1736  },
1737  {
1738  {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1739  gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1740  NULL
1741  },
1742  &geqo_threshold,
1743  12, 2, INT_MAX,
1744  NULL, NULL, NULL
1745  },
1746  {
1747  {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1748  gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1749  NULL
1750  },
1751  &Geqo_effort,
1753  NULL, NULL, NULL
1754  },
1755  {
1756  {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1757  gettext_noop("GEQO: number of individuals in the population."),
1758  gettext_noop("Zero selects a suitable default value.")
1759  },
1760  &Geqo_pool_size,
1761  0, 0, INT_MAX,
1762  NULL, NULL, NULL
1763  },
1764  {
1765  {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1766  gettext_noop("GEQO: number of iterations of the algorithm."),
1767  gettext_noop("Zero selects a suitable default value.")
1768  },
1770  0, 0, INT_MAX,
1771  NULL, NULL, NULL
1772  },
1773 
1774  {
1775  /* This is PGC_SUSET to prevent hiding from log_lock_waits. */
1776  {"deadlock_timeout", PGC_SUSET, LOCK_MANAGEMENT,
1777  gettext_noop("Sets the time to wait on a lock before checking for deadlock."),
1778  NULL,
1779  GUC_UNIT_MS
1780  },
1781  &DeadlockTimeout,
1782  1000, 1, INT_MAX,
1783  NULL, NULL, NULL
1784  },
1785 
1786  {
1787  {"max_standby_archive_delay", PGC_SIGHUP, REPLICATION_STANDBY,
1788  gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data."),
1789  NULL,
1790  GUC_UNIT_MS
1791  },
1793  30 * 1000, -1, INT_MAX,
1794  NULL, NULL, NULL
1795  },
1796 
1797  {
1798  {"max_standby_streaming_delay", PGC_SIGHUP, REPLICATION_STANDBY,
1799  gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data."),
1800  NULL,
1801  GUC_UNIT_MS
1802  },
1804  30 * 1000, -1, INT_MAX,
1805  NULL, NULL, NULL
1806  },
1807 
1808  {
1809  {"wal_receiver_status_interval", PGC_SIGHUP, REPLICATION_STANDBY,
1810  gettext_noop("Sets the maximum interval between WAL receiver status reports to the primary."),
1811  NULL,
1812  GUC_UNIT_S
1813  },
1815  10, 0, INT_MAX / 1000,
1816  NULL, NULL, NULL
1817  },
1818 
1819  {
1820  {"wal_receiver_timeout", PGC_SIGHUP, REPLICATION_STANDBY,
1821  gettext_noop("Sets the maximum wait time to receive data from the primary."),
1822  NULL,
1823  GUC_UNIT_MS
1824  },
1826  60 * 1000, 0, INT_MAX,
1827  NULL, NULL, NULL
1828  },
1829 
1830  {
1831  {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1832  gettext_noop("Sets the maximum number of concurrent connections."),
1833  NULL
1834  },
1835  &MaxConnections,
1836  100, 1, MAX_BACKENDS,
1837  check_maxconnections, NULL, NULL
1838  },
1839 
1840  {
1841  {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1842  gettext_noop("Sets the number of connection slots reserved for superusers."),
1843  NULL
1844  },
1846  3, 0, MAX_BACKENDS,
1847  NULL, NULL, NULL
1848  },
1849 
1850  /*
1851  * We sometimes multiply the number of shared buffers by two without
1852  * checking for overflow, so we mustn't allow more than INT_MAX / 2.
1853  */
1854  {
1855  {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1856  gettext_noop("Sets the number of shared memory buffers used by the server."),
1857  NULL,
1859  },
1860  &NBuffers,
1861  1024, 16, INT_MAX / 2,
1862  NULL, NULL, NULL
1863  },
1864 
1865  {
1866  {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1867  gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1868  NULL,
1870  },
1872  1024, 100, INT_MAX / 2,
1873  check_temp_buffers, NULL, NULL
1874  },
1875 
1876  {
1878  gettext_noop("Sets the TCP port the server listens on."),
1879  NULL
1880  },
1881  &PostPortNumber,
1882  DEF_PGPORT, 1, 65535,
1883  NULL, NULL, NULL
1884  },
1885 
1886  {
1887  {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1888  gettext_noop("Sets the access permissions of the Unix-domain socket."),
1889  gettext_noop("Unix-domain sockets use the usual Unix file system "
1890  "permission set. The parameter value is expected "
1891  "to be a numeric mode specification in the form "
1892  "accepted by the chmod and umask system calls. "
1893  "(To use the customary octal format the number must "
1894  "start with a 0 (zero).)")
1895  },
1897  0777, 0000, 0777,
1899  },
1900 
1901  {
1902  {"log_file_mode", PGC_SIGHUP, LOGGING_WHERE,
1903  gettext_noop("Sets the file permissions for log files."),
1904  gettext_noop("The parameter value is expected "
1905  "to be a numeric mode specification in the form "
1906  "accepted by the chmod and umask system calls. "
1907  "(To use the customary octal format the number must "
1908  "start with a 0 (zero).)")
1909  },
1910  &Log_file_mode,
1911  0600, 0000, 0777,
1913  },
1914 
1915  {
1916  {"work_mem", PGC_USERSET, RESOURCES_MEM,
1917  gettext_noop("Sets the maximum memory to be used for query workspaces."),
1918  gettext_noop("This much memory can be used by each internal "
1919  "sort operation and hash table before switching to "
1920  "temporary disk files."),
1921  GUC_UNIT_KB
1922  },
1923  &work_mem,
1924  4096, 64, MAX_KILOBYTES,
1925  NULL, NULL, NULL
1926  },
1927 
1928  {
1929  {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1930  gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1931  gettext_noop("This includes operations such as VACUUM and CREATE INDEX."),
1932  GUC_UNIT_KB
1933  },
1935  65536, 1024, MAX_KILOBYTES,
1936  NULL, NULL, NULL
1937  },
1938 
1939  {
1940  {"replacement_sort_tuples", PGC_USERSET, RESOURCES_MEM,
1941  gettext_noop("Sets the maximum number of tuples to be sorted using replacement selection."),
1942  gettext_noop("When more tuples than this are present, quicksort will be used.")
1943  },
1945  150000, 0, INT_MAX,
1946  NULL, NULL, NULL
1947  },
1948 
1949  /*
1950  * We use the hopefully-safely-small value of 100kB as the compiled-in
1951  * default for max_stack_depth. InitializeGUCOptions will increase it if
1952  * possible, depending on the actual platform-specific stack limit.
1953  */
1954  {
1955  {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1956  gettext_noop("Sets the maximum stack depth, in kilobytes."),
1957  NULL,
1958  GUC_UNIT_KB
1959  },
1960  &max_stack_depth,
1961  100, 100, MAX_KILOBYTES,
1963  },
1964 
1965  {
1966  {"temp_file_limit", PGC_SUSET, RESOURCES_DISK,
1967  gettext_noop("Limits the total size of all temporary files used by each process."),
1968  gettext_noop("-1 means no limit."),
1969  GUC_UNIT_KB
1970  },
1971  &temp_file_limit,
1972  -1, -1, INT_MAX,
1973  NULL, NULL, NULL
1974  },
1975 
1976  {
1977  {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
1978  gettext_noop("Vacuum cost for a page found in the buffer cache."),
1979  NULL
1980  },
1982  1, 0, 10000,
1983  NULL, NULL, NULL
1984  },
1985 
1986  {
1987  {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES_VACUUM_DELAY,
1988  gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1989  NULL
1990  },
1992  10, 0, 10000,
1993  NULL, NULL, NULL
1994  },
1995 
1996  {
1997  {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES_VACUUM_DELAY,
1998  gettext_noop("Vacuum cost for a page dirtied by vacuum."),
1999  NULL
2000  },
2002  20, 0, 10000,
2003  NULL, NULL, NULL
2004  },
2005 
2006  {
2007  {"vacuum_cost_limit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
2008  gettext_noop("Vacuum cost amount available before napping."),
2009  NULL
2010  },
2011  &VacuumCostLimit,
2012  200, 1, 10000,
2013  NULL, NULL, NULL
2014  },
2015 
2016  {
2017  {"vacuum_cost_delay", PGC_USERSET, RESOURCES_VACUUM_DELAY,
2018  gettext_noop("Vacuum cost delay in milliseconds."),
2019  NULL,
2020  GUC_UNIT_MS
2021  },
2022  &VacuumCostDelay,
2023  0, 0, 100,
2024  NULL, NULL, NULL
2025  },
2026 
2027  {
2028  {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
2029  gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
2030  NULL,
2031  GUC_UNIT_MS
2032  },
2034  20, -1, 100,
2035  NULL, NULL, NULL
2036  },
2037 
2038  {
2039  {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
2040  gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
2041  NULL
2042  },
2044  -1, -1, 10000,
2045  NULL, NULL, NULL
2046  },
2047 
2048  {
2049  {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
2050  gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
2051  NULL
2052  },
2054  1000, 25, INT_MAX,
2055  NULL, NULL, NULL
2056  },
2057 
2058  /*
2059  * See also CheckRequiredParameterValues() if this parameter changes
2060  */
2061  {
2062  {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES_MEM,
2063  gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
2064  NULL
2065  },
2067  0, 0, MAX_BACKENDS,
2068  NULL, NULL, NULL
2069  },
2070 
2071 #ifdef LOCK_DEBUG
2072  {
2073  {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
2074  gettext_noop("Sets the minimum OID of tables for tracking locks."),
2075  gettext_noop("Is used to avoid output on system tables."),
2077  },
2078  &Trace_lock_oidmin,
2079  FirstNormalObjectId, 0, INT_MAX,
2080  NULL, NULL, NULL
2081  },
2082  {
2083  {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
2084  gettext_noop("Sets the OID of the table with unconditionally lock tracing."),
2085  NULL,
2087  },
2088  &Trace_lock_table,
2089  0, 0, INT_MAX,
2090  NULL, NULL, NULL
2091  },
2092 #endif
2093 
2094  {
2095  {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2096  gettext_noop("Sets the maximum allowed duration of any statement."),
2097  gettext_noop("A value of 0 turns off the timeout."),
2098  GUC_UNIT_MS
2099  },
2101  0, 0, INT_MAX,
2102  NULL, NULL, NULL
2103  },
2104 
2105  {
2106  {"lock_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2107  gettext_noop("Sets the maximum allowed duration of any wait for a lock."),
2108  gettext_noop("A value of 0 turns off the timeout."),
2109  GUC_UNIT_MS
2110  },
2111  &LockTimeout,
2112  0, 0, INT_MAX,
2113  NULL, NULL, NULL
2114  },
2115 
2116  {
2117  {"idle_in_transaction_session_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2118  gettext_noop("Sets the maximum allowed duration of any idling transaction."),
2119  gettext_noop("A value of 0 turns off the timeout."),
2120  GUC_UNIT_MS
2121  },
2123  0, 0, INT_MAX,
2124  NULL, NULL, NULL
2125  },
2126 
2127  {
2128  {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2129  gettext_noop("Minimum age at which VACUUM should freeze a table row."),
2130  NULL
2131  },
2133  50000000, 0, 1000000000,
2134  NULL, NULL, NULL
2135  },
2136 
2137  {
2138  {"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2139  gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
2140  NULL
2141  },
2143  150000000, 0, 2000000000,
2144  NULL, NULL, NULL
2145  },
2146 
2147  {
2148  {"vacuum_multixact_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2149  gettext_noop("Minimum age at which VACUUM should freeze a MultiXactId in a table row."),
2150  NULL
2151  },
2153  5000000, 0, 1000000000,
2154  NULL, NULL, NULL
2155  },
2156 
2157  {
2158  {"vacuum_multixact_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2159  gettext_noop("Multixact age at which VACUUM should scan whole table to freeze tuples."),
2160  NULL
2161  },
2163  150000000, 0, 2000000000,
2164  NULL, NULL, NULL
2165  },
2166 
2167  {
2168  {"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_MASTER,
2169  gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."),
2170  NULL
2171  },
2173  0, 0, 1000000,
2174  NULL, NULL, NULL
2175  },
2176 
2177  /*
2178  * See also CheckRequiredParameterValues() if this parameter changes
2179  */
2180  {
2181  {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
2182  gettext_noop("Sets the maximum number of locks per transaction."),
2183  gettext_noop("The shared lock table is sized on the assumption that "
2184  "at most max_locks_per_transaction * max_connections distinct "
2185  "objects will need to be locked at any one time.")
2186  },
2188  64, 10, INT_MAX,
2189  NULL, NULL, NULL
2190  },
2191 
2192  {
2193  {"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
2194  gettext_noop("Sets the maximum number of predicate locks per transaction."),
2195  gettext_noop("The shared predicate lock table is sized on the assumption that "
2196  "at most max_pred_locks_per_transaction * max_connections distinct "
2197  "objects will need to be locked at any one time.")
2198  },
2200  64, 10, INT_MAX,
2201  NULL, NULL, NULL
2202  },
2203 
2204  {
2205  {"max_pred_locks_per_relation", PGC_SIGHUP, LOCK_MANAGEMENT,
2206  gettext_noop("Sets the maximum number of predicate-locked pages and tuples per relation."),
2207  gettext_noop("If more than this total of pages and tuples in the same relation are locked "
2208  "by a connection, those locks are replaced by a relation level lock.")
2209  },
2211  -2, INT_MIN, INT_MAX,
2212  NULL, NULL, NULL
2213  },
2214 
2215  {
2216  {"max_pred_locks_per_page", PGC_SIGHUP, LOCK_MANAGEMENT,
2217  gettext_noop("Sets the maximum number of predicate-locked tuples per page."),
2218  gettext_noop("If more than this number of tuples on the same page are locked "
2219  "by a connection, those locks are replaced by a page level lock.")
2220  },
2222  2, 0, INT_MAX,
2223  NULL, NULL, NULL
2224  },
2225 
2226  {
2227  {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
2228  gettext_noop("Sets the maximum allowed time to complete client authentication."),
2229  NULL,
2230  GUC_UNIT_S
2231  },
2233  60, 1, 600,
2234  NULL, NULL, NULL
2235  },
2236 
2237  {
2238  /* Not for general use */
2239  {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
2240  gettext_noop("Waits N seconds on connection startup before authentication."),
2241  gettext_noop("This allows attaching a debugger to the process."),
2243  },
2244  &PreAuthDelay,
2245  0, 0, 60,
2246  NULL, NULL, NULL
2247  },
2248 
2249  {
2250  {"wal_keep_segments", PGC_SIGHUP, REPLICATION_SENDING,
2251  gettext_noop("Sets the number of WAL files held for standby servers."),
2252  NULL
2253  },
2255  0, 0, INT_MAX,
2256  NULL, NULL, NULL
2257  },
2258 
2259  {
2260  {"min_wal_size", PGC_SIGHUP, WAL_CHECKPOINTS,
2261  gettext_noop("Sets the minimum size to shrink the WAL to."),
2262  NULL,
2263  GUC_UNIT_MB
2264  },
2265  &min_wal_size_mb,
2266  5 * (XLOG_SEG_SIZE/ (1024 * 1024)), 2, MAX_KILOBYTES,
2267  NULL, NULL, NULL
2268  },
2269 
2270  {
2271  {"max_wal_size", PGC_SIGHUP, WAL_CHECKPOINTS,
2272  gettext_noop("Sets the WAL size that triggers a checkpoint."),
2273  NULL,
2274  GUC_UNIT_MB
2275  },
2276  &max_wal_size_mb,
2277  64 * (XLOG_SEG_SIZE/ (1024 * 1024)), 2, MAX_KILOBYTES,
2278  NULL, assign_max_wal_size, NULL
2279  },
2280 
2281  {
2282  {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
2283  gettext_noop("Sets the maximum time between automatic WAL checkpoints."),
2284  NULL,
2285  GUC_UNIT_S
2286  },
2288  300, 30, 86400,
2289  NULL, NULL, NULL
2290  },
2291 
2292  {
2293  {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
2294  gettext_noop("Enables warnings if checkpoint segments are filled more "
2295  "frequently than this."),
2296  gettext_noop("Write a message to the server log if checkpoints "
2297  "caused by the filling of checkpoint segment files happens more "
2298  "frequently than this number of seconds. Zero turns off the warning."),
2299  GUC_UNIT_S
2300  },
2302  30, 0, INT_MAX,
2303  NULL, NULL, NULL
2304  },
2305 
2306  {
2307  {"checkpoint_flush_after", PGC_SIGHUP, WAL_CHECKPOINTS,
2308  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2309  NULL,
2311  },
2314  NULL, NULL, NULL
2315  },
2316 
2317  {
2318  {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
2319  gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
2320  NULL,
2322  },
2323  &XLOGbuffers,
2324  -1, -1, (INT_MAX / XLOG_BLCKSZ),
2326  },
2327 
2328  {
2329  {"wal_writer_delay", PGC_SIGHUP, WAL_SETTINGS,
2330  gettext_noop("Time between WAL flushes performed in the WAL writer."),
2331  NULL,
2332  GUC_UNIT_MS
2333  },
2334  &WalWriterDelay,
2335  200, 1, 10000,
2336  NULL, NULL, NULL
2337  },
2338 
2339  {
2340  {"wal_writer_flush_after", PGC_SIGHUP, WAL_SETTINGS,
2341  gettext_noop("Amount of WAL written out by WAL writer that triggers a flush."),
2342  NULL,
2344  },
2346  (1024 * 1024) / XLOG_BLCKSZ, 0, INT_MAX,
2347  NULL, NULL, NULL
2348  },
2349 
2350  {
2351  /* see max_connections */
2352  {"max_wal_senders", PGC_POSTMASTER, REPLICATION_SENDING,
2353  gettext_noop("Sets the maximum number of simultaneously running WAL sender processes."),
2354  NULL
2355  },
2356  &max_wal_senders,
2357  10, 0, MAX_BACKENDS,
2358  NULL, NULL, NULL
2359  },
2360 
2361  {
2362  /* see max_connections */
2363  {"max_replication_slots", PGC_POSTMASTER, REPLICATION_SENDING,
2364  gettext_noop("Sets the maximum number of simultaneously defined replication slots."),
2365  NULL
2366  },
2368  10, 0, MAX_BACKENDS /* XXX? */ ,
2369  NULL, NULL, NULL
2370  },
2371 
2372  {
2373  {"wal_sender_timeout", PGC_SIGHUP, REPLICATION_SENDING,
2374  gettext_noop("Sets the maximum time to wait for WAL replication."),
2375  NULL,
2376  GUC_UNIT_MS
2377  },
2379  60 * 1000, 0, INT_MAX,
2380  NULL, NULL, NULL
2381  },
2382 
2383  {
2384  {"commit_delay", PGC_SUSET, WAL_SETTINGS,
2385  gettext_noop("Sets the delay in microseconds between transaction commit and "
2386  "flushing WAL to disk."),
2387  NULL
2388  /* we have no microseconds designation, so can't supply units here */
2389  },
2390  &CommitDelay,
2391  0, 0, 100000,
2392  NULL, NULL, NULL
2393  },
2394 
2395  {
2396  {"commit_siblings", PGC_USERSET, WAL_SETTINGS,
2397  gettext_noop("Sets the minimum concurrent open transactions before performing "
2398  "commit_delay."),
2399  NULL
2400  },
2401  &CommitSiblings,
2402  5, 0, 1000,
2403  NULL, NULL, NULL
2404  },
2405 
2406  {
2407  {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
2408  gettext_noop("Sets the number of digits displayed for floating-point values."),
2409  gettext_noop("This affects real, double precision, and geometric data types. "
2410  "The parameter value is added to the standard number of digits "
2411  "(FLT_DIG or DBL_DIG as appropriate).")
2412  },
2414  0, -15, 3,
2415  NULL, NULL, NULL
2416  },
2417 
2418  {
2419  {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
2420  gettext_noop("Sets the minimum execution time above which "
2421  "statements will be logged."),
2422  gettext_noop("Zero prints all queries. -1 turns this feature off."),
2423  GUC_UNIT_MS
2424  },
2426  -1, -1, INT_MAX,
2427  NULL, NULL, NULL
2428  },
2429 
2430  {
2431  {"log_autovacuum_min_duration", PGC_SIGHUP, LOGGING_WHAT,
2432  gettext_noop("Sets the minimum execution time above which "
2433  "autovacuum actions will be logged."),
2434  gettext_noop("Zero prints all actions. -1 turns autovacuum logging off."),
2435  GUC_UNIT_MS
2436  },
2438  -1, -1, INT_MAX,
2439  NULL, NULL, NULL
2440  },
2441 
2442  {
2443  {"bgwriter_delay", PGC_SIGHUP, RESOURCES_BGWRITER,
2444  gettext_noop("Background writer sleep time between rounds."),
2445  NULL,
2446  GUC_UNIT_MS
2447  },
2448  &BgWriterDelay,
2449  200, 10, 10000,
2450  NULL, NULL, NULL
2451  },
2452 
2453  {
2454  {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES_BGWRITER,
2455  gettext_noop("Background writer maximum number of LRU pages to flush per round."),
2456  NULL
2457  },
2459  100, 0, INT_MAX / 2, /* Same upper limit as shared_buffers */
2460  NULL, NULL, NULL
2461  },
2462 
2463  {
2464  {"bgwriter_flush_after", PGC_SIGHUP, RESOURCES_BGWRITER,
2465  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2466  NULL,
2468  },
2471  NULL, NULL, NULL
2472  },
2473 
2474  {
2475  {"effective_io_concurrency",
2476  PGC_USERSET,
2478  gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."),
2479  gettext_noop("For RAID arrays, this should be approximately the number of drive spindles in the array.")
2480  },
2482 #ifdef USE_PREFETCH
2483  1, 0, MAX_IO_CONCURRENCY,
2484 #else
2485  0, 0, 0,
2486 #endif
2488  },
2489 
2490  {
2491  {"backend_flush_after", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2492  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2493  NULL,
2495  },
2498  NULL, NULL, NULL
2499  },
2500 
2501  {
2502  {"max_worker_processes",
2505  gettext_noop("Maximum number of concurrent worker processes."),
2506  NULL,
2507  },
2509  8, 0, MAX_BACKENDS,
2511  },
2512 
2513  {
2514  {"max_logical_replication_workers",
2517  gettext_noop("Maximum number of logical replication worker processes."),
2518  NULL,
2519  },
2521  4, 0, MAX_BACKENDS,
2522  NULL, NULL, NULL
2523  },
2524 
2525  {
2526  {"max_sync_workers_per_subscription",
2527  PGC_SIGHUP,
2529  gettext_noop("Maximum number of table synchronization workers per subscription."),
2530  NULL,
2531  },
2533  2, 0, MAX_BACKENDS,
2534  NULL, NULL, NULL
2535  },
2536 
2537  {
2538  {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
2539  gettext_noop("Automatic log file rotation will occur after N minutes."),
2540  NULL,
2541  GUC_UNIT_MIN
2542  },
2543  &Log_RotationAge,
2545  NULL, NULL, NULL
2546  },
2547 
2548  {
2549  {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
2550  gettext_noop("Automatic log file rotation will occur after N kilobytes."),
2551  NULL,
2552  GUC_UNIT_KB
2553  },
2555  10 * 1024, 0, INT_MAX / 1024,
2556  NULL, NULL, NULL
2557  },
2558 
2559  {
2560  {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
2561  gettext_noop("Shows the maximum number of function arguments."),
2562  NULL,
2564  },
2567  NULL, NULL, NULL
2568  },
2569 
2570  {
2571  {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
2572  gettext_noop("Shows the maximum number of index keys."),
2573  NULL,
2575  },
2576  &max_index_keys,
2578  NULL, NULL, NULL
2579  },
2580 
2581  {
2582  {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
2583  gettext_noop("Shows the maximum identifier length."),
2584  NULL,
2586  },
2588  NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1,
2589  NULL, NULL, NULL
2590  },
2591 
2592  {
2593  {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
2594  gettext_noop("Shows the size of a disk block."),
2595  NULL,
2597  },
2598  &block_size,
2599  BLCKSZ, BLCKSZ, BLCKSZ,
2600  NULL, NULL, NULL
2601  },
2602 
2603  {
2604  {"segment_size", PGC_INTERNAL, PRESET_OPTIONS,
2605  gettext_noop("Shows the number of pages per disk file."),
2606  NULL,
2608  },
2609  &segment_size,
2610  RELSEG_SIZE, RELSEG_SIZE, RELSEG_SIZE,
2611  NULL, NULL, NULL
2612  },
2613 
2614  {
2615  {"wal_block_size", PGC_INTERNAL, PRESET_OPTIONS,
2616  gettext_noop("Shows the block size in the write ahead log."),
2617  NULL,
2619  },
2620  &wal_block_size,
2621  XLOG_BLCKSZ, XLOG_BLCKSZ, XLOG_BLCKSZ,
2622  NULL, NULL, NULL
2623  },
2624 
2625  {
2626  {"wal_retrieve_retry_interval", PGC_SIGHUP, REPLICATION_STANDBY,
2627  gettext_noop("Sets the time to wait before retrying to retrieve WAL "
2628  "after a failed attempt."),
2629  NULL,
2630  GUC_UNIT_MS
2631  },
2633  5000, 1, INT_MAX,
2634  NULL, NULL, NULL
2635  },
2636 
2637  {
2638  {"wal_segment_size", PGC_INTERNAL, PRESET_OPTIONS,
2639  gettext_noop("Shows the number of pages per write ahead log segment."),
2640  NULL,
2642  },
2644  (XLOG_SEG_SIZE / XLOG_BLCKSZ),
2645  (XLOG_SEG_SIZE / XLOG_BLCKSZ),
2646  (XLOG_SEG_SIZE / XLOG_BLCKSZ),
2647  NULL, NULL, NULL
2648  },
2649 
2650  {
2651  {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
2652  gettext_noop("Time to sleep between autovacuum runs."),
2653  NULL,
2654  GUC_UNIT_S
2655  },
2657  60, 1, INT_MAX / 1000,
2658  NULL, NULL, NULL
2659  },
2660  {
2661  {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
2662  gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
2663  NULL
2664  },
2666  50, 0, INT_MAX,
2667  NULL, NULL, NULL
2668  },
2669  {
2670  {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
2671  gettext_noop("Minimum number of tuple inserts, updates, or deletes prior to analyze."),
2672  NULL
2673  },
2675  50, 0, INT_MAX,
2676  NULL, NULL, NULL
2677  },
2678  {
2679  /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
2680  {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
2681  gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
2682  NULL
2683  },
2685  /* see pg_resetwal if you change the upper-limit value */
2686  200000000, 100000, 2000000000,
2687  NULL, NULL, NULL
2688  },
2689  {
2690  /* see multixact.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
2691  {"autovacuum_multixact_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
2692  gettext_noop("Multixact age at which to autovacuum a table to prevent multixact wraparound."),
2693  NULL
2694  },
2696  400000000, 10000, 2000000000,
2697  NULL, NULL, NULL
2698  },
2699  {
2700  /* see max_connections */
2701  {"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM,
2702  gettext_noop("Sets the maximum number of simultaneously running autovacuum worker processes."),
2703  NULL
2704  },
2706  3, 1, MAX_BACKENDS,
2708  },
2709 
2710  {
2711  {"max_parallel_workers_per_gather", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2712  gettext_noop("Sets the maximum number of parallel processes per executor node."),
2713  NULL
2714  },
2717  NULL, NULL, NULL
2718  },
2719 
2720  {
2721  {"max_parallel_workers", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2722  gettext_noop("Sets the maximum number of parallel workers than can be active at one time."),
2723  NULL
2724  },
2727  NULL, NULL, NULL
2728  },
2729 
2730  {
2731  {"autovacuum_work_mem", PGC_SIGHUP, RESOURCES_MEM,
2732  gettext_noop("Sets the maximum memory to be used by each autovacuum worker process."),
2733  NULL,
2734  GUC_UNIT_KB
2735  },
2737  -1, -1, MAX_KILOBYTES,
2739  },
2740 
2741  {
2742  {"old_snapshot_threshold", PGC_POSTMASTER, RESOURCES_ASYNCHRONOUS,
2743  gettext_noop("Time before a snapshot is too old to read pages changed after the snapshot was taken."),
2744  gettext_noop("A value of -1 disables this feature."),
2745  GUC_UNIT_MIN
2746  },
2748  -1, -1, MINS_PER_HOUR * HOURS_PER_DAY * 60,
2749  NULL, NULL, NULL
2750  },
2751 
2752  {
2753  {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
2754  gettext_noop("Time between issuing TCP keepalives."),
2755  gettext_noop("A value of 0 uses the system default."),
2756  GUC_UNIT_S
2757  },
2759  0, 0, INT_MAX,
2761  },
2762 
2763  {
2764  {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
2765  gettext_noop("Time between TCP keepalive retransmits."),
2766  gettext_noop("A value of 0 uses the system default."),
2767  GUC_UNIT_S
2768  },
2770  0, 0, INT_MAX,
2772  },
2773 
2774  {
2775  {"ssl_renegotiation_limit", PGC_USERSET, CONN_AUTH_SECURITY,
2776  gettext_noop("SSL renegotiation is no longer supported; this can only be 0."),
2777  NULL,
2779  },
2781  0, 0, 0,
2782  NULL, NULL, NULL
2783  },
2784 
2785  {
2786  {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
2787  gettext_noop("Maximum number of TCP keepalive retransmits."),
2788  gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
2789  "lost before a connection is considered dead. A value of 0 uses the "
2790  "system default."),
2791  },
2793  0, 0, INT_MAX,
2795  },
2796 
2797  {
2798  {"gin_fuzzy_search_limit", PGC_USERSET, CLIENT_CONN_OTHER,
2799  gettext_noop("Sets the maximum allowed result for exact search by GIN."),
2800  NULL,
2801  0
2802  },
2804  0, 0, INT_MAX,
2805  NULL, NULL, NULL
2806  },
2807 
2808  {
2809  {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
2810  gettext_noop("Sets the planner's assumption about the size of the disk cache."),
2811  gettext_noop("That is, the portion of the kernel's disk cache that "
2812  "will be used for PostgreSQL data files. This is measured in disk "
2813  "pages, which are normally 8 kB each."),
2815  },
2817  DEFAULT_EFFECTIVE_CACHE_SIZE, 1, INT_MAX,
2818  NULL, NULL, NULL
2819  },
2820 
2821  {
2822  {"min_parallel_table_scan_size", PGC_USERSET, QUERY_TUNING_COST,
2823  gettext_noop("Sets the minimum amount of table data for a parallel scan."),
2824  gettext_noop("If the planner estimates that it will read a number of table pages too small to reach this limit, a parallel scan will not be considered."),
2826  },
2828  (8 * 1024 * 1024) / BLCKSZ, 0, INT_MAX / 3,
2829  NULL, NULL, NULL
2830  },
2831 
2832  {
2833  {"min_parallel_index_scan_size", PGC_USERSET, QUERY_TUNING_COST,
2834  gettext_noop("Sets the minimum amount of index data for a parallel scan."),
2835  gettext_noop("If the planner estimates that it will read a number of index pages too small to reach this limit, a parallel scan will not be considered."),
2837  },
2839  (512 * 1024) / BLCKSZ, 0, INT_MAX / 3,
2840  NULL, NULL, NULL
2841  },
2842 
2843  {
2844  /* Can't be set in postgresql.conf */
2845  {"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
2846  gettext_noop("Shows the server version as an integer."),
2847  NULL,
2849  },
2851  PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM,
2852  NULL, NULL, NULL
2853  },
2854 
2855  {
2856  {"log_temp_files", PGC_SUSET, LOGGING_WHAT,
2857  gettext_noop("Log the use of temporary files larger than this number of kilobytes."),
2858  gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
2859  GUC_UNIT_KB
2860  },
2861  &log_temp_files,
2862  -1, -1, INT_MAX,
2863  NULL, NULL, NULL
2864  },
2865 
2866  {
2867  {"track_activity_query_size", PGC_POSTMASTER, RESOURCES_MEM,
2868  gettext_noop("Sets the size reserved for pg_stat_activity.query, in bytes."),
2869  NULL,
2870 
2871  /*
2872  * There is no _bytes_ unit, so the user can't supply units for
2873  * this.
2874  */
2875  },
2877  1024, 100, 102400,
2878  NULL, NULL, NULL
2879  },
2880 
2881  {
2882  {"gin_pending_list_limit", PGC_USERSET, CLIENT_CONN_STATEMENT,
2883  gettext_noop("Sets the maximum size of the pending list for GIN index."),
2884  NULL,
2885  GUC_UNIT_KB
2886  },
2888  4096, 64, MAX_KILOBYTES,
2889  NULL, NULL, NULL
2890  },
2891 
2892  /* End-of-list marker */
2893  {
2894  {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
2895  }
2896 };
2897 
2898 
2900 {
2901  {
2902  {"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
2903  gettext_noop("Sets the planner's estimate of the cost of a "
2904  "sequentially fetched disk page."),
2905  NULL
2906  },
2907  &seq_page_cost,
2908  DEFAULT_SEQ_PAGE_COST, 0, DBL_MAX,
2909  NULL, NULL, NULL
2910  },
2911  {
2912  {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
2913  gettext_noop("Sets the planner's estimate of the cost of a "
2914  "nonsequentially fetched disk page."),
2915  NULL
2916  },
2918  DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX,
2919  NULL, NULL, NULL
2920  },
2921  {
2922  {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2923  gettext_noop("Sets the planner's estimate of the cost of "
2924  "processing each tuple (row)."),
2925  NULL
2926  },
2927  &cpu_tuple_cost,
2928  DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX,
2929  NULL, NULL, NULL
2930  },
2931  {
2932  {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2933  gettext_noop("Sets the planner's estimate of the cost of "
2934  "processing each index entry during an index scan."),
2935  NULL
2936  },
2938  DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX,
2939  NULL, NULL, NULL
2940  },
2941  {
2942  {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
2943  gettext_noop("Sets the planner's estimate of the cost of "
2944  "processing each operator or function call."),
2945  NULL
2946  },
2948  DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX,
2949  NULL, NULL, NULL
2950  },
2951  {
2952  {"parallel_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2953  gettext_noop("Sets the planner's estimate of the cost of "
2954  "passing each tuple (row) from worker to master backend."),
2955  NULL
2956  },
2958  DEFAULT_PARALLEL_TUPLE_COST, 0, DBL_MAX,
2959  NULL, NULL, NULL
2960  },
2961  {
2962  {"parallel_setup_cost", PGC_USERSET, QUERY_TUNING_COST,
2963  gettext_noop("Sets the planner's estimate of the cost of "
2964  "starting up worker processes for parallel query."),
2965  NULL
2966  },
2968  DEFAULT_PARALLEL_SETUP_COST, 0, DBL_MAX,
2969  NULL, NULL, NULL
2970  },
2971 
2972  {
2973  {"cursor_tuple_fraction", PGC_USERSET, QUERY_TUNING_OTHER,
2974  gettext_noop("Sets the planner's estimate of the fraction of "
2975  "a cursor's rows that will be retrieved."),
2976  NULL
2977  },
2980  NULL, NULL, NULL
2981  },
2982 
2983  {
2984  {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
2985  gettext_noop("GEQO: selective pressure within the population."),
2986  NULL
2987  },
2991  NULL, NULL, NULL
2992  },
2993  {
2994  {"geqo_seed", PGC_USERSET, QUERY_TUNING_GEQO,
2995  gettext_noop("GEQO: seed for random path selection."),
2996  NULL
2997  },
2998  &Geqo_seed,
2999  0.0, 0.0, 1.0,
3000  NULL, NULL, NULL
3001  },
3002 
3003  {
3004  {"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES_BGWRITER,
3005  gettext_noop("Multiple of the average buffer usage to free per round."),
3006  NULL
3007  },
3009  2.0, 0.0, 10.0,
3010  NULL, NULL, NULL
3011  },
3012 
3013  {
3014  {"seed", PGC_USERSET, UNGROUPED,
3015  gettext_noop("Sets the seed for random-number generation."),
3016  NULL,
3018  },
3020  0.0, -1.0, 1.0,
3022  },
3023 
3024  {
3025  {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
3026  gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
3027  NULL
3028  },
3030  0.2, 0.0, 100.0,
3031  NULL, NULL, NULL
3032  },
3033  {
3034  {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
3035  gettext_noop("Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples."),
3036  NULL
3037  },
3039  0.1, 0.0, 100.0,
3040  NULL, NULL, NULL
3041  },
3042 
3043  {
3044  {"checkpoint_completion_target", PGC_SIGHUP, WAL_CHECKPOINTS,
3045  gettext_noop("Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval."),
3046  NULL
3047  },
3049  0.5, 0.0, 1.0,
3050  NULL, NULL, NULL
3051  },
3052 
3053  /* End-of-list marker */
3054  {
3055  {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL, NULL
3056  }
3057 };
3058 
3059 
3061 {
3062  {
3063  {"archive_command", PGC_SIGHUP, WAL_ARCHIVING,
3064  gettext_noop("Sets the shell command that will be called to archive a WAL file."),
3065  NULL
3066  },
3068  "",
3070  },
3071 
3072  {
3073  {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
3074  gettext_noop("Sets the client's character set encoding."),
3075  NULL,
3077  },
3079  "SQL_ASCII",
3081  },
3082 
3083  {
3084  {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
3085  gettext_noop("Controls information prefixed to each log line."),
3086  gettext_noop("If blank, no prefix is used.")
3087  },
3088  &Log_line_prefix,
3089  "%m [%p] ",
3090  NULL, NULL, NULL
3091  },
3092 
3093  {
3094  {"log_timezone", PGC_SIGHUP, LOGGING_WHAT,
3095  gettext_noop("Sets the time zone to use in log messages."),
3096  NULL
3097  },
3099  "GMT",
3101  },
3102 
3103  {
3104  {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
3105  gettext_noop("Sets the display format for date and time values."),
3106  gettext_noop("Also controls interpretation of ambiguous "
3107  "date inputs."),
3109  },
3111  "ISO, MDY",
3113  },
3114 
3115  {
3116  {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
3117  gettext_noop("Sets the default tablespace to create tables and indexes in."),
3118  gettext_noop("An empty string selects the database's default tablespace."),
3119  GUC_IS_NAME
3120  },
3122  "",
3124  },
3125 
3126  {
3127  {"temp_tablespaces", PGC_USERSET, CLIENT_CONN_STATEMENT,
3128  gettext_noop("Sets the tablespace(s) to use for temporary tables and sort files."),
3129  NULL,
3131  },
3133  "",
3135  },
3136 
3137  {
3138  {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
3139  gettext_noop("Sets the path for dynamically loadable modules."),
3140  gettext_noop("If a dynamically loadable module needs to be opened and "
3141  "the specified name does not have a directory component (i.e., the "
3142  "name does not contain a slash), the system will search this path for "
3143  "the specified file."),
3145  },
3147  "$libdir",
3148  NULL, NULL, NULL
3149  },
3150 
3151  {
3152  {"krb_server_keyfile", PGC_SIGHUP, CONN_AUTH_SECURITY,
3153  gettext_noop("Sets the location of the Kerberos server key file."),
3154  NULL,
3156  },
3158  PG_KRB_SRVTAB,
3159  NULL, NULL, NULL
3160  },
3161 
3162  {
3163  {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3164  gettext_noop("Sets the Bonjour service name."),
3165  NULL
3166  },
3167  &bonjour_name,
3168  "",
3169  NULL, NULL, NULL
3170  },
3171 
3172  /* See main.c about why defaults for LC_foo are not all alike */
3173 
3174  {
3175  {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3176  gettext_noop("Shows the collation order locale."),
3177  NULL,
3179  },
3180  &locale_collate,
3181  "C",
3182  NULL, NULL, NULL
3183  },
3184 
3185  {
3186  {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3187  gettext_noop("Shows the character classification and case conversion locale."),
3188  NULL,
3190  },
3191  &locale_ctype,
3192  "C",
3193  NULL, NULL, NULL
3194  },
3195 
3196  {
3197  {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
3198  gettext_noop("Sets the language in which messages are displayed."),
3199  NULL
3200  },
3201  &locale_messages,
3202  "",
3204  },
3205 
3206  {
3207  {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
3208  gettext_noop("Sets the locale for formatting monetary amounts."),
3209  NULL
3210  },
3211  &locale_monetary,
3212  "C",
3214  },
3215 
3216  {
3217  {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
3218  gettext_noop("Sets the locale for formatting numbers."),
3219  NULL
3220  },
3221  &locale_numeric,
3222  "C",
3224  },
3225 
3226  {
3227  {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
3228  gettext_noop("Sets the locale for formatting date and time values."),
3229  NULL
3230  },
3231  &locale_time,
3232  "C",
3234  },
3235 
3236  {
3237  {"session_preload_libraries", PGC_SUSET, CLIENT_CONN_PRELOAD,
3238  gettext_noop("Lists shared libraries to preload into each backend."),
3239  NULL,
3241  },
3243  "",
3244  NULL, NULL, NULL
3245  },
3246 
3247  {
3248  {"shared_preload_libraries", PGC_POSTMASTER, CLIENT_CONN_PRELOAD,
3249  gettext_noop("Lists shared libraries to preload into server."),
3250  NULL,
3252  },
3254  "",
3255  NULL, NULL, NULL
3256  },
3257 
3258  {
3259  {"local_preload_libraries", PGC_USERSET, CLIENT_CONN_PRELOAD,
3260  gettext_noop("Lists unprivileged shared libraries to preload into each backend."),
3261  NULL,
3263  },
3265  "",
3266  NULL, NULL, NULL
3267  },
3268 
3269  {
3270  {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
3271  gettext_noop("Sets the schema search order for names that are not schema-qualified."),
3272  NULL,
3274  },
3276  "\"$user\", public",
3278  },
3279 
3280  {
3281  /* Can't be set in postgresql.conf */
3282  {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3283  gettext_noop("Sets the server (database) character set encoding."),
3284  NULL,
3286  },
3288  "SQL_ASCII",
3289  NULL, NULL, NULL
3290  },
3291 
3292  {
3293  /* Can't be set in postgresql.conf */
3294  {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
3295  gettext_noop("Shows the server version."),
3296  NULL,
3298  },
3300  PG_VERSION,
3301  NULL, NULL, NULL
3302  },
3303 
3304  {
3305  /* Not for general use --- used by SET ROLE */
3306  {"role", PGC_USERSET, UNGROUPED,
3307  gettext_noop("Sets the current role."),
3308  NULL,
3310  },
3311  &role_string,
3312  "none",
3314  },
3315 
3316  {
3317  /* Not for general use --- used by SET SESSION AUTHORIZATION */
3318  {"session_authorization", PGC_USERSET, UNGROUPED,
3319  gettext_noop("Sets the session user name."),
3320  NULL,
3322  },
3324  NULL,
3326  },
3327 
3328  {
3329  {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
3330  gettext_noop("Sets the destination for server log output."),
3331  gettext_noop("Valid values are combinations of \"stderr\", "
3332  "\"syslog\", \"csvlog\", and \"eventlog\", "
3333  "depending on the platform."),
3335  },
3337  "stderr",
3339  },
3340  {
3341  {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
3342  gettext_noop("Sets the destination directory for log files."),
3343  gettext_noop("Can be specified as relative to the data directory "
3344  "or as absolute path."),
3346  },
3347  &Log_directory,
3348  "log",
3349  check_canonical_path, NULL, NULL
3350  },
3351  {
3352  {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
3353  gettext_noop("Sets the file name pattern for log files."),
3354  NULL,
3356  },
3357  &Log_filename,
3358  "postgresql-%Y-%m-%d_%H%M%S.log",
3359  NULL, NULL, NULL
3360  },
3361 
3362  {
3363  {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
3364  gettext_noop("Sets the program name used to identify PostgreSQL "
3365  "messages in syslog."),
3366  NULL
3367  },
3369  "postgres",
3370  NULL, assign_syslog_ident, NULL
3371  },
3372 
3373  {
3374  {"event_source", PGC_POSTMASTER, LOGGING_WHERE,
3375  gettext_noop("Sets the application name used to identify "
3376  "PostgreSQL messages in the event log."),
3377  NULL
3378  },
3379  &event_source,
3381  NULL, NULL, NULL
3382  },
3383 
3384  {
3385  {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
3386  gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
3387  NULL,
3388  GUC_REPORT
3389  },
3390  &timezone_string,
3391  "GMT",
3393  },
3394  {
3395  {"timezone_abbreviations", PGC_USERSET, CLIENT_CONN_LOCALE,
3396  gettext_noop("Selects a file of time zone abbreviations."),
3397  NULL
3398  },
3400  NULL,
3402  },
3403 
3404  {
3405  {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
3406  gettext_noop("Sets the current transaction's isolation level."),
3407  NULL,
3409  },
3411  "default",
3413  },
3414 
3415  {
3416  {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3417  gettext_noop("Sets the owning group of the Unix-domain socket."),
3418  gettext_noop("The owning user of the socket is always the user "
3419  "that starts the server.")
3420  },
3422  "",
3423  NULL, NULL, NULL
3424  },
3425 
3426  {
3427  {"unix_socket_directories", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3428  gettext_noop("Sets the directories where Unix-domain sockets will be created."),
3429  NULL,
3431  },
3433 #ifdef HAVE_UNIX_SOCKETS
3435 #else
3436  "",
3437 #endif
3438  NULL, NULL, NULL
3439  },
3440 
3441  {
3442  {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3443  gettext_noop("Sets the host name or IP address(es) to listen to."),
3444  NULL,
3446  },
3447  &ListenAddresses,
3448  "localhost",
3449  NULL, NULL, NULL
3450  },
3451 
3452  {
3453  /*
3454  * Can't be set by ALTER SYSTEM as it can lead to recursive definition
3455  * of data_directory.
3456  */
3457  {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
3458  gettext_noop("Sets the server's data directory."),
3459  NULL,
3461  },
3462  &data_directory,
3463  NULL,
3464  NULL, NULL, NULL
3465  },
3466 
3467  {
3468  {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
3469  gettext_noop("Sets the server's main configuration file."),
3470  NULL,
3472  },
3473  &ConfigFileName,
3474  NULL,
3475  NULL, NULL, NULL
3476  },
3477 
3478  {
3479  {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
3480  gettext_noop("Sets the server's \"hba\" configuration file."),
3481  NULL,
3483  },
3484  &HbaFileName,
3485  NULL,
3486  NULL, NULL, NULL
3487  },
3488 
3489  {
3490  {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
3491  gettext_noop("Sets the server's \"ident\" configuration file."),
3492  NULL,
3494  },
3495  &IdentFileName,
3496  NULL,
3497  NULL, NULL, NULL
3498  },
3499 
3500  {
3501  {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
3502  gettext_noop("Writes the postmaster PID to the specified file."),
3503  NULL,
3505  },
3507  NULL,
3508  check_canonical_path, NULL, NULL
3509  },
3510 
3511  {
3512  {"ssl_cert_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3513  gettext_noop("Location of the SSL server certificate file."),
3514  NULL
3515  },
3516  &ssl_cert_file,
3517  "server.crt",
3518  NULL, NULL, NULL
3519  },
3520 
3521  {
3522  {"ssl_key_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3523  gettext_noop("Location of the SSL server private key file."),
3524  NULL
3525  },
3526  &ssl_key_file,
3527  "server.key",
3528  NULL, NULL, NULL
3529  },
3530 
3531  {
3532  {"ssl_ca_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3533  gettext_noop("Location of the SSL certificate authority file."),
3534  NULL
3535  },
3536  &ssl_ca_file,
3537  "",
3538  NULL, NULL, NULL
3539  },
3540 
3541  {
3542  {"ssl_crl_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3543  gettext_noop("Location of the SSL certificate revocation list file."),
3544  NULL
3545  },
3546  &ssl_crl_file,
3547  "",
3548  NULL, NULL, NULL
3549  },
3550 
3551  {
3552  {"stats_temp_directory", PGC_SIGHUP, STATS_COLLECTOR,
3553  gettext_noop("Writes temporary statistics files to the specified directory."),
3554  NULL,
3556  },
3560  },
3561 
3562  {
3563  {"synchronous_standby_names", PGC_SIGHUP, REPLICATION_MASTER,
3564  gettext_noop("Number of synchronous standbys and list of names of potential synchronous ones."),
3565  NULL,
3567  },
3569  "",
3571  },
3572 
3573  {
3574  {"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
3575  gettext_noop("Sets default text search configuration."),
3576  NULL
3577  },
3578  &TSCurrentConfig,
3579  "pg_catalog.simple",
3581  },
3582 
3583  {
3584  {"ssl_ciphers", PGC_SIGHUP, CONN_AUTH_SECURITY,
3585  gettext_noop("Sets the list of allowed SSL ciphers."),
3586  NULL,
3588  },
3589  &SSLCipherSuites,
3590 #ifdef USE_SSL
3591  "HIGH:MEDIUM:+3DES:!aNULL",
3592 #else
3593  "none",
3594 #endif
3595  NULL, NULL, NULL
3596  },
3597 
3598  {
3599  {"ssl_ecdh_curve", PGC_SIGHUP, CONN_AUTH_SECURITY,
3600  gettext_noop("Sets the curve to use for ECDH."),
3601  NULL,
3603  },
3604  &SSLECDHCurve,
3605 #ifdef USE_SSL
3606  "prime256v1",
3607 #else
3608  "none",
3609 #endif
3610  NULL, NULL, NULL
3611  },
3612 
3613  {
3614  {"application_name", PGC_USERSET, LOGGING_WHAT,
3615  gettext_noop("Sets the application name to be reported in statistics and logs."),
3616  NULL,
3618  },
3620  "",
3622  },
3623 
3624  {
3625  {"cluster_name", PGC_POSTMASTER, PROCESS_TITLE,
3626  gettext_noop("Sets the name of the cluster, which is included in the process title."),
3627  NULL,
3628  GUC_IS_NAME
3629  },
3630  &cluster_name,
3631  "",
3632  check_cluster_name, NULL, NULL
3633  },
3634 
3635  {
3636  {"wal_consistency_checking", PGC_SUSET, DEVELOPER_OPTIONS,
3637  gettext_noop("Sets the WAL resource managers for which WAL consistency checks are done."),
3638  gettext_noop("Full-page images will be logged for all data blocks and cross-checked against the results of WAL replay."),
3640  },
3642  "",
3644  },
3645 
3646  /* End-of-list marker */
3647  {
3648  {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL, NULL
3649  }
3650 };
3651 
3652 
3654 {
3655  {
3656  {"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
3657  gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
3658  NULL
3659  },
3660  &backslash_quote,
3662  NULL, NULL, NULL
3663  },
3664 
3665  {
3666  {"bytea_output", PGC_USERSET, CLIENT_CONN_STATEMENT,
3667  gettext_noop("Sets the output format for bytea."),
3668  NULL
3669  },
3670  &bytea_output,
3672  NULL, NULL, NULL
3673  },
3674 
3675  {
3676  {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
3677  gettext_noop("Sets the message levels that are sent to the client."),
3678  gettext_noop("Each level includes all the levels that follow it. The later"
3679  " the level, the fewer messages are sent.")
3680  },
3683  NULL, NULL, NULL
3684  },
3685 
3686  {
3687  {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
3688  gettext_noop("Enables the planner to use constraints to optimize queries."),
3689  gettext_noop("Table scans will be skipped if their constraints"
3690  " guarantee that no rows match the query.")
3691  },
3694  NULL, NULL, NULL
3695  },
3696 
3697  {
3698  {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
3699  gettext_noop("Sets the transaction isolation level of each new transaction."),
3700  NULL
3701  },
3704  NULL, NULL, NULL
3705  },
3706 
3707  {
3708  {"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
3709  gettext_noop("Sets the display format for interval values."),
3710  NULL,
3711  GUC_REPORT
3712  },
3713  &IntervalStyle,
3715  NULL, NULL, NULL
3716  },
3717 
3718  {
3719  {"log_error_verbosity", PGC_SUSET, LOGGING_WHAT,
3720  gettext_noop("Sets the verbosity of logged messages."),
3721  NULL
3722  },
3725  NULL, NULL, NULL
3726  },
3727 
3728  {
3729  {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
3730  gettext_noop("Sets the message levels that are logged."),
3731  gettext_noop("Each level includes all the levels that follow it. The later"
3732  " the level, the fewer messages are sent.")
3733  },
3736  NULL, NULL, NULL
3737  },
3738 
3739  {
3740  {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
3741  gettext_noop("Causes all statements generating error at or above this level to be logged."),
3742  gettext_noop("Each level includes all the levels that follow it. The later"
3743  " the level, the fewer messages are sent.")
3744  },
3747  NULL, NULL, NULL
3748  },
3749 
3750  {
3751  {"log_statement", PGC_SUSET, LOGGING_WHAT,
3752  gettext_noop("Sets the type of statements logged."),
3753  NULL
3754  },
3755  &log_statement,
3757  NULL, NULL, NULL
3758  },
3759 
3760  {
3761  {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
3762  gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
3763  NULL
3764  },
3765  &syslog_facility,
3766 #ifdef HAVE_SYSLOG
3767  LOG_LOCAL0,
3768 #else
3769  0,
3770 #endif
3773  },
3774 
3775  {
3776  {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
3777  gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
3778  NULL
3779  },
3783  },
3784 
3785  {
3786  {"synchronous_commit", PGC_USERSET, WAL_SETTINGS,
3787  gettext_noop("Sets the current transaction's synchronization level."),
3788  NULL
3789  },
3793  },
3794 
3795  {
3796  {"archive_mode", PGC_POSTMASTER, WAL_ARCHIVING,
3797  gettext_noop("Allows archiving of WAL files using archive_command."),
3798  NULL
3799  },
3800  &XLogArchiveMode,
3802  NULL, NULL, NULL
3803  },
3804 
3805  {
3806  {"trace_recovery_messages", PGC_SIGHUP, DEVELOPER_OPTIONS,
3807  gettext_noop("Enables logging of recovery-related debugging information."),
3808  gettext_noop("Each level includes all the levels that follow it. The later"
3809  " the level, the fewer messages are sent.")
3810  },
3812 
3813  /*
3814  * client_message_level_options allows too many values, really, but
3815  * it's not worth having a separate options array for this.
3816  */
3818  NULL, NULL, NULL
3819  },
3820 
3821  {
3822  {"track_functions", PGC_SUSET, STATS_COLLECTOR,
3823  gettext_noop("Collects function-level statistics on database activity."),
3824  NULL
3825  },
3828  NULL, NULL, NULL
3829  },
3830 
3831  {
3832  {"wal_level", PGC_POSTMASTER, WAL_SETTINGS,
3833  gettext_noop("Set the level of information written to the WAL."),
3834  NULL
3835  },
3836  &wal_level,
3838  NULL, NULL, NULL
3839  },
3840 
3841  {
3842  {"dynamic_shared_memory_type", PGC_POSTMASTER, RESOURCES_MEM,
3843  gettext_noop("Selects the dynamic shared memory implementation used."),
3844  NULL
3845  },
3848  NULL, NULL, NULL
3849  },
3850 
3851  {
3852  {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
3853  gettext_noop("Selects the method used for forcing WAL updates to disk."),
3854  NULL
3855  },
3856  &sync_method,
3859  },
3860 
3861  {
3862  {"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
3863  gettext_noop("Sets how binary values are to be encoded in XML."),
3864  NULL
3865  },
3866  &xmlbinary,
3868  NULL, NULL, NULL
3869  },
3870 
3871  {
3872  {"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
3873  gettext_noop("Sets whether XML data in implicit parsing and serialization "
3874  "operations is to be considered as documents or content fragments."),
3875  NULL
3876  },
3877  &xmloption,
3879  NULL, NULL, NULL
3880  },
3881 
3882  {
3883  {"huge_pages", PGC_POSTMASTER, RESOURCES_MEM,
3884  gettext_noop("Use of huge pages on Linux."),
3885  NULL
3886  },
3887  &huge_pages,
3889  NULL, NULL, NULL
3890  },
3891 
3892  {
3893  {"force_parallel_mode", PGC_USERSET, QUERY_TUNING_OTHER,
3894  gettext_noop("Forces use of parallel query facilities."),
3895  gettext_noop("If possible, run query using a parallel worker and with parallel restrictions.")
3896  },
3899  NULL, NULL, NULL
3900  },
3901 
3902  {
3903  {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
3904  gettext_noop("Encrypt passwords."),
3905  gettext_noop("When a password is specified in CREATE USER or "
3906  "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
3907  "this parameter determines whether the password is to be encrypted.")
3908  },
3911  NULL, NULL, NULL
3912  },
3913 
3914  /* End-of-list marker */
3915  {
3916  {NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
3917  }
3918 };
3919 
3920 /******** end of options list ********/
3921 
3922 
3923 /*
3924  * To allow continued support of obsolete names for GUC variables, we apply
3925  * the following mappings to any unrecognized name. Note that an old name
3926  * should be mapped to a new one only if the new variable has very similar
3927  * semantics to the old.
3928  */
3929 static const char *const map_old_guc_names[] = {
3930  "sort_mem", "work_mem",
3931  "vacuum_mem", "maintenance_work_mem",
3932  NULL
3933 };
3934 
3935 
3936 /*
3937  * Actual lookup of variables is done through this single, sorted array.
3938  */
3940 
3941 /* Current number of variables contained in the vector */
3943 
3944 /* Vector capacity */
3946 
3947 
3948 static bool guc_dirty; /* TRUE if need to do commit/abort work */
3949 
3950 static bool reporting_enabled; /* TRUE to enable GUC_REPORT */
3951 
3952 static int GUCNestLevel = 0; /* 1 when in main transaction */
3953 
3954 
3955 static int guc_var_compare(const void *a, const void *b);
3956 static int guc_name_compare(const char *namea, const char *nameb);
3957 static void InitializeGUCOptionsFromEnvironment(void);
3958 static void InitializeOneGUCOption(struct config_generic * gconf);
3959 static void push_old_value(struct config_generic * gconf, GucAction action);
3960 static void ReportGUCOption(struct config_generic * record);
3961 static void reapply_stacked_values(struct config_generic * variable,
3962  struct config_string * pHolder,
3963  GucStack *stack,
3964  const char *curvalue,
3965  GucContext curscontext, GucSource cursource);
3966 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
3967 static void ShowAllGUCConfig(DestReceiver *dest);
3968 static char *_ShowOption(struct config_generic * record, bool use_units);
3969 static bool validate_option_array_item(const char *name, const char *value,
3970  bool skipIfNoPermissions);
3971 static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p);
3972 static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
3973  const char *name, const char *value);
3974 
3975 
3976 /*
3977  * Some infrastructure for checking malloc/strdup/realloc calls
3978  */
3979 static void *
3980 guc_malloc(int elevel, size_t size)
3981 {
3982  void *data;
3983 
3984  /* Avoid unportable behavior of malloc(0) */
3985  if (size == 0)
3986  size = 1;
3987  data = malloc(size);
3988  if (data == NULL)
3989  ereport(elevel,
3990  (errcode(ERRCODE_OUT_OF_MEMORY),
3991  errmsg("out of memory")));
3992  return data;
3993 }
3994 
3995 static void *
3996 guc_realloc(int elevel, void *old, size_t size)
3997 {
3998  void *data;
3999 
4000  /* Avoid unportable behavior of realloc(NULL, 0) */
4001  if (old == NULL && size == 0)
4002  size = 1;
4003  data = realloc(old, size);
4004  if (data == NULL)
4005  ereport(elevel,
4006  (errcode(ERRCODE_OUT_OF_MEMORY),
4007  errmsg("out of memory")));
4008  return data;
4009 }
4010 
4011 static char *
4012 guc_strdup(int elevel, const char *src)
4013 {
4014  char *data;
4015 
4016  data = strdup(src);
4017  if (data == NULL)
4018  ereport(elevel,
4019  (errcode(ERRCODE_OUT_OF_MEMORY),
4020  errmsg("out of memory")));
4021  return data;
4022 }
4023 
4024 
4025 /*
4026  * Detect whether strval is referenced anywhere in a GUC string item
4027  */
4028 static bool
4029 string_field_used(struct config_string * conf, char *strval)
4030 {
4031  GucStack *stack;
4032 
4033  if (strval == *(conf->variable) ||
4034  strval == conf->reset_val ||
4035  strval == conf->boot_val)
4036  return true;
4037  for (stack = conf->gen.stack; stack; stack = stack->prev)
4038  {
4039  if (strval == stack->prior.val.stringval ||
4040  strval == stack->masked.val.stringval)
4041  return true;
4042  }
4043  return false;
4044 }
4045 
4046 /*
4047  * Support for assigning to a field of a string GUC item. Free the prior
4048  * value if it's not referenced anywhere else in the item (including stacked
4049  * states).
4050  */
4051 static void
4052 set_string_field(struct config_string * conf, char **field, char *newval)
4053 {
4054  char *oldval = *field;
4055 
4056  /* Do the assignment */
4057  *field = newval;
4058 
4059  /* Free old value if it's not NULL and isn't referenced anymore */
4060  if (oldval && !string_field_used(conf, oldval))
4061  free(oldval);
4062 }
4063 
4064 /*
4065  * Detect whether an "extra" struct is referenced anywhere in a GUC item
4066  */
4067 static bool
4068 extra_field_used(struct config_generic * gconf, void *extra)
4069 {
4070  GucStack *stack;
4071 
4072  if (extra == gconf->extra)
4073  return true;
4074  switch (gconf->vartype)
4075  {
4076  case PGC_BOOL:
4077  if (extra == ((struct config_bool *) gconf)->reset_extra)
4078  return true;
4079  break;
4080  case PGC_INT:
4081  if (extra == ((struct config_int *) gconf)->reset_extra)
4082  return true;
4083  break;
4084  case PGC_REAL:
4085  if (extra == ((struct config_real *) gconf)->reset_extra)
4086  return true;
4087  break;
4088  case PGC_STRING:
4089  if (extra == ((struct config_string *) gconf)->reset_extra)
4090  return true;
4091  break;
4092  case PGC_ENUM:
4093  if (extra == ((struct config_enum *) gconf)->reset_extra)
4094  return true;
4095  break;
4096  }
4097  for (stack = gconf->stack; stack; stack = stack->prev)
4098  {
4099  if (extra == stack->prior.extra ||
4100  extra == stack->masked.extra)
4101  return true;
4102  }
4103 
4104  return false;
4105 }
4106 
4107 /*
4108  * Support for assigning to an "extra" field of a GUC item. Free the prior
4109  * value if it's not referenced anywhere else in the item (including stacked
4110  * states).
4111  */
4112 static void
4113 set_extra_field(struct config_generic * gconf, void **field, void *newval)
4114 {
4115  void *oldval = *field;
4116 
4117  /* Do the assignment */
4118  *field = newval;
4119 
4120  /* Free old value if it's not NULL and isn't referenced anymore */
4121  if (oldval && !extra_field_used(gconf, oldval))
4122  free(oldval);
4123 }
4124 
4125 /*
4126  * Support for copying a variable's active value into a stack entry.
4127  * The "extra" field associated with the active value is copied, too.
4128  *
4129  * NB: be sure stringval and extra fields of a new stack entry are
4130  * initialized to NULL before this is used, else we'll try to free() them.
4131  */
4132 static void
4134 {
4135  switch (gconf->vartype)
4136  {
4137  case PGC_BOOL:
4138  val->val.boolval =
4139  *((struct config_bool *) gconf)->variable;
4140  break;
4141  case PGC_INT:
4142  val->val.intval =
4143  *((struct config_int *) gconf)->variable;
4144  break;
4145  case PGC_REAL:
4146  val->val.realval =
4147  *((struct config_real *) gconf)->variable;
4148  break;
4149  case PGC_STRING:
4150  set_string_field((struct config_string *) gconf,
4151  &(val->val.stringval),
4152  *((struct config_string *) gconf)->variable);
4153  break;
4154  case PGC_ENUM:
4155  val->val.enumval =
4156  *((struct config_enum *) gconf)->variable;
4157  break;
4158  }
4159  set_extra_field(gconf, &(val->extra), gconf->extra);
4160 }
4161 
4162 /*
4163  * Support for discarding a no-longer-needed value in a stack entry.
4164  * The "extra" field associated with the stack entry is cleared, too.
4165  */
4166 static void
4168 {
4169  switch (gconf->vartype)
4170  {
4171  case PGC_BOOL:
4172  case PGC_INT:
4173  case PGC_REAL:
4174  case PGC_ENUM:
4175  /* no need to do anything */
4176  break;
4177  case PGC_STRING:
4178  set_string_field((struct config_string *) gconf,
4179  &(val->val.stringval),
4180  NULL);
4181  break;
4182  }
4183  set_extra_field(gconf, &(val->extra), NULL);
4184 }
4185 
4186 
4187 /*
4188  * Fetch the sorted array pointer (exported for help_config.c's use ONLY)
4189  */
4190 struct config_generic **
4192 {
4193  return guc_variables;
4194 }
4195 
4196 
4197 /*
4198  * Build the sorted array. This is split out so that it could be
4199  * re-executed after startup (e.g., we could allow loadable modules to
4200  * add vars, and then we'd need to re-sort).
4201  */
4202 void
4204 {
4205  int size_vars;
4206  int num_vars = 0;
4207  struct config_generic **guc_vars;
4208  int i;
4209 
4210  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4211  {
4212  struct config_bool *conf = &ConfigureNamesBool[i];
4213 
4214  /* Rather than requiring vartype to be filled in by hand, do this: */
4215  conf->gen.vartype = PGC_BOOL;
4216  num_vars++;
4217  }
4218 
4219  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4220  {
4221  struct config_int *conf = &ConfigureNamesInt[i];
4222 
4223  conf->gen.vartype = PGC_INT;
4224  num_vars++;
4225  }
4226 
4227  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4228  {
4229  struct config_real *conf = &ConfigureNamesReal[i];
4230 
4231  conf->gen.vartype = PGC_REAL;
4232  num_vars++;
4233  }
4234 
4235  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4236  {
4237  struct config_string *conf = &ConfigureNamesString[i];
4238 
4239  conf->gen.vartype = PGC_STRING;
4240  num_vars++;
4241  }
4242 
4243  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4244  {
4245  struct config_enum *conf = &ConfigureNamesEnum[i];
4246 
4247  conf->gen.vartype = PGC_ENUM;
4248  num_vars++;
4249  }
4250 
4251  /*
4252  * Create table with 20% slack
4253  */
4254  size_vars = num_vars + num_vars / 4;
4255 
4256  guc_vars = (struct config_generic **)
4257  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
4258 
4259  num_vars = 0;
4260 
4261  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4262  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
4263 
4264  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4265  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
4266 
4267  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4268  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
4269 
4270  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4271  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
4272 
4273  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4274  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
4275 
4276  if (guc_variables)
4277  free(guc_variables);
4278  guc_variables = guc_vars;
4279  num_guc_variables = num_vars;
4280  size_guc_variables = size_vars;
4281  qsort((void *) guc_variables, num_guc_variables,
4282  sizeof(struct config_generic *), guc_var_compare);
4283 }
4284 
4285 /*
4286  * Add a new GUC variable to the list of known variables. The
4287  * list is expanded if needed.
4288  */
4289 static bool
4290 add_guc_variable(struct config_generic * var, int elevel)
4291 {
4292  if (num_guc_variables + 1 >= size_guc_variables)
4293  {
4294  /*
4295  * Increase the vector by 25%
4296  */
4297  int size_vars = size_guc_variables + size_guc_variables / 4;
4298  struct config_generic **guc_vars;
4299 
4300  if (size_vars == 0)
4301  {
4302  size_vars = 100;
4303  guc_vars = (struct config_generic **)
4304  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
4305  }
4306  else
4307  {
4308  guc_vars = (struct config_generic **)
4309  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
4310  }
4311 
4312  if (guc_vars == NULL)
4313  return false; /* out of memory */
4314 
4315  guc_variables = guc_vars;
4316  size_guc_variables = size_vars;
4317  }
4318  guc_variables[num_guc_variables++] = var;
4319  qsort((void *) guc_variables, num_guc_variables,
4320  sizeof(struct config_generic *), guc_var_compare);
4321  return true;
4322 }
4323 
4324 /*
4325  * Create and add a placeholder variable for a custom variable name.
4326  */
4327 static struct config_generic *
4328 add_placeholder_variable(const char *name, int elevel)
4329 {
4330  size_t sz = sizeof(struct config_string) + sizeof(char *);
4331  struct config_string *var;
4332  struct config_generic *gen;
4333 
4334  var = (struct config_string *) guc_malloc(elevel, sz);
4335  if (var == NULL)
4336  return NULL;
4337  memset(var, 0, sz);
4338  gen = &var->gen;
4339 
4340  gen->name = guc_strdup(elevel, name);
4341  if (gen->name == NULL)
4342  {
4343  free(var);
4344  return NULL;
4345  }
4346 
4347  gen->context = PGC_USERSET;
4348  gen->group = CUSTOM_OPTIONS;
4349  gen->short_desc = "GUC placeholder variable";
4351  gen->vartype = PGC_STRING;
4352 
4353  /*
4354  * The char* is allocated at the end of the struct since we have no
4355  * 'static' place to point to. Note that the current value, as well as
4356  * the boot and reset values, start out NULL.
4357  */
4358  var->variable = (char **) (var + 1);
4359 
4360  if (!add_guc_variable((struct config_generic *) var, elevel))
4361  {
4362  free((void *) gen->name);
4363  free(var);
4364  return NULL;
4365  }
4366 
4367  return gen;
4368 }
4369 
4370 /*
4371  * Look up option NAME. If it exists, return a pointer to its record,
4372  * else return NULL. If create_placeholders is TRUE, we'll create a
4373  * placeholder record for a valid-looking custom variable name.
4374  */
4375 static struct config_generic *
4376 find_option(const char *name, bool create_placeholders, int elevel)
4377 {
4378  const char **key = &name;
4379  struct config_generic **res;
4380  int i;
4381 
4382  Assert(name);
4383 
4384  /*
4385  * By equating const char ** with struct config_generic *, we are assuming
4386  * the name field is first in config_generic.
4387  */
4388  res = (struct config_generic **) bsearch((void *) &key,
4389  (void *) guc_variables,
4390  num_guc_variables,
4391  sizeof(struct config_generic *),
4392  guc_var_compare);
4393  if (res)
4394  return *res;
4395 
4396  /*
4397  * See if the name is an obsolete name for a variable. We assume that the
4398  * set of supported old names is short enough that a brute-force search is
4399  * the best way.
4400  */
4401  for (i = 0; map_old_guc_names[i] != NULL; i += 2)
4402  {
4403  if (guc_name_compare(name, map_old_guc_names[i]) == 0)
4404  return find_option(map_old_guc_names[i + 1], false, elevel);
4405  }
4406 
4407  if (create_placeholders)
4408  {
4409  /*
4410  * Check if the name is qualified, and if so, add a placeholder.
4411  */
4412  if (strchr(name, GUC_QUALIFIER_SEPARATOR) != NULL)
4413  return add_placeholder_variable(name, elevel);
4414  }
4415 
4416  /* Unknown name */
4417  return NULL;
4418 }
4419 
4420 
4421 /*
4422  * comparator for qsorting and bsearching guc_variables array
4423  */
4424 static int
4425 guc_var_compare(const void *a, const void *b)
4426 {
4427  const struct config_generic *confa = *(struct config_generic * const *) a;
4428  const struct config_generic *confb = *(struct config_generic * const *) b;
4429 
4430  return guc_name_compare(confa->name, confb->name);
4431 }
4432 
4433 /*
4434  * the bare comparison function for GUC names
4435  */
4436 static int
4437 guc_name_compare(const char *namea, const char *nameb)
4438 {
4439  /*
4440  * The temptation to use strcasecmp() here must be resisted, because the
4441  * array ordering has to remain stable across setlocale() calls. So, build
4442  * our own with a simple ASCII-only downcasing.
4443  */
4444  while (*namea && *nameb)
4445  {
4446  char cha = *namea++;
4447  char chb = *nameb++;
4448 
4449  if (cha >= 'A' && cha <= 'Z')
4450  cha += 'a' - 'A';
4451  if (chb >= 'A' && chb <= 'Z')
4452  chb += 'a' - 'A';
4453  if (cha != chb)
4454  return cha - chb;
4455  }
4456  if (*namea)
4457  return 1; /* a is longer */
4458  if (*nameb)
4459  return -1; /* b is longer */
4460  return 0;
4461 }
4462 
4463 
4464 /*
4465  * Initialize GUC options during program startup.
4466  *
4467  * Note that we cannot read the config file yet, since we have not yet
4468  * processed command-line switches.
4469  */
4470 void
4472 {
4473  int i;
4474 
4475  /*
4476  * Before log_line_prefix could possibly receive a nonempty setting, make
4477  * sure that timezone processing is minimally alive (see elog.c).
4478  */
4480 
4481  /*
4482  * Build sorted array of all GUC variables.
4483  */
4485 
4486  /*
4487  * Load all variables with their compiled-in defaults, and initialize
4488  * status fields as needed.
4489  */
4490  for (i = 0; i < num_guc_variables; i++)
4491  {
4492  InitializeOneGUCOption(guc_variables[i]);
4493  }
4494 
4495  guc_dirty = false;
4496 
4497  reporting_enabled = false;
4498 
4499  /*
4500  * Prevent any attempt to override the transaction modes from
4501  * non-interactive sources.
4502  */
4503  SetConfigOption("transaction_isolation", "default",
4505  SetConfigOption("transaction_read_only", "no",
4507  SetConfigOption("transaction_deferrable", "no",
4509 
4510  /*
4511  * For historical reasons, some GUC parameters can receive defaults from
4512  * environment variables. Process those settings.
4513  */
4515 }
4516 
4517 /*
4518  * Assign any GUC values that can come from the server's environment.
4519  *
4520  * This is called from InitializeGUCOptions, and also from ProcessConfigFile
4521  * to deal with the possibility that a setting has been removed from
4522  * postgresql.conf and should now get a value from the environment.
4523  * (The latter is a kludge that should probably go away someday; if so,
4524  * fold this back into InitializeGUCOptions.)
4525  */
4526 static void
4528 {
4529  char *env;
4530  long stack_rlimit;
4531 
4532  env = getenv("PGPORT");
4533  if (env != NULL)
4535 
4536  env = getenv("PGDATESTYLE");
4537  if (env != NULL)
4538  SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
4539 
4540  env = getenv("PGCLIENTENCODING");
4541  if (env != NULL)
4542  SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
4543 
4544  /*
4545  * rlimit isn't exactly an "environment variable", but it behaves about
4546  * the same. If we can identify the platform stack depth rlimit, increase
4547  * default stack depth setting up to whatever is safe (but at most 2MB).
4548  */
4549  stack_rlimit = get_stack_depth_rlimit();
4550  if (stack_rlimit > 0)
4551  {
4552  long new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;
4553 
4554  if (new_limit > 100)
4555  {
4556  char limbuf[16];
4557 
4558  new_limit = Min(new_limit, 2048);
4559  sprintf(limbuf, "%ld", new_limit);
4560  SetConfigOption("max_stack_depth", limbuf,
4562  }
4563  }
4564 }
4565 
4566 /*
4567  * Initialize one GUC option variable to its compiled-in default.
4568  *
4569  * Note: the reason for calling check_hooks is not that we think the boot_val
4570  * might fail, but that the hooks might wish to compute an "extra" struct.
4571  */
4572 static void
4574 {
4575  gconf->status = 0;
4576  gconf->source = PGC_S_DEFAULT;
4577  gconf->reset_source = PGC_S_DEFAULT;
4578  gconf->scontext = PGC_INTERNAL;
4579  gconf->reset_scontext = PGC_INTERNAL;
4580  gconf->stack = NULL;
4581  gconf->extra = NULL;
4582  gconf->sourcefile = NULL;
4583  gconf->sourceline = 0;
4584 
4585  switch (gconf->vartype)
4586  {
4587  case PGC_BOOL:
4588  {
4589  struct config_bool *conf = (struct config_bool *) gconf;
4590  bool newval = conf->boot_val;
4591  void *extra = NULL;
4592 
4593  if (!call_bool_check_hook(conf, &newval, &extra,
4594  PGC_S_DEFAULT, LOG))
4595  elog(FATAL, "failed to initialize %s to %d",
4596  conf->gen.name, (int) newval);
4597  if (conf->assign_hook)
4598  (*conf->assign_hook) (newval, extra);
4599  *conf->variable = conf->reset_val = newval;
4600  conf->gen.extra = conf->reset_extra = extra;
4601  break;
4602  }
4603  case PGC_INT:
4604  {
4605  struct config_int *conf = (struct config_int *) gconf;
4606  int newval = conf->boot_val;
4607  void *extra = NULL;
4608 
4609  Assert(newval >= conf->min);
4610  Assert(newval <= conf->max);
4611  if (!call_int_check_hook(conf, &newval, &extra,
4612  PGC_S_DEFAULT, LOG))
4613  elog(FATAL, "failed to initialize %s to %d",
4614  conf->gen.name, newval);
4615  if (conf->assign_hook)
4616  (*conf->assign_hook) (newval, extra);
4617  *conf->variable = conf->reset_val = newval;
4618  conf->gen.extra = conf->reset_extra = extra;
4619  break;
4620  }
4621  case PGC_REAL:
4622  {
4623  struct config_real *conf = (struct config_real *) gconf;
4624  double newval = conf->boot_val;
4625  void *extra = NULL;
4626 
4627  Assert(newval >= conf->min);
4628  Assert(newval <= conf->max);
4629  if (!call_real_check_hook(conf, &newval, &extra,
4630  PGC_S_DEFAULT, LOG))
4631  elog(FATAL, "failed to initialize %s to %g",
4632  conf->gen.name, newval);
4633  if (conf->assign_hook)
4634  (*conf->assign_hook) (newval, extra);
4635  *conf->variable = conf->reset_val = newval;
4636  conf->gen.extra = conf->reset_extra = extra;
4637  break;
4638  }
4639  case PGC_STRING:
4640  {
4641  struct config_string *conf = (struct config_string *) gconf;
4642  char *newval;
4643  void *extra = NULL;
4644 
4645  /* non-NULL boot_val must always get strdup'd */
4646  if (conf->boot_val != NULL)
4647  newval = guc_strdup(FATAL, conf->boot_val);
4648  else
4649  newval = NULL;
4650 
4651  if (!call_string_check_hook(conf, &newval, &extra,
4652  PGC_S_DEFAULT, LOG))
4653  elog(FATAL, "failed to initialize %s to \"%s\"",
4654  conf->gen.name, newval ? newval : "");
4655  if (conf->assign_hook)
4656  (*conf->assign_hook) (newval, extra);
4657  *conf->variable = conf->reset_val = newval;
4658  conf->gen.extra = conf->reset_extra = extra;
4659  break;
4660  }
4661  case PGC_ENUM:
4662  {
4663  struct config_enum *conf = (struct config_enum *) gconf;
4664  int newval = conf->boot_val;
4665  void *extra = NULL;
4666 
4667  if (!call_enum_check_hook(conf, &newval, &extra,
4668  PGC_S_DEFAULT, LOG))
4669  elog(FATAL, "failed to initialize %s to %d",
4670  conf->gen.name, newval);
4671  if (conf->assign_hook)
4672  (*conf->assign_hook) (newval, extra);
4673  *conf->variable = conf->reset_val = newval;
4674  conf->gen.extra = conf->reset_extra = extra;
4675  break;
4676  }
4677  }
4678 }
4679 
4680 
4681 /*
4682  * Select the configuration files and data directory to be used, and
4683  * do the initial read of postgresql.conf.
4684  *
4685  * This is called after processing command-line switches.
4686  * userDoption is the -D switch value if any (NULL if unspecified).
4687  * progname is just for use in error messages.
4688  *
4689  * Returns true on success; on failure, prints a suitable error message
4690  * to stderr and returns false.
4691  */
4692 bool
4693 SelectConfigFiles(const char *userDoption, const char *progname)
4694 {
4695  char *configdir;
4696  char *fname;
4697  struct stat stat_buf;
4698 
4699  /* configdir is -D option, or $PGDATA if no -D */
4700  if (userDoption)
4701  configdir = make_absolute_path(userDoption);
4702  else
4703  configdir = make_absolute_path(getenv("PGDATA"));
4704 
4705  if (configdir && stat(configdir, &stat_buf) != 0)
4706  {
4707  write_stderr("%s: could not access directory \"%s\": %s\n",
4708  progname,
4709  configdir,
4710  strerror(errno));
4711  if (errno == ENOENT)
4712  write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
4713  return false;
4714  }
4715 
4716  /*
4717  * Find the configuration file: if config_file was specified on the
4718  * command line, use it, else use configdir/postgresql.conf. In any case
4719  * ensure the result is an absolute path, so that it will be interpreted
4720  * the same way by future backends.
4721  */
4722  if (ConfigFileName)
4723  fname = make_absolute_path(ConfigFileName);
4724  else if (configdir)
4725  {
4726  fname = guc_malloc(FATAL,
4727  strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
4728  sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
4729  }
4730  else
4731  {
4732  write_stderr("%s does not know where to find the server configuration file.\n"
4733  "You must specify the --config-file or -D invocation "
4734  "option or set the PGDATA environment variable.\n",
4735  progname);
4736  return false;
4737  }
4738 
4739  /*
4740  * Set the ConfigFileName GUC variable to its final value, ensuring that
4741  * it can't be overridden later.
4742  */
4743  SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4744  free(fname);
4745 
4746  /*
4747  * Now read the config file for the first time.
4748  */
4749  if (stat(ConfigFileName, &stat_buf) != 0)
4750  {
4751  write_stderr("%s: could not access the server configuration file \"%s\": %s\n",
4752  progname, ConfigFileName, strerror(errno));
4753  free(configdir);
4754  return false;
4755  }
4756 
4757  /*
4758  * Read the configuration file for the first time. This time only the
4759  * data_directory parameter is picked up to determine the data directory,
4760  * so that we can read the PG_AUTOCONF_FILENAME file next time.
4761  */
4763 
4764  /*
4765  * If the data_directory GUC variable has been set, use that as DataDir;
4766  * otherwise use configdir if set; else punt.
4767  *
4768  * Note: SetDataDir will copy and absolute-ize its argument, so we don't
4769  * have to.
4770  */
4771  if (data_directory)
4772  SetDataDir(data_directory);
4773  else if (configdir)
4774  SetDataDir(configdir);
4775  else
4776  {
4777  write_stderr("%s does not know where to find the database system data.\n"
4778  "This can be specified as \"data_directory\" in \"%s\", "
4779  "or by the -D invocation option, or by the "
4780  "PGDATA environment variable.\n",
4781  progname, ConfigFileName);
4782  return false;
4783  }
4784 
4785  /*
4786  * Reflect the final DataDir value back into the data_directory GUC var.
4787  * (If you are wondering why we don't just make them a single variable,
4788  * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
4789  * child backends specially. XXX is that still true? Given that we now
4790  * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
4791  * DataDir in advance.)
4792  */
4794 
4795  /*
4796  * Now read the config file a second time, allowing any settings in the
4797  * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but
4798  * since we have to determine the DataDir before we can find the autoconf
4799  * file, the alternatives seem worse.)
4800  */
4802 
4803  /*
4804  * If timezone_abbreviations wasn't set in the configuration file, install
4805  * the default value. We do it this way because we can't safely install a
4806  * "real" value until my_exec_path is set, which may not have happened
4807  * when InitializeGUCOptions runs, so the bootstrap default value cannot
4808  * be the real desired default.
4809  */
4811 
4812  /*
4813  * Figure out where pg_hba.conf is, and make sure the path is absolute.
4814  */
4815  if (HbaFileName)
4816  fname = make_absolute_path(HbaFileName);
4817  else if (configdir)
4818  {
4819  fname = guc_malloc(FATAL,
4820  strlen(configdir) + strlen(HBA_FILENAME) + 2);
4821  sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
4822  }
4823  else
4824  {
4825  write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
4826  "This can be specified as \"hba_file\" in \"%s\", "
4827  "or by the -D invocation option, or by the "
4828  "PGDATA environment variable.\n",
4829  progname, ConfigFileName);
4830  return false;
4831  }
4832  SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4833  free(fname);
4834 
4835  /*
4836  * Likewise for pg_ident.conf.
4837  */
4838  if (IdentFileName)
4839  fname = make_absolute_path(IdentFileName);
4840  else if (configdir)
4841  {
4842  fname = guc_malloc(FATAL,
4843  strlen(configdir) + strlen(IDENT_FILENAME) + 2);
4844  sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
4845  }
4846  else
4847  {
4848  write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
4849  "This can be specified as \"ident_file\" in \"%s\", "
4850  "or by the -D invocation option, or by the "
4851  "PGDATA environment variable.\n",
4852  progname, ConfigFileName);
4853  return false;
4854  }
4855  SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4856  free(fname);
4857 
4858  free(configdir);
4859 
4860  return true;
4861 }
4862 
4863 
4864 /*
4865  * Reset all options to their saved default values (implements RESET ALL)
4866  */
4867 void
4869 {
4870  int i;
4871 
4872  for (i = 0; i < num_guc_variables; i++)
4873  {
4874  struct config_generic *gconf = guc_variables[i];
4875 
4876  /* Don't reset non-SET-able values */
4877  if (gconf->context != PGC_SUSET &&
4878  gconf->context != PGC_USERSET)
4879  continue;
4880  /* Don't reset if special exclusion from RESET ALL */
4881  if (gconf->flags & GUC_NO_RESET_ALL)
4882  continue;
4883  /* No need to reset if wasn't SET */
4884  if (gconf->source <= PGC_S_OVERRIDE)
4885  continue;
4886 
4887  /* Save old value to support transaction abort */
4889 
4890  switch (gconf->vartype)
4891  {
4892  case PGC_BOOL:
4893  {
4894  struct config_bool *conf = (struct config_bool *) gconf;
4895 
4896  if (conf->assign_hook)
4897  (*conf->assign_hook) (conf->reset_val,
4898  conf->reset_extra);
4899  *conf->variable = conf->reset_val;
4900  set_extra_field(&conf->gen, &conf->gen.extra,
4901  conf->reset_extra);
4902  break;
4903  }
4904  case PGC_INT:
4905  {
4906  struct config_int *conf = (struct config_int *) gconf;
4907 
4908  if (conf->assign_hook)
4909  (*conf->assign_hook) (conf->reset_val,
4910  conf->reset_extra);
4911  *conf->variable = conf->reset_val;
4912  set_extra_field(&conf->gen, &conf->gen.extra,
4913  conf->reset_extra);
4914  break;
4915  }
4916  case PGC_REAL:
4917  {
4918  struct config_real *conf = (struct config_real *) gconf;
4919 
4920  if (conf->assign_hook)
4921  (*conf->assign_hook) (conf->reset_val,
4922  conf->reset_extra);
4923  *conf->variable = conf->reset_val;
4924  set_extra_field(&conf->gen, &conf->gen.extra,
4925  conf->reset_extra);
4926  break;
4927  }
4928  case PGC_STRING:
4929  {
4930  struct config_string *conf = (struct config_string *) gconf;
4931 
4932  if (conf->assign_hook)
4933  (*conf->assign_hook) (conf->reset_val,
4934  conf->reset_extra);
4935  set_string_field(conf, conf->variable, conf->reset_val);
4936  set_extra_field(&conf->gen, &conf->gen.extra,
4937  conf->reset_extra);
4938  break;
4939  }
4940  case PGC_ENUM:
4941  {
4942  struct config_enum *conf = (struct config_enum *) gconf;
4943 
4944  if (conf->assign_hook)
4945  (*conf->assign_hook) (conf->reset_val,
4946  conf->reset_extra);
4947  *conf->variable = conf->reset_val;
4948  set_extra_field(&conf->gen, &conf->gen.extra,
4949  conf->reset_extra);
4950  break;
4951  }
4952  }
4953 
4954  gconf->source = gconf->reset_source;
4955  gconf->scontext = gconf->reset_scontext;
4956 
4957  if (gconf->flags & GUC_REPORT)
4958  ReportGUCOption(gconf);
4959  }
4960 }
4961 
4962 
4963 /*
4964  * push_old_value
4965  * Push previous state during transactional assignment to a GUC variable.
4966  */
4967 static void
4968 push_old_value(struct config_generic * gconf, GucAction action)
4969 {
4970  GucStack *stack;
4971 
4972  /* If we're not inside a nest level, do nothing */
4973  if (GUCNestLevel == 0)
4974  return;
4975 
4976  /* Do we already have a stack entry of the current nest level? */
4977  stack = gconf->stack;
4978  if (stack && stack->nest_level >= GUCNestLevel)
4979  {
4980  /* Yes, so adjust its state if necessary */
4981  Assert(stack->nest_level == GUCNestLevel);
4982  switch (action)
4983  {
4984  case GUC_ACTION_SET:
4985  /* SET overrides any prior action at same nest level */
4986  if (stack->state == GUC_SET_LOCAL)
4987  {
4988  /* must discard old masked value */
4989  discard_stack_value(gconf, &stack->masked);
4990  }
4991  stack->state = GUC_SET;
4992  break;
4993  case GUC_ACTION_LOCAL:
4994  if (stack->state == GUC_SET)
4995  {
4996  /* SET followed by SET LOCAL, remember SET's value */
4997  stack->masked_scontext = gconf->scontext;
4998  set_stack_value(gconf, &stack->masked);
4999  stack->state = GUC_SET_LOCAL;
5000  }
5001  /* in all other cases, no change to stack entry */
5002  break;
5003  case GUC_ACTION_SAVE:
5004  /* Could only have a prior SAVE of same variable */
5005  Assert(stack->state == GUC_SAVE);
5006  break;
5007  }
5008  Assert(guc_dirty); /* must be set already */
5009  return;
5010  }
5011 
5012  /*
5013  * Push a new stack entry
5014  *
5015  * We keep all the stack entries in TopTransactionContext for simplicity.
5016  */
5018  sizeof(GucStack));
5019 
5020  stack->prev = gconf->stack;
5021  stack->nest_level = GUCNestLevel;
5022  switch (action)
5023  {
5024  case GUC_ACTION_SET:
5025  stack->state = GUC_SET;
5026  break;
5027  case GUC_ACTION_LOCAL:
5028  stack->state = GUC_LOCAL;
5029  break;
5030  case GUC_ACTION_SAVE:
5031  stack->state = GUC_SAVE;
5032  break;
5033  }
5034  stack->source = gconf->source;
5035  stack->scontext = gconf->scontext;
5036  set_stack_value(gconf, &stack->prior);
5037 
5038  gconf->stack = stack;
5039 
5040  /* Ensure we remember to pop at end of xact */
5041  guc_dirty = true;
5042 }
5043 
5044 
5045 /*
5046  * Do GUC processing at main transaction start.
5047  */
5048 void
5050 {
5051  /*
5052  * The nest level should be 0 between transactions; if it isn't, somebody
5053  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
5054  * throw a warning but make no other effort to clean up.
5055  */
5056  if (GUCNestLevel != 0)
5057  elog(WARNING, "GUC nest level = %d at transaction start",
5058  GUCNestLevel);
5059  GUCNestLevel = 1;
5060 }
5061 
5062 /*
5063  * Enter a new nesting level for GUC values. This is called at subtransaction
5064  * start, and when entering a function that has proconfig settings, and in
5065  * some other places where we want to set GUC variables transiently.
5066  * NOTE we must not risk error here, else subtransaction start will be unhappy.
5067  */
5068 int
5070 {
5071  return ++GUCNestLevel;
5072 }
5073 
5074 /*
5075  * Do GUC processing at transaction or subtransaction commit or abort, or
5076  * when exiting a function that has proconfig settings, or when undoing a
5077  * transient assignment to some GUC variables. (The name is thus a bit of
5078  * a misnomer; perhaps it should be ExitGUCNestLevel or some such.)
5079  * During abort, we discard all GUC settings that were applied at nesting
5080  * levels >= nestLevel. nestLevel == 1 corresponds to the main transaction.
5081  */
5082 void
5083 AtEOXact_GUC(bool isCommit, int nestLevel)
5084 {
5085  bool still_dirty;
5086  int i;
5087 
5088  /*
5089  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
5090  * abort, if there is a failure during transaction start before
5091  * AtStart_GUC is called.
5092  */
5093  Assert(nestLevel > 0 &&
5094  (nestLevel <= GUCNestLevel ||
5095  (nestLevel == GUCNestLevel + 1 && !isCommit)));
5096 
5097  /* Quick exit if nothing's changed in this transaction */
5098  if (!guc_dirty)
5099  {
5100  GUCNestLevel = nestLevel - 1;
5101  return;
5102  }
5103 
5104  still_dirty = false;
5105  for (i = 0; i < num_guc_variables; i++)
5106  {
5107  struct config_generic *gconf = guc_variables[i];
5108  GucStack *stack;
5109 
5110  /*
5111  * Process and pop each stack entry within the nest level. To simplify
5112  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
5113  * we allow failure exit from code that uses a local nest level to be
5114  * recovered at the surrounding transaction or subtransaction abort;
5115  * so there could be more than one stack entry to pop.
5116  */
5117  while ((stack = gconf->stack) != NULL &&
5118  stack->nest_level >= nestLevel)
5119  {
5120  GucStack *prev = stack->prev;
5121  bool restorePrior = false;
5122  bool restoreMasked = false;
5123  bool changed;
5124 
5125  /*
5126  * In this next bit, if we don't set either restorePrior or
5127  * restoreMasked, we must "discard" any unwanted fields of the
5128  * stack entries to avoid leaking memory. If we do set one of
5129  * those flags, unused fields will be cleaned up after restoring.
5130  */
5131  if (!isCommit) /* if abort, always restore prior value */
5132  restorePrior = true;
5133  else if (stack->state == GUC_SAVE)
5134  restorePrior = true;
5135  else if (stack->nest_level == 1)
5136  {
5137  /* transaction commit */
5138  if (stack->state == GUC_SET_LOCAL)
5139  restoreMasked = true;
5140  else if (stack->state == GUC_SET)
5141  {
5142  /* we keep the current active value */
5143  discard_stack_value(gconf, &stack->prior);
5144  }
5145  else /* must be GUC_LOCAL */
5146  restorePrior = true;
5147  }
5148  else if (prev == NULL ||
5149  prev->nest_level < stack->nest_level - 1)
5150  {
5151  /* decrement entry's level and do not pop it */
5152  stack->nest_level--;
5153  continue;
5154  }
5155  else
5156  {
5157  /*
5158  * We have to merge this stack entry into prev. See README for
5159  * discussion of this bit.
5160  */
5161  switch (stack->state)
5162  {
5163  case GUC_SAVE:
5164  Assert(false); /* can't get here */
5165 
5166  case GUC_SET:
5167  /* next level always becomes SET */
5168  discard_stack_value(gconf, &stack->prior);
5169  if (prev->state == GUC_SET_LOCAL)
5170  discard_stack_value(gconf, &prev->masked);
5171  prev->state = GUC_SET;
5172  break;
5173 
5174  case GUC_LOCAL:
5175  if (prev->state == GUC_SET)
5176  {
5177  /* LOCAL migrates down */
5178  prev->masked_scontext = stack->scontext;
5179  prev->masked = stack->prior;
5180  prev->state = GUC_SET_LOCAL;
5181  }
5182  else
5183  {
5184  /* else just forget this stack level */
5185  discard_stack_value(gconf, &stack->prior);
5186  }
5187  break;
5188 
5189  case GUC_SET_LOCAL:
5190  /* prior state at this level no longer wanted */
5191  discard_stack_value(gconf, &stack->prior);
5192  /* copy down the masked state */
5193  prev->masked_scontext = stack->masked_scontext;
5194  if (prev->state == GUC_SET_LOCAL)
5195  discard_stack_value(gconf, &prev->masked);
5196  prev->masked = stack->masked;
5197  prev->state = GUC_SET_LOCAL;
5198  break;
5199  }
5200  }
5201 
5202  changed = false;
5203 
5204  if (restorePrior || restoreMasked)
5205  {
5206  /* Perform appropriate restoration of the stacked value */
5207  config_var_value newvalue;
5208  GucSource newsource;
5209  GucContext newscontext;
5210 
5211  if (restoreMasked)
5212  {
5213  newvalue = stack->masked;
5214  newsource = PGC_S_SESSION;
5215  newscontext = stack->masked_scontext;
5216  }
5217  else
5218  {
5219  newvalue = stack->prior;
5220  newsource = stack->source;
5221  newscontext = stack->scontext;
5222  }
5223 
5224  switch (gconf->vartype)
5225  {
5226  case PGC_BOOL:
5227  {
5228  struct config_bool *conf = (struct config_bool *) gconf;
5229  bool newval = newvalue.val.boolval;
5230  void *newextra = newvalue.extra;
5231 
5232  if (*conf->variable != newval ||
5233  conf->gen.extra != newextra)
5234  {
5235  if (conf->assign_hook)
5236  (*conf->assign_hook) (newval, newextra);
5237  *conf->variable = newval;
5238  set_extra_field(&conf->gen, &conf->gen.extra,
5239  newextra);
5240  changed = true;
5241  }
5242  break;
5243  }
5244  case PGC_INT:
5245  {
5246  struct config_int *conf = (struct config_int *) gconf;
5247  int newval = newvalue.val.intval;
5248  void *newextra = newvalue.extra;
5249 
5250  if (*conf->variable != newval ||
5251  conf->gen.extra != newextra)
5252  {
5253  if (conf->assign_hook)
5254  (*conf->assign_hook) (newval, newextra);
5255  *conf->variable = newval;
5256  set_extra_field(&conf->gen, &conf->gen.extra,
5257  newextra);
5258  changed = true;
5259  }
5260  break;
5261  }
5262  case PGC_REAL:
5263  {
5264  struct config_real *conf = (struct config_real *) gconf;
5265  double newval = newvalue.val.realval;
5266  void *newextra = newvalue.extra;
5267 
5268  if (*conf->variable != newval ||
5269  conf->gen.extra != newextra)
5270  {
5271  if (conf->assign_hook)
5272  (*conf->assign_hook) (newval, newextra);
5273  *conf->variable = newval;
5274  set_extra_field(&conf->gen, &conf->gen.extra,
5275  newextra);
5276  changed = true;
5277  }
5278  break;
5279  }
5280  case PGC_STRING:
5281  {
5282  struct config_string *conf = (struct config_string *) gconf;
5283  char *newval = newvalue.val.stringval;
5284  void *newextra = newvalue.extra;
5285 
5286  if (*conf->variable != newval ||
5287  conf->gen.extra != newextra)
5288  {
5289  if (conf->assign_hook)
5290  (*conf->assign_hook) (newval, newextra);
5291  set_string_field(conf, conf->variable, newval);
5292  set_extra_field(&conf->gen, &conf->gen.extra,
5293  newextra);
5294  changed = true;
5295  }
5296 
5297  /*
5298  * Release stacked values if not used anymore. We
5299  * could use discard_stack_value() here, but since
5300  * we have type-specific code anyway, might as
5301  * well inline it.
5302  */
5303  set_string_field(conf, &stack->prior.val.stringval, NULL);
5304  set_string_field(conf, &stack->masked.val.stringval, NULL);
5305  break;
5306  }
5307  case PGC_ENUM:
5308  {
5309  struct config_enum *conf = (struct config_enum *) gconf;
5310  int newval = newvalue.val.enumval;
5311  void *newextra = newvalue.extra;
5312 
5313  if (*conf->variable != newval ||
5314  conf->gen.extra != newextra)
5315  {
5316  if (conf->assign_hook)
5317  (*conf->assign_hook) (newval, newextra);
5318  *conf->variable = newval;
5319  set_extra_field(&conf->gen, &conf->gen.extra,
5320  newextra);
5321  changed = true;
5322  }
5323  break;
5324  }
5325  }
5326 
5327  /*
5328  * Release stacked extra values if not used anymore.
5329  */
5330  set_extra_field(gconf, &(stack->prior.extra), NULL);
5331  set_extra_field(gconf, &(stack->masked.extra), NULL);
5332 
5333  /* And restore source information */
5334  gconf->source = newsource;
5335  gconf->scontext = newscontext;
5336  }
5337 
5338  /* Finish popping the state stack */
5339  gconf->stack = prev;
5340  pfree(stack);
5341 
5342  /* Report new value if we changed it */
5343  if (changed && (gconf->flags & GUC_REPORT))
5344  ReportGUCOption(gconf);
5345  } /* end of stack-popping loop */
5346 
5347  if (stack != NULL)
5348  still_dirty = true;
5349  }
5350 
5351  /* If there are no remaining stack entries, we can reset guc_dirty */
5352  guc_dirty = still_dirty;
5353 
5354  /* Update nesting level */
5355  GUCNestLevel = nestLevel - 1;
5356 }
5357 
5358 
5359 /*
5360  * Start up automatic reporting of changes to variables marked GUC_REPORT.
5361  * This is executed at completion of backend startup.
5362  */
5363 void
5365 {
5366  int i;
5367 
5368  /*
5369  * Don't do anything unless talking to an interactive frontend of protocol
5370  * 3.0 or later.
5371  */
5372  if (whereToSendOutput !=