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