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