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