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