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