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