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