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