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-2017, 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  {
925  {"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
926  gettext_noop("Enables genetic query optimization."),
927  gettext_noop("This algorithm attempts to do planning without "
928  "exhaustive searching.")
929  },
930  &enable_geqo,
931  true,
932  NULL, NULL, NULL
933  },
934  {
935  /* Not for general use --- used by SET SESSION AUTHORIZATION */
936  {"is_superuser", PGC_INTERNAL, UNGROUPED,
937  gettext_noop("Shows whether the current user is a superuser."),
938  NULL,
940  },
942  false,
943  NULL, NULL, NULL
944  },
945  {
946  {"bonjour", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
947  gettext_noop("Enables advertising the server via Bonjour."),
948  NULL
949  },
951  false,
952  check_bonjour, NULL, NULL
953  },
954  {
955  {"track_commit_timestamp", PGC_POSTMASTER, REPLICATION,
956  gettext_noop("Collects transaction commit time."),
957  NULL
958  },
960  false,
961  NULL, NULL, NULL
962  },
963  {
965  gettext_noop("Enables SSL connections."),
966  NULL
967  },
968  &EnableSSL,
969  false,
970  check_ssl, NULL, NULL
971  },
972  {
973  {"ssl_prefer_server_ciphers", PGC_SIGHUP, CONN_AUTH_SECURITY,
974  gettext_noop("Give priority to server ciphersuite order."),
975  NULL
976  },
978  true,
979  NULL, NULL, NULL
980  },
981  {
982  {"fsync", PGC_SIGHUP, WAL_SETTINGS,
983  gettext_noop("Forces synchronization of updates to disk."),
984  gettext_noop("The server will use the fsync() system call in several places to make "
985  "sure that updates are physically written to disk. This insures "
986  "that a database cluster will recover to a consistent state after "
987  "an operating system or hardware crash.")
988  },
989  &enableFsync,
990  true,
991  NULL, NULL, NULL
992  },
993  {
994  {"ignore_checksum_failure", PGC_SUSET, DEVELOPER_OPTIONS,
995  gettext_noop("Continues processing after a checksum failure."),
996  gettext_noop("Detection of a checksum failure normally causes PostgreSQL to "
997  "report an error, aborting the current transaction. Setting "
998  "ignore_checksum_failure to true causes the system to ignore the failure "
999  "(but still report a warning), and continue processing. This "
1000  "behavior could cause crashes or other serious problems. Only "
1001  "has an effect if checksums are enabled."),
1003  },
1005  false,
1006  NULL, NULL, NULL
1007  },
1008  {
1009  {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS,
1010  gettext_noop("Continues processing past damaged page headers."),
1011  gettext_noop("Detection of a damaged page header normally causes PostgreSQL to "
1012  "report an error, aborting the current transaction. Setting "
1013  "zero_damaged_pages to true causes the system to instead report a "
1014  "warning, zero out the damaged page, and continue processing. This "
1015  "behavior will destroy data, namely all the rows on the damaged page."),
1017  },
1019  false,
1020  NULL, NULL, NULL
1021  },
1022  {
1023  {"full_page_writes", PGC_SIGHUP, WAL_SETTINGS,
1024  gettext_noop("Writes full pages to WAL when first modified after a checkpoint."),
1025  gettext_noop("A page write in process during an operating system crash might be "
1026  "only partially written to disk. During recovery, the row changes "
1027  "stored in WAL are not enough to recover. This option writes "
1028  "pages when first modified after a checkpoint to WAL so full recovery "
1029  "is possible.")
1030  },
1031  &fullPageWrites,
1032  true,
1033  NULL, NULL, NULL
1034  },
1035 
1036  {
1037  {"wal_log_hints", PGC_POSTMASTER, WAL_SETTINGS,
1038  gettext_noop("Writes full pages to WAL when first modified after a checkpoint, even for a non-critical modifications."),
1039  NULL
1040  },
1041  &wal_log_hints,
1042  false,
1043  NULL, NULL, NULL
1044  },
1045 
1046  {
1047  {"wal_compression", PGC_SUSET, WAL_SETTINGS,
1048  gettext_noop("Compresses full-page writes written in WAL file."),
1049  NULL
1050  },
1051  &wal_compression,
1052  false,
1053  NULL, NULL, NULL
1054  },
1055 
1056  {
1057  {"log_checkpoints", PGC_SIGHUP, LOGGING_WHAT,
1058  gettext_noop("Logs each checkpoint."),
1059  NULL
1060  },
1061  &log_checkpoints,
1062  false,
1063  NULL, NULL, NULL
1064  },
1065  {
1066  {"log_connections", PGC_SU_BACKEND, LOGGING_WHAT,
1067  gettext_noop("Logs each successful connection."),
1068  NULL
1069  },
1070  &Log_connections,
1071  false,
1072  NULL, NULL, NULL
1073  },
1074  {
1075  {"log_disconnections", PGC_SU_BACKEND, LOGGING_WHAT,
1076  gettext_noop("Logs end of a session, including duration."),
1077  NULL
1078  },
1080  false,
1081  NULL, NULL, NULL
1082  },
1083  {
1084  {"log_replication_commands", PGC_SUSET, LOGGING_WHAT,
1085  gettext_noop("Logs each replication command."),
1086  NULL
1087  },
1089  false,
1090  NULL, NULL, NULL
1091  },
1092  {
1093  {"debug_assertions", PGC_INTERNAL, PRESET_OPTIONS,
1094  gettext_noop("Shows whether the running server has assertion checks enabled."),
1095  NULL,
1097  },
1098  &assert_enabled,
1099 #ifdef USE_ASSERT_CHECKING
1100  true,
1101 #else
1102  false,
1103 #endif
1104  NULL, NULL, NULL
1105  },
1106 
1107  {
1108  {"exit_on_error", PGC_USERSET, ERROR_HANDLING_OPTIONS,
1109  gettext_noop("Terminate session on any error."),
1110  NULL
1111  },
1112  &ExitOnAnyError,
1113  false,
1114  NULL, NULL, NULL
1115  },
1116  {
1117  {"restart_after_crash", PGC_SIGHUP, ERROR_HANDLING_OPTIONS,
1118  gettext_noop("Reinitialize server after backend crash."),
1119  NULL
1120  },
1122  true,
1123  NULL, NULL, NULL
1124  },
1125 
1126  {
1127  {"log_duration", PGC_SUSET, LOGGING_WHAT,
1128  gettext_noop("Logs the duration of each completed SQL statement."),
1129  NULL
1130  },
1131  &log_duration,
1132  false,
1133  NULL, NULL, NULL
1134  },
1135  {
1136  {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
1137  gettext_noop("Logs each query's parse tree."),
1138  NULL
1139  },
1141  false,
1142  NULL, NULL, NULL
1143  },
1144  {
1145  {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
1146  gettext_noop("Logs each query's rewritten parse tree."),
1147  NULL
1148  },
1150  false,
1151  NULL, NULL, NULL
1152  },
1153  {
1154  {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
1155  gettext_noop("Logs each query's execution plan."),
1156  NULL
1157  },
1159  false,
1160  NULL, NULL, NULL
1161  },
1162  {
1163  {"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
1164  gettext_noop("Indents parse and plan tree displays."),
1165  NULL
1166  },
1168  true,
1169  NULL, NULL, NULL
1170  },
1171  {
1172  {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
1173  gettext_noop("Writes parser performance statistics to the server log."),
1174  NULL
1175  },
1177  false,
1178  check_stage_log_stats, NULL, NULL
1179  },
1180  {
1181  {"log_planner_stats", PGC_SUSET, STATS_MONITORING,
1182  gettext_noop("Writes planner performance statistics to the server log."),
1183  NULL
1184  },
1186  false,
1187  check_stage_log_stats, NULL, NULL
1188  },
1189  {
1190  {"log_executor_stats", PGC_SUSET, STATS_MONITORING,
1191  gettext_noop("Writes executor performance statistics to the server log."),
1192  NULL
1193  },
1195  false,
1196  check_stage_log_stats, NULL, NULL
1197  },
1198  {
1199  {"log_statement_stats", PGC_SUSET, STATS_MONITORING,
1200  gettext_noop("Writes cumulative performance statistics to the server log."),
1201  NULL
1202  },
1204  false,
1205  check_log_stats, NULL, NULL
1206  },
1207 #ifdef BTREE_BUILD_STATS
1208  {
1209  {"log_btree_build_stats", PGC_SUSET, DEVELOPER_OPTIONS,
1210  gettext_noop("Logs system resource usage statistics (memory and CPU) on various B-tree operations."),
1211  NULL,
1213  },
1215  false,
1216  NULL, NULL, NULL
1217  },
1218 #endif
1219 
1220  {
1221  {"track_activities", PGC_SUSET, STATS_COLLECTOR,
1222  gettext_noop("Collects information about executing commands."),
1223  gettext_noop("Enables the collection of information on the currently "
1224  "executing command of each session, along with "
1225  "the time at which that command began execution.")
1226  },
1228  true,
1229  NULL, NULL, NULL
1230  },
1231  {
1232  {"track_counts", PGC_SUSET, STATS_COLLECTOR,
1233  gettext_noop("Collects statistics on database activity."),
1234  NULL
1235  },
1237  true,
1238  NULL, NULL, NULL
1239  },
1240  {
1241  {"track_io_timing", PGC_SUSET, STATS_COLLECTOR,
1242  gettext_noop("Collects timing statistics for database I/O activity."),
1243  NULL
1244  },
1245  &track_io_timing,
1246  false,
1247  NULL, NULL, NULL
1248  },
1249 
1250  {
1251  {"update_process_title", PGC_SUSET, PROCESS_TITLE,
1252  gettext_noop("Updates the process title to show the active SQL command."),
1253  gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.")
1254  },
1256 #ifdef WIN32
1257  false,
1258 #else
1259  true,
1260 #endif
1261  NULL, NULL, NULL
1262  },
1263 
1264  {
1265  {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
1266  gettext_noop("Starts the autovacuum subprocess."),
1267  NULL
1268  },
1270  true,
1271  NULL, NULL, NULL
1272  },
1273 
1274  {
1275  {"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
1276  gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
1277  NULL,
1279  },
1280  &Trace_notify,
1281  false,
1282  NULL, NULL, NULL
1283  },
1284 
1285 #ifdef LOCK_DEBUG
1286  {
1287  {"trace_locks", PGC_SUSET, DEVELOPER_OPTIONS,
1288  gettext_noop("Emits information about lock usage."),
1289  NULL,
1291  },
1292  &Trace_locks,
1293  false,
1294  NULL, NULL, NULL
1295  },
1296  {
1297  {"trace_userlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1298  gettext_noop("Emits information about user lock usage."),
1299  NULL,
1301  },
1302  &Trace_userlocks,
1303  false,
1304  NULL, NULL, NULL
1305  },
1306  {
1307  {"trace_lwlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1308  gettext_noop("Emits information about lightweight lock usage."),
1309  NULL,
1311  },
1312  &Trace_lwlocks,
1313  false,
1314  NULL, NULL, NULL
1315  },
1316  {
1317  {"debug_deadlocks", PGC_SUSET, DEVELOPER_OPTIONS,
1318  gettext_noop("Dumps information about all current locks when a deadlock timeout occurs."),
1319  NULL,
1321  },
1322  &Debug_deadlocks,
1323  false,
1324  NULL, NULL, NULL
1325  },
1326 #endif
1327 
1328  {
1329  {"log_lock_waits", PGC_SUSET, LOGGING_WHAT,
1330  gettext_noop("Logs long lock waits."),
1331  NULL
1332  },
1333  &log_lock_waits,
1334  false,
1335  NULL, NULL, NULL
1336  },
1337 
1338  {
1339  {"log_hostname", PGC_SIGHUP, LOGGING_WHAT,
1340  gettext_noop("Logs the host name in the connection logs."),
1341  gettext_noop("By default, connection logs only show the IP address "
1342  "of the connecting host. If you want them to show the host name you "
1343  "can turn this on, but depending on your host name resolution "
1344  "setup it might impose a non-negligible performance penalty.")
1345  },
1346  &log_hostname,
1347  false,
1348  NULL, NULL, NULL
1349  },
1350  {
1351  {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
1352  gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
1353  gettext_noop("When turned on, expressions of the form expr = NULL "
1354  "(or NULL = expr) are treated as expr IS NULL, that is, they "
1355  "return true if expr evaluates to the null value, and false "
1356  "otherwise. The correct behavior of expr = NULL is to always "
1357  "return null (unknown).")
1358  },
1360  false,
1361  NULL, NULL, NULL
1362  },
1363  {
1364  {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_SECURITY,
1365  gettext_noop("Enables per-database user names."),
1366  NULL
1367  },
1369  false,
1370  NULL, NULL, NULL
1371  },
1372  {
1373  {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
1374  gettext_noop("Sets the default read-only status of new transactions."),
1375  NULL
1376  },
1378  false,
1379  NULL, NULL, NULL
1380  },
1381  {
1382  {"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
1383  gettext_noop("Sets the current transaction's read-only status."),
1384  NULL,
1386  },
1387  &XactReadOnly,
1388  false,
1389  check_transaction_read_only, NULL, NULL
1390  },
1391  {
1392  {"default_transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
1393  gettext_noop("Sets the default deferrable status of new transactions."),
1394  NULL
1395  },
1397  false,
1398  NULL, NULL, NULL
1399  },
1400  {
1401  {"transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
1402  gettext_noop("Whether to defer a read-only serializable transaction until it can be executed with no possible serialization failures."),
1403  NULL,
1405  },
1406  &XactDeferrable,
1407  false,
1408  check_transaction_deferrable, NULL, NULL
1409  },
1410  {
1411  {"row_security", PGC_USERSET, CONN_AUTH_SECURITY,
1412  gettext_noop("Enable row security."),
1413  gettext_noop("When enabled, row security will be applied to all users.")
1414  },
1415  &row_security,
1416  true,
1417  NULL, NULL, NULL
1418  },
1419  {
1420  {"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
1421  gettext_noop("Check function bodies during CREATE FUNCTION."),
1422  NULL
1423  },
1425  true,
1426  NULL, NULL, NULL
1427  },
1428  {
1429  {"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1430  gettext_noop("Enable input of NULL elements in arrays."),
1431  gettext_noop("When turned on, unquoted NULL in an array input "
1432  "value means a null value; "
1433  "otherwise it is taken literally.")
1434  },
1435  &Array_nulls,
1436  true,
1437  NULL, NULL, NULL
1438  },
1439  {
1440  {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1441  gettext_noop("Create new tables with OIDs by default."),
1442  NULL
1443  },
1445  false,
1446  NULL, NULL, NULL
1447  },
1448  {
1449  {"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
1450  gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
1451  NULL
1452  },
1454  false,
1455  NULL, NULL, NULL
1456  },
1457  {
1458  {"log_truncate_on_rotation", PGC_SIGHUP, LOGGING_WHERE,
1459  gettext_noop("Truncate existing log files of same name during log rotation."),
1460  NULL
1461  },
1463  false,
1464  NULL, NULL, NULL
1465  },
1466 
1467 #ifdef TRACE_SORT
1468  {
1469  {"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
1470  gettext_noop("Emit information about resource usage in sorting."),
1471  NULL,
1473  },
1474  &trace_sort,
1475  false,
1476  NULL, NULL, NULL
1477  },
1478 #endif
1479 
1480 #ifdef TRACE_SYNCSCAN
1481  /* this is undocumented because not exposed in a standard build */
1482  {
1483  {"trace_syncscan", PGC_USERSET, DEVELOPER_OPTIONS,
1484  gettext_noop("Generate debugging output for synchronized scanning."),
1485  NULL,
1487  },
1488  &trace_syncscan,
1489  false,
1490  NULL, NULL, NULL
1491  },
1492 #endif
1493 
1494 #ifdef DEBUG_BOUNDED_SORT
1495  /* this is undocumented because not exposed in a standard build */
1496  {
1497  {
1498  "optimize_bounded_sort", PGC_USERSET, QUERY_TUNING_METHOD,
1499  gettext_noop("Enable bounded sorting using heap sort."),
1500  NULL,
1502  },
1503  &optimize_bounded_sort,
1504  true,
1505  NULL, NULL, NULL
1506  },
1507 #endif
1508 
1509 #ifdef WAL_DEBUG
1510  {
1511  {"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
1512  gettext_noop("Emit WAL-related debugging output."),
1513  NULL,
1515  },
1516  &XLOG_DEBUG,
1517  false,
1518  NULL, NULL, NULL
1519  },
1520 #endif
1521 
1522  {
1523  {"integer_datetimes", PGC_INTERNAL, PRESET_OPTIONS,
1524  gettext_noop("Datetimes are integer based."),
1525  NULL,
1527  },
1529  true,
1530  NULL, NULL, NULL
1531  },
1532 
1533  {
1534  {"krb_caseins_users", PGC_SIGHUP, CONN_AUTH_SECURITY,
1535  gettext_noop("Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive."),
1536  NULL
1537  },
1539  false,
1540  NULL, NULL, NULL
1541  },
1542 
1543  {
1544  {"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1545  gettext_noop("Warn about backslash escapes in ordinary string literals."),
1546  NULL
1547  },
1549  true,
1550  NULL, NULL, NULL
1551  },
1552 
1553  {
1554  {"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1555  gettext_noop("Causes '...' strings to treat backslashes literally."),
1556  NULL,
1557  GUC_REPORT
1558  },
1560  true,
1561  NULL, NULL, NULL
1562  },
1563 
1564  {
1565  {"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1566  gettext_noop("Enable synchronized sequential scans."),
1567  NULL
1568  },
1570  true,
1571  NULL, NULL, NULL
1572  },
1573 
1574  {
1575  {"hot_standby", PGC_POSTMASTER, REPLICATION_STANDBY,
1576  gettext_noop("Allows connections and queries during recovery."),
1577  NULL
1578  },
1580  true,
1581  NULL, NULL, NULL
1582  },
1583 
1584  {
1585  {"hot_standby_feedback", PGC_SIGHUP, REPLICATION_STANDBY,
1586  gettext_noop("Allows feedback from a hot standby to the primary that will avoid query conflicts."),
1587  NULL
1588  },
1590  false,
1591  NULL, NULL, NULL
1592  },
1593 
1594  {
1595  {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
1596  gettext_noop("Allows modifications of the structure of system tables."),
1597  NULL,
1599  },
1601  false,
1602  NULL, NULL, NULL
1603  },
1604 
1605  {
1606  {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
1607  gettext_noop("Disables reading from system indexes."),
1608  gettext_noop("It does not prevent updating the indexes, so it is safe "
1609  "to use. The worst consequence is slowness."),
1611  },
1613  false,
1614  NULL, NULL, NULL
1615  },
1616 
1617  {
1618  {"lo_compat_privileges", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
1619  gettext_noop("Enables backward compatibility mode for privilege checks on large objects."),
1620  gettext_noop("Skips privilege checks when reading or modifying large objects, "
1621  "for compatibility with PostgreSQL releases prior to 9.0.")
1622  },
1624  false,
1625  NULL, NULL, NULL
1626  },
1627 
1628  {
1629  {"operator_precedence_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1630  gettext_noop("Emit a warning for constructs that changed meaning since PostgreSQL 9.4."),
1631  NULL,
1632  },
1634  false,
1635  NULL, NULL, NULL
1636  },
1637 
1638  {
1639  {"quote_all_identifiers", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1640  gettext_noop("When generating SQL fragments, quote all identifiers."),
1641  NULL,
1642  },
1644  false,
1645  NULL, NULL, NULL
1646  },
1647 
1648  {
1649  {"data_checksums", PGC_INTERNAL, PRESET_OPTIONS,
1650  gettext_noop("Shows whether data checksums are turned on for this cluster."),
1651  NULL,
1653  },
1654  &data_checksums,
1655  false,
1656  NULL, NULL, NULL
1657  },
1658 
1659  {
1660  {"syslog_sequence_numbers", PGC_SIGHUP, LOGGING_WHERE,
1661  gettext_noop("Add sequence number to syslog messages to avoid duplicate suppression."),
1662  NULL
1663  },
1665  true,
1666  NULL, NULL, NULL
1667  },
1668 
1669  {
1670  {"syslog_split_messages", PGC_SIGHUP, LOGGING_WHERE,
1671  gettext_noop("Split messages sent to syslog by lines and to fit into 1024 bytes."),
1672  NULL
1673  },
1675  true,
1676  NULL, NULL, NULL
1677  },
1678 
1679  {
1680  {"parallel_leader_participation", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
1681  gettext_noop("Controls whether Gather and Gather Merge also run subplans."),
1682  gettext_noop("Should gather nodes also run subplans, or just gather tuples?")
1683  },
1685  true,
1686  NULL, NULL, NULL
1687  },
1688 
1689  /* End-of-list marker */
1690  {
1691  {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
1692  }
1693 };
1694 
1695 
1697 {
1698  {
1699  {"archive_timeout", PGC_SIGHUP, WAL_ARCHIVING,
1700  gettext_noop("Forces a switch to the next WAL file if a "
1701  "new file has not been started within N seconds."),
1702  NULL,
1703  GUC_UNIT_S
1704  },
1706  0, 0, INT_MAX / 2,
1707  NULL, NULL, NULL
1708  },
1709  {
1710  {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
1711  gettext_noop("Waits N seconds on connection startup after authentication."),
1712  gettext_noop("This allows attaching a debugger to the process."),
1714  },
1715  &PostAuthDelay,
1716  0, 0, INT_MAX / 1000000,
1717  NULL, NULL, NULL
1718  },
1719  {
1720  {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
1721  gettext_noop("Sets the default statistics target."),
1722  gettext_noop("This applies to table columns that have not had a "
1723  "column-specific target set via ALTER TABLE SET STATISTICS.")
1724  },
1726  100, 1, 10000,
1727  NULL, NULL, NULL
1728  },
1729  {
1730  {"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1731  gettext_noop("Sets the FROM-list size beyond which subqueries "
1732  "are not collapsed."),
1733  gettext_noop("The planner will merge subqueries into upper "
1734  "queries if the resulting FROM list would have no more than "
1735  "this many items.")
1736  },
1738  8, 1, INT_MAX,
1739  NULL, NULL, NULL
1740  },
1741  {
1742  {"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
1743  gettext_noop("Sets the FROM-list size beyond which JOIN "
1744  "constructs are not flattened."),
1745  gettext_noop("The planner will flatten explicit JOIN "
1746  "constructs into lists of FROM items whenever a "
1747  "list of no more than this many items would result.")
1748  },
1750  8, 1, INT_MAX,
1751  NULL, NULL, NULL
1752  },
1753  {
1754  {"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
1755  gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
1756  NULL
1757  },
1758  &geqo_threshold,
1759  12, 2, INT_MAX,
1760  NULL, NULL, NULL
1761  },
1762  {
1763  {"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
1764  gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
1765  NULL
1766  },
1767  &Geqo_effort,
1769  NULL, NULL, NULL
1770  },
1771  {
1772  {"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
1773  gettext_noop("GEQO: number of individuals in the population."),
1774  gettext_noop("Zero selects a suitable default value.")
1775  },
1776  &Geqo_pool_size,
1777  0, 0, INT_MAX,
1778  NULL, NULL, NULL
1779  },
1780  {
1781  {"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
1782  gettext_noop("GEQO: number of iterations of the algorithm."),
1783  gettext_noop("Zero selects a suitable default value.")
1784  },
1786  0, 0, INT_MAX,
1787  NULL, NULL, NULL
1788  },
1789 
1790  {
1791  /* This is PGC_SUSET to prevent hiding from log_lock_waits. */
1792  {"deadlock_timeout", PGC_SUSET, LOCK_MANAGEMENT,
1793  gettext_noop("Sets the time to wait on a lock before checking for deadlock."),
1794  NULL,
1795  GUC_UNIT_MS
1796  },
1797  &DeadlockTimeout,
1798  1000, 1, INT_MAX,
1799  NULL, NULL, NULL
1800  },
1801 
1802  {
1803  {"max_standby_archive_delay", PGC_SIGHUP, REPLICATION_STANDBY,
1804  gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data."),
1805  NULL,
1806  GUC_UNIT_MS
1807  },
1809  30 * 1000, -1, INT_MAX,
1810  NULL, NULL, NULL
1811  },
1812 
1813  {
1814  {"max_standby_streaming_delay", PGC_SIGHUP, REPLICATION_STANDBY,
1815  gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data."),
1816  NULL,
1817  GUC_UNIT_MS
1818  },
1820  30 * 1000, -1, INT_MAX,
1821  NULL, NULL, NULL
1822  },
1823 
1824  {
1825  {"wal_receiver_status_interval", PGC_SIGHUP, REPLICATION_STANDBY,
1826  gettext_noop("Sets the maximum interval between WAL receiver status reports to the primary."),
1827  NULL,
1828  GUC_UNIT_S
1829  },
1831  10, 0, INT_MAX / 1000,
1832  NULL, NULL, NULL
1833  },
1834 
1835  {
1836  {"wal_receiver_timeout", PGC_SIGHUP, REPLICATION_STANDBY,
1837  gettext_noop("Sets the maximum wait time to receive data from the primary."),
1838  NULL,
1839  GUC_UNIT_MS
1840  },
1842  60 * 1000, 0, INT_MAX,
1843  NULL, NULL, NULL
1844  },
1845 
1846  {
1847  {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1848  gettext_noop("Sets the maximum number of concurrent connections."),
1849  NULL
1850  },
1851  &MaxConnections,
1852  100, 1, MAX_BACKENDS,
1853  check_maxconnections, NULL, NULL
1854  },
1855 
1856  {
1857  {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1858  gettext_noop("Sets the number of connection slots reserved for superusers."),
1859  NULL
1860  },
1862  3, 0, MAX_BACKENDS,
1863  NULL, NULL, NULL
1864  },
1865 
1866  /*
1867  * We sometimes multiply the number of shared buffers by two without
1868  * checking for overflow, so we mustn't allow more than INT_MAX / 2.
1869  */
1870  {
1871  {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1872  gettext_noop("Sets the number of shared memory buffers used by the server."),
1873  NULL,
1875  },
1876  &NBuffers,
1877  1024, 16, INT_MAX / 2,
1878  NULL, NULL, NULL
1879  },
1880 
1881  {
1882  {"temp_buffers", PGC_USERSET, RESOURCES_MEM,
1883  gettext_noop("Sets the maximum number of temporary buffers used by each session."),
1884  NULL,
1886  },
1888  1024, 100, INT_MAX / 2,
1889  check_temp_buffers, NULL, NULL
1890  },
1891 
1892  {
1894  gettext_noop("Sets the TCP port the server listens on."),
1895  NULL
1896  },
1897  &PostPortNumber,
1898  DEF_PGPORT, 1, 65535,
1899  NULL, NULL, NULL
1900  },
1901 
1902  {
1903  {"unix_socket_permissions", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
1904  gettext_noop("Sets the access permissions of the Unix-domain socket."),
1905  gettext_noop("Unix-domain sockets use the usual Unix file system "
1906  "permission set. The parameter value is expected "
1907  "to be a numeric mode specification in the form "
1908  "accepted by the chmod and umask system calls. "
1909  "(To use the customary octal format the number must "
1910  "start with a 0 (zero).)")
1911  },
1913  0777, 0000, 0777,
1914  NULL, NULL, show_unix_socket_permissions
1915  },
1916 
1917  {
1918  {"log_file_mode", PGC_SIGHUP, LOGGING_WHERE,
1919  gettext_noop("Sets the file permissions for log files."),
1920  gettext_noop("The parameter value is expected "
1921  "to be a numeric mode specification in the form "
1922  "accepted by the chmod and umask system calls. "
1923  "(To use the customary octal format the number must "
1924  "start with a 0 (zero).)")
1925  },
1926  &Log_file_mode,
1927  0600, 0000, 0777,
1928  NULL, NULL, show_log_file_mode
1929  },
1930 
1931  {
1932  {"work_mem", PGC_USERSET, RESOURCES_MEM,
1933  gettext_noop("Sets the maximum memory to be used for query workspaces."),
1934  gettext_noop("This much memory can be used by each internal "
1935  "sort operation and hash table before switching to "
1936  "temporary disk files."),
1937  GUC_UNIT_KB
1938  },
1939  &work_mem,
1940  4096, 64, MAX_KILOBYTES,
1941  NULL, NULL, NULL
1942  },
1943 
1944  {
1945  {"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
1946  gettext_noop("Sets the maximum memory to be used for maintenance operations."),
1947  gettext_noop("This includes operations such as VACUUM and CREATE INDEX."),
1948  GUC_UNIT_KB
1949  },
1951  65536, 1024, MAX_KILOBYTES,
1952  NULL, NULL, NULL
1953  },
1954 
1955  /*
1956  * We use the hopefully-safely-small value of 100kB as the compiled-in
1957  * default for max_stack_depth. InitializeGUCOptions will increase it if
1958  * possible, depending on the actual platform-specific stack limit.
1959  */
1960  {
1961  {"max_stack_depth", PGC_SUSET, RESOURCES_MEM,
1962  gettext_noop("Sets the maximum stack depth, in kilobytes."),
1963  NULL,
1964  GUC_UNIT_KB
1965  },
1966  &max_stack_depth,
1967  100, 100, MAX_KILOBYTES,
1969  },
1970 
1971  {
1972  {"temp_file_limit", PGC_SUSET, RESOURCES_DISK,
1973  gettext_noop("Limits the total size of all temporary files used by each process."),
1974  gettext_noop("-1 means no limit."),
1975  GUC_UNIT_KB
1976  },
1977  &temp_file_limit,
1978  -1, -1, INT_MAX,
1979  NULL, NULL, NULL
1980  },
1981 
1982  {
1983  {"vacuum_cost_page_hit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
1984  gettext_noop("Vacuum cost for a page found in the buffer cache."),
1985  NULL
1986  },
1988  1, 0, 10000,
1989  NULL, NULL, NULL
1990  },
1991 
1992  {
1993  {"vacuum_cost_page_miss", PGC_USERSET, RESOURCES_VACUUM_DELAY,
1994  gettext_noop("Vacuum cost for a page not found in the buffer cache."),
1995  NULL
1996  },
1998  10, 0, 10000,
1999  NULL, NULL, NULL
2000  },
2001 
2002  {
2003  {"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES_VACUUM_DELAY,
2004  gettext_noop("Vacuum cost for a page dirtied by vacuum."),
2005  NULL
2006  },
2008  20, 0, 10000,
2009  NULL, NULL, NULL
2010  },
2011 
2012  {
2013  {"vacuum_cost_limit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
2014  gettext_noop("Vacuum cost amount available before napping."),
2015  NULL
2016  },
2017  &VacuumCostLimit,
2018  200, 1, 10000,
2019  NULL, NULL, NULL
2020  },
2021 
2022  {
2023  {"vacuum_cost_delay", PGC_USERSET, RESOURCES_VACUUM_DELAY,
2024  gettext_noop("Vacuum cost delay in milliseconds."),
2025  NULL,
2026  GUC_UNIT_MS
2027  },
2028  &VacuumCostDelay,
2029  0, 0, 100,
2030  NULL, NULL, NULL
2031  },
2032 
2033  {
2034  {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM,
2035  gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."),
2036  NULL,
2037  GUC_UNIT_MS
2038  },
2040  20, -1, 100,
2041  NULL, NULL, NULL
2042  },
2043 
2044  {
2045  {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM,
2046  gettext_noop("Vacuum cost amount available before napping, for autovacuum."),
2047  NULL
2048  },
2050  -1, -1, 10000,
2051  NULL, NULL, NULL
2052  },
2053 
2054  {
2055  {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL,
2056  gettext_noop("Sets the maximum number of simultaneously open files for each server process."),
2057  NULL
2058  },
2060  1000, 25, INT_MAX,
2061  NULL, NULL, NULL
2062  },
2063 
2064  /*
2065  * See also CheckRequiredParameterValues() if this parameter changes
2066  */
2067  {
2068  {"max_prepared_transactions", PGC_POSTMASTER, RESOURCES_MEM,
2069  gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
2070  NULL
2071  },
2073  0, 0, MAX_BACKENDS,
2074  NULL, NULL, NULL
2075  },
2076 
2077 #ifdef LOCK_DEBUG
2078  {
2079  {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
2080  gettext_noop("Sets the minimum OID of tables for tracking locks."),
2081  gettext_noop("Is used to avoid output on system tables."),
2083  },
2084  &Trace_lock_oidmin,
2085  FirstNormalObjectId, 0, INT_MAX,
2086  NULL, NULL, NULL
2087  },
2088  {
2089  {"trace_lock_table", PGC_SUSET, DEVELOPER_OPTIONS,
2090  gettext_noop("Sets the OID of the table with unconditionally lock tracing."),
2091  NULL,
2093  },
2094  &Trace_lock_table,
2095  0, 0, INT_MAX,
2096  NULL, NULL, NULL
2097  },
2098 #endif
2099 
2100  {
2101  {"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2102  gettext_noop("Sets the maximum allowed duration of any statement."),
2103  gettext_noop("A value of 0 turns off the timeout."),
2104  GUC_UNIT_MS
2105  },
2107  0, 0, INT_MAX,
2108  NULL, NULL, NULL
2109  },
2110 
2111  {
2112  {"lock_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2113  gettext_noop("Sets the maximum allowed duration of any wait for a lock."),
2114  gettext_noop("A value of 0 turns off the timeout."),
2115  GUC_UNIT_MS
2116  },
2117  &LockTimeout,
2118  0, 0, INT_MAX,
2119  NULL, NULL, NULL
2120  },
2121 
2122  {
2123  {"idle_in_transaction_session_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
2124  gettext_noop("Sets the maximum allowed duration of any idling transaction."),
2125  gettext_noop("A value of 0 turns off the timeout."),
2126  GUC_UNIT_MS
2127  },
2129  0, 0, INT_MAX,
2130  NULL, NULL, NULL
2131  },
2132 
2133  {
2134  {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2135  gettext_noop("Minimum age at which VACUUM should freeze a table row."),
2136  NULL
2137  },
2139  50000000, 0, 1000000000,
2140  NULL, NULL, NULL
2141  },
2142 
2143  {
2144  {"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2145  gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
2146  NULL
2147  },
2149  150000000, 0, 2000000000,
2150  NULL, NULL, NULL
2151  },
2152 
2153  {
2154  {"vacuum_multixact_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2155  gettext_noop("Minimum age at which VACUUM should freeze a MultiXactId in a table row."),
2156  NULL
2157  },
2159  5000000, 0, 1000000000,
2160  NULL, NULL, NULL
2161  },
2162 
2163  {
2164  {"vacuum_multixact_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
2165  gettext_noop("Multixact age at which VACUUM should scan whole table to freeze tuples."),
2166  NULL
2167  },
2169  150000000, 0, 2000000000,
2170  NULL, NULL, NULL
2171  },
2172 
2173  {
2174  {"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_MASTER,
2175  gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."),
2176  NULL
2177  },
2179  0, 0, 1000000,
2180  NULL, NULL, NULL
2181  },
2182 
2183  /*
2184  * See also CheckRequiredParameterValues() if this parameter changes
2185  */
2186  {
2187  {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
2188  gettext_noop("Sets the maximum number of locks per transaction."),
2189  gettext_noop("The shared lock table is sized on the assumption that "
2190  "at most max_locks_per_transaction * max_connections distinct "
2191  "objects will need to be locked at any one time.")
2192  },
2194  64, 10, INT_MAX,
2195  NULL, NULL, NULL
2196  },
2197 
2198  {
2199  {"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
2200  gettext_noop("Sets the maximum number of predicate locks per transaction."),
2201  gettext_noop("The shared predicate lock table is sized on the assumption that "
2202  "at most max_pred_locks_per_transaction * max_connections distinct "
2203  "objects will need to be locked at any one time.")
2204  },
2206  64, 10, INT_MAX,
2207  NULL, NULL, NULL
2208  },
2209 
2210  {
2211  {"max_pred_locks_per_relation", PGC_SIGHUP, LOCK_MANAGEMENT,
2212  gettext_noop("Sets the maximum number of predicate-locked pages and tuples per relation."),
2213  gettext_noop("If more than this total of pages and tuples in the same relation are locked "
2214  "by a connection, those locks are replaced by a relation-level lock.")
2215  },
2217  -2, INT_MIN, INT_MAX,
2218  NULL, NULL, NULL
2219  },
2220 
2221  {
2222  {"max_pred_locks_per_page", PGC_SIGHUP, LOCK_MANAGEMENT,
2223  gettext_noop("Sets the maximum number of predicate-locked tuples per page."),
2224  gettext_noop("If more than this number of tuples on the same page are locked "
2225  "by a connection, those locks are replaced by a page-level lock.")
2226  },
2228  2, 0, INT_MAX,
2229  NULL, NULL, NULL
2230  },
2231 
2232  {
2233  {"authentication_timeout", PGC_SIGHUP, CONN_AUTH_SECURITY,
2234  gettext_noop("Sets the maximum allowed time to complete client authentication."),
2235  NULL,
2236  GUC_UNIT_S
2237  },
2239  60, 1, 600,
2240  NULL, NULL, NULL
2241  },
2242 
2243  {
2244  /* Not for general use */
2245  {"pre_auth_delay", PGC_SIGHUP, DEVELOPER_OPTIONS,
2246  gettext_noop("Waits N seconds on connection startup before authentication."),
2247  gettext_noop("This allows attaching a debugger to the process."),
2249  },
2250  &PreAuthDelay,
2251  0, 0, 60,
2252  NULL, NULL, NULL
2253  },
2254 
2255  {
2256  {"wal_keep_segments", PGC_SIGHUP, REPLICATION_SENDING,
2257  gettext_noop("Sets the number of WAL files held for standby servers."),
2258  NULL
2259  },
2261  0, 0, INT_MAX,
2262  NULL, NULL, NULL
2263  },
2264 
2265  {
2266  {"min_wal_size", PGC_SIGHUP, WAL_CHECKPOINTS,
2267  gettext_noop("Sets the minimum size to shrink the WAL to."),
2268  NULL,
2269  GUC_UNIT_MB
2270  },
2271  &min_wal_size_mb,
2272  DEFAULT_MIN_WAL_SEGS * (DEFAULT_XLOG_SEG_SIZE / (1024 * 1024)),
2273  2, MAX_KILOBYTES,
2274  NULL, NULL, NULL
2275  },
2276 
2277  {
2278  {"max_wal_size", PGC_SIGHUP, WAL_CHECKPOINTS,
2279  gettext_noop("Sets the WAL size that triggers a checkpoint."),
2280  NULL,
2281  GUC_UNIT_MB
2282  },
2283  &max_wal_size_mb,
2284  DEFAULT_MAX_WAL_SEGS * (DEFAULT_XLOG_SEG_SIZE / (1024 * 1024)),
2285  2, MAX_KILOBYTES,
2286  NULL, assign_max_wal_size, NULL
2287  },
2288 
2289  {
2290  {"checkpoint_timeout", PGC_SIGHUP, WAL_CHECKPOINTS,
2291  gettext_noop("Sets the maximum time between automatic WAL checkpoints."),
2292  NULL,
2293  GUC_UNIT_S
2294  },
2296  300, 30, 86400,
2297  NULL, NULL, NULL
2298  },
2299 
2300  {
2301  {"checkpoint_warning", PGC_SIGHUP, WAL_CHECKPOINTS,
2302  gettext_noop("Enables warnings if checkpoint segments are filled more "
2303  "frequently than this."),
2304  gettext_noop("Write a message to the server log if checkpoints "
2305  "caused by the filling of checkpoint segment files happens more "
2306  "frequently than this number of seconds. Zero turns off the warning."),
2307  GUC_UNIT_S
2308  },
2310  30, 0, INT_MAX,
2311  NULL, NULL, NULL
2312  },
2313 
2314  {
2315  {"checkpoint_flush_after", PGC_SIGHUP, WAL_CHECKPOINTS,
2316  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2317  NULL,
2319  },
2322  NULL, NULL, NULL
2323  },
2324 
2325  {
2326  {"wal_buffers", PGC_POSTMASTER, WAL_SETTINGS,
2327  gettext_noop("Sets the number of disk-page buffers in shared memory for WAL."),
2328  NULL,
2330  },
2331  &XLOGbuffers,
2332  -1, -1, (INT_MAX / XLOG_BLCKSZ),
2333  check_wal_buffers, NULL, NULL
2334  },
2335 
2336  {
2337  {"wal_writer_delay", PGC_SIGHUP, WAL_SETTINGS,
2338  gettext_noop("Time between WAL flushes performed in the WAL writer."),
2339  NULL,
2340  GUC_UNIT_MS
2341  },
2342  &WalWriterDelay,
2343  200, 1, 10000,
2344  NULL, NULL, NULL
2345  },
2346 
2347  {
2348  {"wal_writer_flush_after", PGC_SIGHUP, WAL_SETTINGS,
2349  gettext_noop("Amount of WAL written out by WAL writer that triggers a flush."),
2350  NULL,
2352  },
2354  (1024 * 1024) / XLOG_BLCKSZ, 0, INT_MAX,
2355  NULL, NULL, NULL
2356  },
2357 
2358  {
2359  /* see max_connections */
2360  {"max_wal_senders", PGC_POSTMASTER, REPLICATION_SENDING,
2361  gettext_noop("Sets the maximum number of simultaneously running WAL sender processes."),
2362  NULL
2363  },
2364  &max_wal_senders,
2365  10, 0, MAX_BACKENDS,
2366  NULL, NULL, NULL
2367  },
2368 
2369  {
2370  /* see max_connections */
2371  {"max_replication_slots", PGC_POSTMASTER, REPLICATION_SENDING,
2372  gettext_noop("Sets the maximum number of simultaneously defined replication slots."),
2373  NULL
2374  },
2376  10, 0, MAX_BACKENDS /* XXX? */ ,
2377  NULL, NULL, NULL
2378  },
2379 
2380  {
2381  {"wal_sender_timeout", PGC_SIGHUP, REPLICATION_SENDING,
2382  gettext_noop("Sets the maximum time to wait for WAL replication."),
2383  NULL,
2384  GUC_UNIT_MS
2385  },
2387  60 * 1000, 0, INT_MAX,
2388  NULL, NULL, NULL
2389  },
2390 
2391  {
2392  {"commit_delay", PGC_SUSET, WAL_SETTINGS,
2393  gettext_noop("Sets the delay in microseconds between transaction commit and "
2394  "flushing WAL to disk."),
2395  NULL
2396  /* we have no microseconds designation, so can't supply units here */
2397  },
2398  &CommitDelay,
2399  0, 0, 100000,
2400  NULL, NULL, NULL
2401  },
2402 
2403  {
2404  {"commit_siblings", PGC_USERSET, WAL_SETTINGS,
2405  gettext_noop("Sets the minimum concurrent open transactions before performing "
2406  "commit_delay."),
2407  NULL
2408  },
2409  &CommitSiblings,
2410  5, 0, 1000,
2411  NULL, NULL, NULL
2412  },
2413 
2414  {
2415  {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
2416  gettext_noop("Sets the number of digits displayed for floating-point values."),
2417  gettext_noop("This affects real, double precision, and geometric data types. "
2418  "The parameter value is added to the standard number of digits "
2419  "(FLT_DIG or DBL_DIG as appropriate).")
2420  },
2422  0, -15, 3,
2423  NULL, NULL, NULL
2424  },
2425 
2426  {
2427  {"log_min_duration_statement", PGC_SUSET, LOGGING_WHEN,
2428  gettext_noop("Sets the minimum execution time above which "
2429  "statements will be logged."),
2430  gettext_noop("Zero prints all queries. -1 turns this feature off."),
2431  GUC_UNIT_MS
2432  },
2434  -1, -1, INT_MAX,
2435  NULL, NULL, NULL
2436  },
2437 
2438  {
2439  {"log_autovacuum_min_duration", PGC_SIGHUP, LOGGING_WHAT,
2440  gettext_noop("Sets the minimum execution time above which "
2441  "autovacuum actions will be logged."),
2442  gettext_noop("Zero prints all actions. -1 turns autovacuum logging off."),
2443  GUC_UNIT_MS
2444  },
2446  -1, -1, INT_MAX,
2447  NULL, NULL, NULL
2448  },
2449 
2450  {
2451  {"bgwriter_delay", PGC_SIGHUP, RESOURCES_BGWRITER,
2452  gettext_noop("Background writer sleep time between rounds."),
2453  NULL,
2454  GUC_UNIT_MS
2455  },
2456  &BgWriterDelay,
2457  200, 10, 10000,
2458  NULL, NULL, NULL
2459  },
2460 
2461  {
2462  {"bgwriter_lru_maxpages", PGC_SIGHUP, RESOURCES_BGWRITER,
2463  gettext_noop("Background writer maximum number of LRU pages to flush per round."),
2464  NULL
2465  },
2467  100, 0, INT_MAX / 2, /* Same upper limit as shared_buffers */
2468  NULL, NULL, NULL
2469  },
2470 
2471  {
2472  {"bgwriter_flush_after", PGC_SIGHUP, RESOURCES_BGWRITER,
2473  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2474  NULL,
2476  },
2479  NULL, NULL, NULL
2480  },
2481 
2482  {
2483  {"effective_io_concurrency",
2484  PGC_USERSET,
2486  gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."),
2487  gettext_noop("For RAID arrays, this should be approximately the number of drive spindles in the array.")
2488  },
2490 #ifdef USE_PREFETCH
2491  1, 0, MAX_IO_CONCURRENCY,
2492 #else
2493  0, 0, 0,
2494 #endif
2496  },
2497 
2498  {
2499  {"backend_flush_after", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2500  gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
2501  NULL,
2503  },
2506  NULL, NULL, NULL
2507  },
2508 
2509  {
2510  {"max_worker_processes",
2513  gettext_noop("Maximum number of concurrent worker processes."),
2514  NULL,
2515  },
2517  8, 0, MAX_BACKENDS,
2518  check_max_worker_processes, NULL, NULL
2519  },
2520 
2521  {
2522  {"max_logical_replication_workers",
2525  gettext_noop("Maximum number of logical replication worker processes."),
2526  NULL,
2527  },
2529  4, 0, MAX_BACKENDS,
2530  NULL, NULL, NULL
2531  },
2532 
2533  {
2534  {"max_sync_workers_per_subscription",
2535  PGC_SIGHUP,
2537  gettext_noop("Maximum number of table synchronization workers per subscription."),
2538  NULL,
2539  },
2541  2, 0, MAX_BACKENDS,
2542  NULL, NULL, NULL
2543  },
2544 
2545  {
2546  {"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
2547  gettext_noop("Automatic log file rotation will occur after N minutes."),
2548  NULL,
2549  GUC_UNIT_MIN
2550  },
2551  &Log_RotationAge,
2553  NULL, NULL, NULL
2554  },
2555 
2556  {
2557  {"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
2558  gettext_noop("Automatic log file rotation will occur after N kilobytes."),
2559  NULL,
2560  GUC_UNIT_KB
2561  },
2563  10 * 1024, 0, INT_MAX / 1024,
2564  NULL, NULL, NULL
2565  },
2566 
2567  {
2568  {"max_function_args", PGC_INTERNAL, PRESET_OPTIONS,
2569  gettext_noop("Shows the maximum number of function arguments."),
2570  NULL,
2572  },
2575  NULL, NULL, NULL
2576  },
2577 
2578  {
2579  {"max_index_keys", PGC_INTERNAL, PRESET_OPTIONS,
2580  gettext_noop("Shows the maximum number of index keys."),
2581  NULL,
2583  },
2584  &max_index_keys,
2586  NULL, NULL, NULL
2587  },
2588 
2589  {
2590  {"max_identifier_length", PGC_INTERNAL, PRESET_OPTIONS,
2591  gettext_noop("Shows the maximum identifier length."),
2592  NULL,
2594  },
2596  NAMEDATALEN - 1, NAMEDATALEN - 1, NAMEDATALEN - 1,
2597  NULL, NULL, NULL
2598  },
2599 
2600  {
2601  {"block_size", PGC_INTERNAL, PRESET_OPTIONS,
2602  gettext_noop("Shows the size of a disk block."),
2603  NULL,
2605  },
2606  &block_size,
2607  BLCKSZ, BLCKSZ, BLCKSZ,
2608  NULL, NULL, NULL
2609  },
2610 
2611  {
2612  {"segment_size", PGC_INTERNAL, PRESET_OPTIONS,
2613  gettext_noop("Shows the number of pages per disk file."),
2614  NULL,
2616  },
2617  &segment_size,
2618  RELSEG_SIZE, RELSEG_SIZE, RELSEG_SIZE,
2619  NULL, NULL, NULL
2620  },
2621 
2622  {
2623  {"wal_block_size", PGC_INTERNAL, PRESET_OPTIONS,
2624  gettext_noop("Shows the block size in the write ahead log."),
2625  NULL,
2627  },
2628  &wal_block_size,
2629  XLOG_BLCKSZ, XLOG_BLCKSZ, XLOG_BLCKSZ,
2630  NULL, NULL, NULL
2631  },
2632 
2633  {
2634  {"wal_retrieve_retry_interval", PGC_SIGHUP, REPLICATION_STANDBY,
2635  gettext_noop("Sets the time to wait before retrying to retrieve WAL "
2636  "after a failed attempt."),
2637  NULL,
2638  GUC_UNIT_MS
2639  },
2641  5000, 1, INT_MAX,
2642  NULL, NULL, NULL
2643  },
2644 
2645  {
2646  {"wal_segment_size", PGC_INTERNAL, PRESET_OPTIONS,
2647  gettext_noop("Shows the size of write ahead log segments."),
2648  NULL,
2650  },
2653  WalSegMinSize,
2654  WalSegMaxSize,
2655  NULL, NULL, NULL
2656  },
2657 
2658  {
2659  {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
2660  gettext_noop("Time to sleep between autovacuum runs."),
2661  NULL,
2662  GUC_UNIT_S
2663  },
2665  60, 1, INT_MAX / 1000,
2666  NULL, NULL, NULL
2667  },
2668  {
2669  {"autovacuum_vacuum_threshold", PGC_SIGHUP, AUTOVACUUM,
2670  gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
2671  NULL
2672  },
2674  50, 0, INT_MAX,
2675  NULL, NULL, NULL
2676  },
2677  {
2678  {"autovacuum_analyze_threshold", PGC_SIGHUP, AUTOVACUUM,
2679  gettext_noop("Minimum number of tuple inserts, updates, or deletes prior to analyze."),
2680  NULL
2681  },
2683  50, 0, INT_MAX,
2684  NULL, NULL, NULL
2685  },
2686  {
2687  /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
2688  {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
2689  gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
2690  NULL
2691  },
2693  /* see pg_resetwal if you change the upper-limit value */
2694  200000000, 100000, 2000000000,
2695  NULL, NULL, NULL
2696  },
2697  {
2698  /* see multixact.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
2699  {"autovacuum_multixact_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
2700  gettext_noop("Multixact age at which to autovacuum a table to prevent multixact wraparound."),
2701  NULL
2702  },
2704  400000000, 10000, 2000000000,
2705  NULL, NULL, NULL
2706  },
2707  {
2708  /* see max_connections */
2709  {"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM,
2710  gettext_noop("Sets the maximum number of simultaneously running autovacuum worker processes."),
2711  NULL
2712  },
2714  3, 1, MAX_BACKENDS,
2715  check_autovacuum_max_workers, NULL, NULL
2716  },
2717 
2718  {
2719  {"max_parallel_workers_per_gather", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2720  gettext_noop("Sets the maximum number of parallel processes per executor node."),
2721  NULL
2722  },
2725  NULL, NULL, NULL
2726  },
2727 
2728  {
2729  {"max_parallel_workers", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
2730  gettext_noop("Sets the maximum number of parallel workers than can be active at one time."),
2731  NULL
2732  },
2735  NULL, NULL, NULL
2736  },
2737 
2738  {
2739  {"autovacuum_work_mem", PGC_SIGHUP, RESOURCES_MEM,
2740  gettext_noop("Sets the maximum memory to be used by each autovacuum worker process."),
2741  NULL,
2742  GUC_UNIT_KB
2743  },
2745  -1, -1, MAX_KILOBYTES,
2746  check_autovacuum_work_mem, NULL, NULL
2747  },
2748 
2749  {
2750  {"old_snapshot_threshold", PGC_POSTMASTER, RESOURCES_ASYNCHRONOUS,
2751  gettext_noop("Time before a snapshot is too old to read pages changed after the snapshot was taken."),
2752  gettext_noop("A value of -1 disables this feature."),
2753  GUC_UNIT_MIN
2754  },
2756  -1, -1, MINS_PER_HOUR * HOURS_PER_DAY * 60,
2757  NULL, NULL, NULL
2758  },
2759 
2760  {
2761  {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER,
2762  gettext_noop("Time between issuing TCP keepalives."),
2763  gettext_noop("A value of 0 uses the system default."),
2764  GUC_UNIT_S
2765  },
2767  0, 0, INT_MAX,
2769  },
2770 
2771  {
2772  {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER,
2773  gettext_noop("Time between TCP keepalive retransmits."),
2774  gettext_noop("A value of 0 uses the system default."),
2775  GUC_UNIT_S
2776  },
2778  0, 0, INT_MAX,
2780  },
2781 
2782  {
2783  {"ssl_renegotiation_limit", PGC_USERSET, CONN_AUTH_SECURITY,
2784  gettext_noop("SSL renegotiation is no longer supported; this can only be 0."),
2785  NULL,
2787  },
2789  0, 0, 0,
2790  NULL, NULL, NULL
2791  },
2792 
2793  {
2794  {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
2795  gettext_noop("Maximum number of TCP keepalive retransmits."),
2796  gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
2797  "lost before a connection is considered dead. A value of 0 uses the "
2798  "system default."),
2799  },
2801  0, 0, INT_MAX,
2803  },
2804 
2805  {
2806  {"gin_fuzzy_search_limit", PGC_USERSET, CLIENT_CONN_OTHER,
2807  gettext_noop("Sets the maximum allowed result for exact search by GIN."),
2808  NULL,
2809  0
2810  },
2812  0, 0, INT_MAX,
2813  NULL, NULL, NULL
2814  },
2815 
2816  {
2817  {"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
2818  gettext_noop("Sets the planner's assumption about the size of the disk cache."),
2819  gettext_noop("That is, the portion of the kernel's disk cache that "
2820  "will be used for PostgreSQL data files. This is measured in disk "
2821  "pages, which are normally 8 kB each."),
2823  },
2825  DEFAULT_EFFECTIVE_CACHE_SIZE, 1, INT_MAX,
2826  NULL, NULL, NULL
2827  },
2828 
2829  {
2830  {"min_parallel_table_scan_size", PGC_USERSET, QUERY_TUNING_COST,
2831  gettext_noop("Sets the minimum amount of table data for a parallel scan."),
2832  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."),
2834  },
2836  (8 * 1024 * 1024) / BLCKSZ, 0, INT_MAX / 3,
2837  NULL, NULL, NULL
2838  },
2839 
2840  {
2841  {"min_parallel_index_scan_size", PGC_USERSET, QUERY_TUNING_COST,
2842  gettext_noop("Sets the minimum amount of index data for a parallel scan."),
2843  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."),
2845  },
2847  (512 * 1024) / BLCKSZ, 0, INT_MAX / 3,
2848  NULL, NULL, NULL
2849  },
2850 
2851  {
2852  /* Can't be set in postgresql.conf */
2853  {"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
2854  gettext_noop("Shows the server version as an integer."),
2855  NULL,
2857  },
2859  PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM,
2860  NULL, NULL, NULL
2861  },
2862 
2863  {
2864  {"log_temp_files", PGC_SUSET, LOGGING_WHAT,
2865  gettext_noop("Log the use of temporary files larger than this number of kilobytes."),
2866  gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
2867  GUC_UNIT_KB
2868  },
2869  &log_temp_files,
2870  -1, -1, INT_MAX,
2871  NULL, NULL, NULL
2872  },
2873 
2874  {
2875  {"track_activity_query_size", PGC_POSTMASTER, RESOURCES_MEM,
2876  gettext_noop("Sets the size reserved for pg_stat_activity.query, in bytes."),
2877  NULL,
2879  },
2881  1024, 100, 102400,
2882  NULL, NULL, NULL
2883  },
2884 
2885  {
2886  {"gin_pending_list_limit", PGC_USERSET, CLIENT_CONN_STATEMENT,
2887  gettext_noop("Sets the maximum size of the pending list for GIN index."),
2888  NULL,
2889  GUC_UNIT_KB
2890  },
2892  4096, 64, MAX_KILOBYTES,
2893  NULL, NULL, NULL
2894  },
2895 
2896  /* End-of-list marker */
2897  {
2898  {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
2899  }
2900 };
2901 
2902 
2904 {
2905  {
2906  {"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
2907  gettext_noop("Sets the planner's estimate of the cost of a "
2908  "sequentially fetched disk page."),
2909  NULL
2910  },
2911  &seq_page_cost,
2912  DEFAULT_SEQ_PAGE_COST, 0, DBL_MAX,
2913  NULL, NULL, NULL
2914  },
2915  {
2916  {"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
2917  gettext_noop("Sets the planner's estimate of the cost of a "
2918  "nonsequentially fetched disk page."),
2919  NULL
2920  },
2922  DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX,
2923  NULL, NULL, NULL
2924  },
2925  {
2926  {"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2927  gettext_noop("Sets the planner's estimate of the cost of "
2928  "processing each tuple (row)."),
2929  NULL
2930  },
2931  &cpu_tuple_cost,
2932  DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX,
2933  NULL, NULL, NULL
2934  },
2935  {
2936  {"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2937  gettext_noop("Sets the planner's estimate of the cost of "
2938  "processing each index entry during an index scan."),
2939  NULL
2940  },
2942  DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX,
2943  NULL, NULL, NULL
2944  },
2945  {
2946  {"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
2947  gettext_noop("Sets the planner's estimate of the cost of "
2948  "processing each operator or function call."),
2949  NULL
2950  },
2952  DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX,
2953  NULL, NULL, NULL
2954  },
2955  {
2956  {"parallel_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
2957  gettext_noop("Sets the planner's estimate of the cost of "
2958  "passing each tuple (row) from worker to master backend."),
2959  NULL
2960  },
2962  DEFAULT_PARALLEL_TUPLE_COST, 0, DBL_MAX,
2963  NULL, NULL, NULL
2964  },
2965  {
2966  {"parallel_setup_cost", PGC_USERSET, QUERY_TUNING_COST,
2967  gettext_noop("Sets the planner's estimate of the cost of "
2968  "starting up worker processes for parallel query."),
2969  NULL
2970  },
2972  DEFAULT_PARALLEL_SETUP_COST, 0, DBL_MAX,
2973  NULL, NULL, NULL
2974  },
2975 
2976  {
2977  {"cursor_tuple_fraction", PGC_USERSET, QUERY_TUNING_OTHER,
2978  gettext_noop("Sets the planner's estimate of the fraction of "
2979  "a cursor's rows that will be retrieved."),
2980  NULL
2981  },
2984  NULL, NULL, NULL
2985  },
2986 
2987  {
2988  {"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
2989  gettext_noop("GEQO: selective pressure within the population."),
2990  NULL
2991  },
2995  NULL, NULL, NULL
2996  },
2997  {
2998  {"geqo_seed", PGC_USERSET, QUERY_TUNING_GEQO,
2999  gettext_noop("GEQO: seed for random path selection."),
3000  NULL
3001  },
3002  &Geqo_seed,
3003  0.0, 0.0, 1.0,
3004  NULL, NULL, NULL
3005  },
3006 
3007  {
3008  {"bgwriter_lru_multiplier", PGC_SIGHUP, RESOURCES_BGWRITER,
3009  gettext_noop("Multiple of the average buffer usage to free per round."),
3010  NULL
3011  },
3013  2.0, 0.0, 10.0,
3014  NULL, NULL, NULL
3015  },
3016 
3017  {
3018  {"seed", PGC_USERSET, UNGROUPED,
3019  gettext_noop("Sets the seed for random-number generation."),
3020  NULL,
3022  },
3024  0.0, -1.0, 1.0,
3026  },
3027 
3028  {
3029  {"autovacuum_vacuum_scale_factor", PGC_SIGHUP, AUTOVACUUM,
3030  gettext_noop("Number of tuple updates or deletes prior to vacuum as a fraction of reltuples."),
3031  NULL
3032  },
3034  0.2, 0.0, 100.0,
3035  NULL, NULL, NULL
3036  },
3037  {
3038  {"autovacuum_analyze_scale_factor", PGC_SIGHUP, AUTOVACUUM,
3039  gettext_noop("Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples."),
3040  NULL
3041  },
3043  0.1, 0.0, 100.0,
3044  NULL, NULL, NULL
3045  },
3046 
3047  {
3048  {"checkpoint_completion_target", PGC_SIGHUP, WAL_CHECKPOINTS,
3049  gettext_noop("Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval."),
3050  NULL
3051  },
3053  0.5, 0.0, 1.0,
3054  NULL, NULL, NULL
3055  },
3056 
3057  /* End-of-list marker */
3058  {
3059  {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL, NULL
3060  }
3061 };
3062 
3063 
3065 {
3066  {
3067  {"archive_command", PGC_SIGHUP, WAL_ARCHIVING,
3068  gettext_noop("Sets the shell command that will be called to archive a WAL file."),
3069  NULL
3070  },
3072  "",
3073  NULL, NULL, show_archive_command
3074  },
3075 
3076  {
3077  {"client_encoding", PGC_USERSET, CLIENT_CONN_LOCALE,
3078  gettext_noop("Sets the client's character set encoding."),
3079  NULL,
3081  },
3083  "SQL_ASCII",
3085  },
3086 
3087  {
3088  {"log_line_prefix", PGC_SIGHUP, LOGGING_WHAT,
3089  gettext_noop("Controls information prefixed to each log line."),
3090  gettext_noop("If blank, no prefix is used.")
3091  },
3092  &Log_line_prefix,
3093  "%m [%p] ",
3094  NULL, NULL, NULL
3095  },
3096 
3097  {
3098  {"log_timezone", PGC_SIGHUP, LOGGING_WHAT,
3099  gettext_noop("Sets the time zone to use in log messages."),
3100  NULL
3101  },
3103  "GMT",
3105  },
3106 
3107  {
3108  {"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
3109  gettext_noop("Sets the display format for date and time values."),
3110  gettext_noop("Also controls interpretation of ambiguous "
3111  "date inputs."),
3113  },
3115  "ISO, MDY",
3117  },
3118 
3119  {
3120  {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
3121  gettext_noop("Sets the default tablespace to create tables and indexes in."),
3122  gettext_noop("An empty string selects the database's default tablespace."),
3123  GUC_IS_NAME
3124  },
3126  "",
3127  check_default_tablespace, NULL, NULL
3128  },
3129 
3130  {
3131  {"temp_tablespaces", PGC_USERSET, CLIENT_CONN_STATEMENT,
3132  gettext_noop("Sets the tablespace(s) to use for temporary tables and sort files."),
3133  NULL,
3135  },
3137  "",
3139  },
3140 
3141  {
3142  {"dynamic_library_path", PGC_SUSET, CLIENT_CONN_OTHER,
3143  gettext_noop("Sets the path for dynamically loadable modules."),
3144  gettext_noop("If a dynamically loadable module needs to be opened and "
3145  "the specified name does not have a directory component (i.e., the "
3146  "name does not contain a slash), the system will search this path for "
3147  "the specified file."),
3149  },
3151  "$libdir",
3152  NULL, NULL, NULL
3153  },
3154 
3155  {
3156  {"krb_server_keyfile", PGC_SIGHUP, CONN_AUTH_SECURITY,
3157  gettext_noop("Sets the location of the Kerberos server key file."),
3158  NULL,
3160  },
3162  PG_KRB_SRVTAB,
3163  NULL, NULL, NULL
3164  },
3165 
3166  {
3167  {"bonjour_name", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3168  gettext_noop("Sets the Bonjour service name."),
3169  NULL
3170  },
3171  &bonjour_name,
3172  "",
3173  NULL, NULL, NULL
3174  },
3175 
3176  /* See main.c about why defaults for LC_foo are not all alike */
3177 
3178  {
3179  {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3180  gettext_noop("Shows the collation order locale."),
3181  NULL,
3183  },
3184  &locale_collate,
3185  "C",
3186  NULL, NULL, NULL
3187  },
3188 
3189  {
3190  {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3191  gettext_noop("Shows the character classification and case conversion locale."),
3192  NULL,
3194  },
3195  &locale_ctype,
3196  "C",
3197  NULL, NULL, NULL
3198  },
3199 
3200  {
3201  {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
3202  gettext_noop("Sets the language in which messages are displayed."),
3203  NULL
3204  },
3205  &locale_messages,
3206  "",
3208  },
3209 
3210  {
3211  {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
3212  gettext_noop("Sets the locale for formatting monetary amounts."),
3213  NULL
3214  },
3215  &locale_monetary,
3216  "C",
3218  },
3219 
3220  {
3221  {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
3222  gettext_noop("Sets the locale for formatting numbers."),
3223  NULL
3224  },
3225  &locale_numeric,
3226  "C",
3228  },
3229 
3230  {
3231  {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
3232  gettext_noop("Sets the locale for formatting date and time values."),
3233  NULL
3234  },
3235  &locale_time,
3236  "C",
3238  },
3239 
3240  {
3241  {"session_preload_libraries", PGC_SUSET, CLIENT_CONN_PRELOAD,
3242  gettext_noop("Lists shared libraries to preload into each backend."),
3243  NULL,
3245  },
3247  "",
3248  NULL, NULL, NULL
3249  },
3250 
3251  {
3252  {"shared_preload_libraries", PGC_POSTMASTER, CLIENT_CONN_PRELOAD,
3253  gettext_noop("Lists shared libraries to preload into server."),
3254  NULL,
3256  },
3258  "",
3259  NULL, NULL, NULL
3260  },
3261 
3262  {
3263  {"local_preload_libraries", PGC_USERSET, CLIENT_CONN_PRELOAD,
3264  gettext_noop("Lists unprivileged shared libraries to preload into each backend."),
3265  NULL,
3267  },
3269  "",
3270  NULL, NULL, NULL
3271  },
3272 
3273  {
3274  {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
3275  gettext_noop("Sets the schema search order for names that are not schema-qualified."),
3276  NULL,
3278  },
3280  "\"$user\", public",
3282  },
3283 
3284  {
3285  /* Can't be set in postgresql.conf */
3286  {"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
3287  gettext_noop("Sets the server (database) character set encoding."),
3288  NULL,
3290  },
3292  "SQL_ASCII",
3293  NULL, NULL, NULL
3294  },
3295 
3296  {
3297  /* Can't be set in postgresql.conf */
3298  {"server_version", PGC_INTERNAL, PRESET_OPTIONS,
3299  gettext_noop("Shows the server version."),
3300  NULL,
3302  },
3304  PG_VERSION,
3305  NULL, NULL, NULL
3306  },
3307 
3308  {
3309  /* Not for general use --- used by SET ROLE */
3310  {"role", PGC_USERSET, UNGROUPED,
3311  gettext_noop("Sets the current role."),
3312  NULL,
3314  },
3315  &role_string,
3316  "none",
3318  },
3319 
3320  {
3321  /* Not for general use --- used by SET SESSION AUTHORIZATION */
3322  {"session_authorization", PGC_USERSET, UNGROUPED,
3323  gettext_noop("Sets the session user name."),
3324  NULL,
3326  },
3328  NULL,
3330  },
3331 
3332  {
3333  {"log_destination", PGC_SIGHUP, LOGGING_WHERE,
3334  gettext_noop("Sets the destination for server log output."),
3335  gettext_noop("Valid values are combinations of \"stderr\", "
3336  "\"syslog\", \"csvlog\", and \"eventlog\", "
3337  "depending on the platform."),
3339  },
3341  "stderr",
3343  },
3344  {
3345  {"log_directory", PGC_SIGHUP, LOGGING_WHERE,
3346  gettext_noop("Sets the destination directory for log files."),
3347  gettext_noop("Can be specified as relative to the data directory "
3348  "or as absolute path."),
3350  },
3351  &Log_directory,
3352  "log",
3353  check_canonical_path, NULL, NULL
3354  },
3355  {
3356  {"log_filename", PGC_SIGHUP, LOGGING_WHERE,
3357  gettext_noop("Sets the file name pattern for log files."),
3358  NULL,
3360  },
3361  &Log_filename,
3362  "postgresql-%Y-%m-%d_%H%M%S.log",
3363  NULL, NULL, NULL
3364  },
3365 
3366  {
3367  {"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
3368  gettext_noop("Sets the program name used to identify PostgreSQL "
3369  "messages in syslog."),
3370  NULL
3371  },
3373  "postgres",
3374  NULL, assign_syslog_ident, NULL
3375  },
3376 
3377  {
3378  {"event_source", PGC_POSTMASTER, LOGGING_WHERE,
3379  gettext_noop("Sets the application name used to identify "
3380  "PostgreSQL messages in the event log."),
3381  NULL
3382  },
3383  &event_source,
3385  NULL, NULL, NULL
3386  },
3387 
3388  {
3389  {"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
3390  gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
3391  NULL,
3392  GUC_REPORT
3393  },
3394  &timezone_string,
3395  "GMT",
3397  },
3398  {
3399  {"timezone_abbreviations", PGC_USERSET, CLIENT_CONN_LOCALE,
3400  gettext_noop("Selects a file of time zone abbreviations."),
3401  NULL
3402  },
3404  NULL,
3406  },
3407 
3408  {
3409  {"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
3410  gettext_noop("Sets the current transaction's isolation level."),
3411  NULL,
3413  },
3415  "default",
3417  },
3418 
3419  {
3420  {"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3421  gettext_noop("Sets the owning group of the Unix-domain socket."),
3422  gettext_noop("The owning user of the socket is always the user "
3423  "that starts the server.")
3424  },
3426  "",
3427  NULL, NULL, NULL
3428  },
3429 
3430  {
3431  {"unix_socket_directories", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3432  gettext_noop("Sets the directories where Unix-domain sockets will be created."),
3433  NULL,
3435  },
3437 #ifdef HAVE_UNIX_SOCKETS
3439 #else
3440  "",
3441 #endif
3442  NULL, NULL, NULL
3443  },
3444 
3445  {
3446  {"listen_addresses", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
3447  gettext_noop("Sets the host name or IP address(es) to listen to."),
3448  NULL,
3450  },
3451  &ListenAddresses,
3452  "localhost",
3453  NULL, NULL, NULL
3454  },
3455 
3456  {
3457  /*
3458  * Can't be set by ALTER SYSTEM as it can lead to recursive definition
3459  * of data_directory.
3460  */
3461  {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS,
3462  gettext_noop("Sets the server's data directory."),
3463  NULL,
3465  },
3466  &data_directory,
3467  NULL,
3468  NULL, NULL, NULL
3469  },
3470 
3471  {
3472  {"config_file", PGC_POSTMASTER, FILE_LOCATIONS,
3473  gettext_noop("Sets the server's main configuration file."),
3474  NULL,
3476  },
3477  &ConfigFileName,
3478  NULL,
3479  NULL, NULL, NULL
3480  },
3481 
3482  {
3483  {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS,
3484  gettext_noop("Sets the server's \"hba\" configuration file."),
3485  NULL,
3487  },
3488  &HbaFileName,
3489  NULL,
3490  NULL, NULL, NULL
3491  },
3492 
3493  {
3494  {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS,
3495  gettext_noop("Sets the server's \"ident\" configuration file."),
3496  NULL,
3498  },
3499  &IdentFileName,
3500  NULL,
3501  NULL, NULL, NULL
3502  },
3503 
3504  {
3505  {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS,
3506  gettext_noop("Writes the postmaster PID to the specified file."),
3507  NULL,
3509  },
3511  NULL,
3512  check_canonical_path, NULL, NULL
3513  },
3514 
3515  {
3516  {"ssl_cert_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3517  gettext_noop("Location of the SSL server certificate file."),
3518  NULL
3519  },
3520  &ssl_cert_file,
3521  "server.crt",
3522  NULL, NULL, NULL
3523  },
3524 
3525  {
3526  {"ssl_key_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3527  gettext_noop("Location of the SSL server private key file."),
3528  NULL
3529  },
3530  &ssl_key_file,
3531  "server.key",
3532  NULL, NULL, NULL
3533  },
3534 
3535  {
3536  {"ssl_ca_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3537  gettext_noop("Location of the SSL certificate authority file."),
3538  NULL
3539  },
3540  &ssl_ca_file,
3541  "",
3542  NULL, NULL, NULL
3543  },
3544 
3545  {
3546  {"ssl_crl_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3547  gettext_noop("Location of the SSL certificate revocation list file."),
3548  NULL
3549  },
3550  &ssl_crl_file,
3551  "",
3552  NULL, NULL, NULL
3553  },
3554 
3555  {
3556  {"stats_temp_directory", PGC_SIGHUP, STATS_COLLECTOR,
3557  gettext_noop("Writes temporary statistics files to the specified directory."),
3558  NULL,
3560  },
3564  },
3565 
3566  {
3567  {"synchronous_standby_names", PGC_SIGHUP, REPLICATION_MASTER,
3568  gettext_noop("Number of synchronous standbys and list of names of potential synchronous ones."),
3569  NULL,
3571  },
3573  "",
3575  },
3576 
3577  {
3578  {"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
3579  gettext_noop("Sets default text search configuration."),
3580  NULL
3581  },
3582  &TSCurrentConfig,
3583  "pg_catalog.simple",
3585  },
3586 
3587  {
3588  {"ssl_ciphers", PGC_SIGHUP, CONN_AUTH_SECURITY,
3589  gettext_noop("Sets the list of allowed SSL ciphers."),
3590  NULL,
3592  },
3593  &SSLCipherSuites,
3594 #ifdef USE_SSL
3595  "HIGH:MEDIUM:+3DES:!aNULL",
3596 #else
3597  "none",
3598 #endif
3599  NULL, NULL, NULL
3600  },
3601 
3602  {
3603  {"ssl_ecdh_curve", PGC_SIGHUP, CONN_AUTH_SECURITY,
3604  gettext_noop("Sets the curve to use for ECDH."),
3605  NULL,
3607  },
3608  &SSLECDHCurve,
3609 #ifdef USE_SSL
3610  "prime256v1",
3611 #else
3612  "none",
3613 #endif
3614  NULL, NULL, NULL
3615  },
3616 
3617  {
3618  {"ssl_dh_params_file", PGC_SIGHUP, CONN_AUTH_SECURITY,
3619  gettext_noop("Location of the SSL DH parameters file."),
3620  NULL,
3622  },
3624  "",
3625  NULL, NULL, NULL
3626  },
3627 
3628  {
3629  {"application_name", PGC_USERSET, LOGGING_WHAT,
3630  gettext_noop("Sets the application name to be reported in statistics and logs."),
3631  NULL,
3633  },
3635  "",
3637  },
3638 
3639  {
3640  {"cluster_name", PGC_POSTMASTER, PROCESS_TITLE,
3641  gettext_noop("Sets the name of the cluster, which is included in the process title."),
3642  NULL,
3643  GUC_IS_NAME
3644  },
3645  &cluster_name,
3646  "",
3647  check_cluster_name, NULL, NULL
3648  },
3649 
3650  {
3651  {"wal_consistency_checking", PGC_SUSET, DEVELOPER_OPTIONS,
3652  gettext_noop("Sets the WAL resource managers for which WAL consistency checks are done."),
3653  gettext_noop("Full-page images will be logged for all data blocks and cross-checked against the results of WAL replay."),
3655  },
3657  "",
3659  },
3660 
3661  /* End-of-list marker */
3662  {
3663  {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL, NULL
3664  }
3665 };
3666 
3667 
3669 {
3670  {
3671  {"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
3672  gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
3673  NULL
3674  },
3675  &backslash_quote,
3677  NULL, NULL, NULL
3678  },
3679 
3680  {
3681  {"bytea_output", PGC_USERSET, CLIENT_CONN_STATEMENT,
3682  gettext_noop("Sets the output format for bytea."),
3683  NULL
3684  },
3685  &bytea_output,
3687  NULL, NULL, NULL
3688  },
3689 
3690  {
3691  {"client_min_messages", PGC_USERSET, LOGGING_WHEN,
3692  gettext_noop("Sets the message levels that are sent to the client."),
3693  gettext_noop("Each level includes all the levels that follow it. The later"
3694  " the level, the fewer messages are sent.")
3695  },
3698  NULL, NULL, NULL
3699  },
3700 
3701  {
3702  {"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
3703  gettext_noop("Enables the planner to use constraints to optimize queries."),
3704  gettext_noop("Table scans will be skipped if their constraints"
3705  " guarantee that no rows match the query.")
3706  },
3709  NULL, NULL, NULL
3710  },
3711 
3712  {
3713  {"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
3714  gettext_noop("Sets the transaction isolation level of each new transaction."),
3715  NULL
3716  },
3719  NULL, NULL, NULL
3720  },
3721 
3722  {
3723  {"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
3724  gettext_noop("Sets the display format for interval values."),
3725  NULL,
3726  GUC_REPORT
3727  },
3728  &IntervalStyle,
3730  NULL, NULL, NULL
3731  },
3732 
3733  {
3734  {"log_error_verbosity", PGC_SUSET, LOGGING_WHAT,
3735  gettext_noop("Sets the verbosity of logged messages."),
3736  NULL
3737  },
3740  NULL, NULL, NULL
3741  },
3742 
3743  {
3744  {"log_min_messages", PGC_SUSET, LOGGING_WHEN,
3745  gettext_noop("Sets the message levels that are logged."),
3746  gettext_noop("Each level includes all the levels that follow it. The later"
3747  " the level, the fewer messages are sent.")
3748  },
3751  NULL, NULL, NULL
3752  },
3753 
3754  {
3755  {"log_min_error_statement", PGC_SUSET, LOGGING_WHEN,
3756  gettext_noop("Causes all statements generating error at or above this level to be logged."),
3757  gettext_noop("Each level includes all the levels that follow it. The later"
3758  " the level, the fewer messages are sent.")
3759  },
3762  NULL, NULL, NULL
3763  },
3764 
3765  {
3766  {"log_statement", PGC_SUSET, LOGGING_WHAT,
3767  gettext_noop("Sets the type of statements logged."),
3768  NULL
3769  },
3770  &log_statement,
3772  NULL, NULL, NULL
3773  },
3774 
3775  {
3776  {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
3777  gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
3778  NULL
3779  },
3780  &syslog_facility,
3781 #ifdef HAVE_SYSLOG
3782  LOG_LOCAL0,
3783 #else
3784  0,
3785 #endif
3787  NULL, assign_syslog_facility, NULL
3788  },
3789 
3790  {
3791  {"session_replication_role", PGC_SUSET, CLIENT_CONN_STATEMENT,
3792  gettext_noop("Sets the session's behavior for triggers and rewrite rules."),
3793  NULL
3794  },
3798  },
3799 
3800  {
3801  {"synchronous_commit", PGC_USERSET, WAL_SETTINGS,
3802  gettext_noop("Sets the current transaction's synchronization level."),
3803  NULL
3804  },
3807  NULL, assign_synchronous_commit, NULL
3808  },
3809 
3810  {
3811  {"archive_mode", PGC_POSTMASTER, WAL_ARCHIVING,
3812  gettext_noop("Allows archiving of WAL files using archive_command."),
3813  NULL
3814  },
3815  &XLogArchiveMode,
3817  NULL, NULL, NULL
3818  },
3819 
3820  {
3821  {"trace_recovery_messages", PGC_SIGHUP, DEVELOPER_OPTIONS,
3822  gettext_noop("Enables logging of recovery-related debugging information."),
3823  gettext_noop("Each level includes all the levels that follow it. The later"
3824  " the level, the fewer messages are sent.")
3825  },
3827 
3828  /*
3829  * client_message_level_options allows too many values, really, but
3830  * it's not worth having a separate options array for this.
3831  */
3833  NULL, NULL, NULL
3834  },
3835 
3836  {
3837  {"track_functions", PGC_SUSET, STATS_COLLECTOR,
3838  gettext_noop("Collects function-level statistics on database activity."),
3839  NULL
3840  },
3843  NULL, NULL, NULL
3844  },
3845 
3846  {
3847  {"wal_level", PGC_POSTMASTER, WAL_SETTINGS,
3848  gettext_noop("Set the level of information written to the WAL."),
3849  NULL
3850  },
3851  &wal_level,
3853  NULL, NULL, NULL
3854  },
3855 
3856  {
3857  {"dynamic_shared_memory_type", PGC_POSTMASTER, RESOURCES_MEM,
3858  gettext_noop("Selects the dynamic shared memory implementation used."),
3859  NULL
3860  },
3863  NULL, NULL, NULL
3864  },
3865 
3866  {
3867  {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
3868  gettext_noop("Selects the method used for forcing WAL updates to disk."),
3869  NULL
3870  },
3871  &sync_method,
3873  NULL, assign_xlog_sync_method, NULL
3874  },
3875 
3876  {
3877  {"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
3878  gettext_noop("Sets how binary values are to be encoded in XML."),
3879  NULL
3880  },
3881  &xmlbinary,
3883  NULL, NULL, NULL
3884  },
3885 
3886  {
3887  {"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
3888  gettext_noop("Sets whether XML data in implicit parsing and serialization "
3889  "operations is to be considered as documents or content fragments."),
3890  NULL
3891  },
3892  &xmloption,
3894  NULL, NULL, NULL
3895  },
3896 
3897  {
3898  {"huge_pages", PGC_POSTMASTER, RESOURCES_MEM,
3899  gettext_noop("Use of huge pages on Linux."),
3900  NULL
3901  },
3902  &huge_pages,
3904  NULL, NULL, NULL
3905  },
3906 
3907  {
3908  {"force_parallel_mode", PGC_USERSET, QUERY_TUNING_OTHER,
3909  gettext_noop("Forces use of parallel query facilities."),
3910  gettext_noop("If possible, run query using a parallel worker and with parallel restrictions.")
3911  },
3914  NULL, NULL, NULL
3915  },
3916 
3917  {
3918  {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY,
3919  gettext_noop("Encrypt passwords."),
3920  gettext_noop("When a password is specified in CREATE USER or "
3921  "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, "
3922  "this parameter determines whether the password is to be encrypted.")
3923  },
3926  NULL, NULL, NULL
3927  },
3928 
3929  /* End-of-list marker */
3930  {
3931  {NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
3932  }
3933 };
3934 
3935 /******** end of options list ********/
3936 
3937 
3938 /*
3939  * To allow continued support of obsolete names for GUC variables, we apply
3940  * the following mappings to any unrecognized name. Note that an old name
3941  * should be mapped to a new one only if the new variable has very similar
3942  * semantics to the old.
3943  */
3944 static const char *const map_old_guc_names[] = {
3945  "sort_mem", "work_mem",
3946  "vacuum_mem", "maintenance_work_mem",
3947  NULL
3948 };
3949 
3950 
3951 /*
3952  * Actual lookup of variables is done through this single, sorted array.
3953  */
3955 
3956 /* Current number of variables contained in the vector */
3958 
3959 /* Vector capacity */
3961 
3962 
3963 static bool guc_dirty; /* true if need to do commit/abort work */
3964 
3965 static bool reporting_enabled; /* true to enable GUC_REPORT */
3966 
3967 static int GUCNestLevel = 0; /* 1 when in main transaction */
3968 
3969 
3970 static int guc_var_compare(const void *a, const void *b);
3971 static int guc_name_compare(const char *namea, const char *nameb);
3972 static void InitializeGUCOptionsFromEnvironment(void);
3973 static void InitializeOneGUCOption(struct config_generic *gconf);
3974 static void push_old_value(struct config_generic *gconf, GucAction action);
3975 static void ReportGUCOption(struct config_generic *record);
3976 static void reapply_stacked_values(struct config_generic *variable,
3977  struct config_string *pHolder,
3978  GucStack *stack,
3979  const char *curvalue,
3980  GucContext curscontext, GucSource cursource);
3981 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
3982 static void ShowAllGUCConfig(DestReceiver *dest);
3983 static char *_ShowOption(struct config_generic *record, bool use_units);
3984 static bool validate_option_array_item(const char *name, const char *value,
3985  bool skipIfNoPermissions);
3986 static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p);
3987 static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
3988  const char *name, const char *value);
3989 
3990 
3991 /*
3992  * Some infrastructure for checking malloc/strdup/realloc calls
3993  */
3994 static void *
3995 guc_malloc(int elevel, size_t size)
3996 {
3997  void *data;
3998 
3999  /* Avoid unportable behavior of malloc(0) */
4000  if (size == 0)
4001  size = 1;
4002  data = malloc(size);
4003  if (data == NULL)
4004  ereport(elevel,
4005  (errcode(ERRCODE_OUT_OF_MEMORY),
4006  errmsg("out of memory")));
4007  return data;
4008 }
4009 
4010 static void *
4011 guc_realloc(int elevel, void *old, size_t size)
4012 {
4013  void *data;
4014 
4015  /* Avoid unportable behavior of realloc(NULL, 0) */
4016  if (old == NULL && size == 0)
4017  size = 1;
4018  data = realloc(old, size);
4019  if (data == NULL)
4020  ereport(elevel,
4021  (errcode(ERRCODE_OUT_OF_MEMORY),
4022  errmsg("out of memory")));
4023  return data;
4024 }
4025 
4026 static char *
4027 guc_strdup(int elevel, const char *src)
4028 {
4029  char *data;
4030 
4031  data = strdup(src);
4032  if (data == NULL)
4033  ereport(elevel,
4034  (errcode(ERRCODE_OUT_OF_MEMORY),
4035  errmsg("out of memory")));
4036  return data;
4037 }
4038 
4039 
4040 /*
4041  * Detect whether strval is referenced anywhere in a GUC string item
4042  */
4043 static bool
4044 string_field_used(struct config_string *conf, char *strval)
4045 {
4046  GucStack *stack;
4047 
4048  if (strval == *(conf->variable) ||
4049  strval == conf->reset_val ||
4050  strval == conf->boot_val)
4051  return true;
4052  for (stack = conf->gen.stack; stack; stack = stack->prev)
4053  {
4054  if (strval == stack->prior.val.stringval ||
4055  strval == stack->masked.val.stringval)
4056  return true;
4057  }
4058  return false;
4059 }
4060 
4061 /*
4062  * Support for assigning to a field of a string GUC item. Free the prior
4063  * value if it's not referenced anywhere else in the item (including stacked
4064  * states).
4065  */
4066 static void
4067 set_string_field(struct config_string *conf, char **field, char *newval)
4068 {
4069  char *oldval = *field;
4070 
4071  /* Do the assignment */
4072  *field = newval;
4073 
4074  /* Free old value if it's not NULL and isn't referenced anymore */
4075  if (oldval && !string_field_used(conf, oldval))
4076  free(oldval);
4077 }
4078 
4079 /*
4080  * Detect whether an "extra" struct is referenced anywhere in a GUC item
4081  */
4082 static bool
4083 extra_field_used(struct config_generic *gconf, void *extra)
4084 {
4085  GucStack *stack;
4086 
4087  if (extra == gconf->extra)
4088  return true;
4089  switch (gconf->vartype)
4090  {
4091  case PGC_BOOL:
4092  if (extra == ((struct config_bool *) gconf)->reset_extra)
4093  return true;
4094  break;
4095  case PGC_INT:
4096  if (extra == ((struct config_int *) gconf)->reset_extra)
4097  return true;
4098  break;
4099  case PGC_REAL:
4100  if (extra == ((struct config_real *) gconf)->reset_extra)
4101  return true;
4102  break;
4103  case PGC_STRING:
4104  if (extra == ((struct config_string *) gconf)->reset_extra)
4105  return true;
4106  break;
4107  case PGC_ENUM:
4108  if (extra == ((struct config_enum *) gconf)->reset_extra)
4109  return true;
4110  break;
4111  }
4112  for (stack = gconf->stack; stack; stack = stack->prev)
4113  {
4114  if (extra == stack->prior.extra ||
4115  extra == stack->masked.extra)
4116  return true;
4117  }
4118 
4119  return false;
4120 }
4121 
4122 /*
4123  * Support for assigning to an "extra" field of a GUC item. Free the prior
4124  * value if it's not referenced anywhere else in the item (including stacked
4125  * states).
4126  */
4127 static void
4128 set_extra_field(struct config_generic *gconf, void **field, void *newval)
4129 {
4130  void *oldval = *field;
4131 
4132  /* Do the assignment */
4133  *field = newval;
4134 
4135  /* Free old value if it's not NULL and isn't referenced anymore */
4136  if (oldval && !extra_field_used(gconf, oldval))
4137  free(oldval);
4138 }
4139 
4140 /*
4141  * Support for copying a variable's active value into a stack entry.
4142  * The "extra" field associated with the active value is copied, too.
4143  *
4144  * NB: be sure stringval and extra fields of a new stack entry are
4145  * initialized to NULL before this is used, else we'll try to free() them.
4146  */
4147 static void
4149 {
4150  switch (gconf->vartype)
4151  {
4152  case PGC_BOOL:
4153  val->val.boolval =
4154  *((struct config_bool *) gconf)->variable;
4155  break;
4156  case PGC_INT:
4157  val->val.intval =
4158  *((struct config_int *) gconf)->variable;
4159  break;
4160  case PGC_REAL:
4161  val->val.realval =
4162  *((struct config_real *) gconf)->variable;
4163  break;
4164  case PGC_STRING:
4165  set_string_field((struct config_string *) gconf,
4166  &(val->val.stringval),
4167  *((struct config_string *) gconf)->variable);
4168  break;
4169  case PGC_ENUM:
4170  val->val.enumval =
4171  *((struct config_enum *) gconf)->variable;
4172  break;
4173  }
4174  set_extra_field(gconf, &(val->extra), gconf->extra);
4175 }
4176 
4177 /*
4178  * Support for discarding a no-longer-needed value in a stack entry.
4179  * The "extra" field associated with the stack entry is cleared, too.
4180  */
4181 static void
4183 {
4184  switch (gconf->vartype)
4185  {
4186  case PGC_BOOL:
4187  case PGC_INT:
4188  case PGC_REAL:
4189  case PGC_ENUM:
4190  /* no need to do anything */
4191  break;
4192  case PGC_STRING:
4193  set_string_field((struct config_string *) gconf,
4194  &(val->val.stringval),
4195  NULL);
4196  break;
4197  }
4198  set_extra_field(gconf, &(val->extra), NULL);
4199 }
4200 
4201 
4202 /*
4203  * Fetch the sorted array pointer (exported for help_config.c's use ONLY)
4204  */
4205 struct config_generic **
4207 {
4208  return guc_variables;
4209 }
4210 
4211 
4212 /*
4213  * Build the sorted array. This is split out so that it could be
4214  * re-executed after startup (e.g., we could allow loadable modules to
4215  * add vars, and then we'd need to re-sort).
4216  */
4217 void
4219 {
4220  int size_vars;
4221  int num_vars = 0;
4222  struct config_generic **guc_vars;
4223  int i;
4224 
4225  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4226  {
4227  struct config_bool *conf = &ConfigureNamesBool[i];
4228 
4229  /* Rather than requiring vartype to be filled in by hand, do this: */
4230  conf->gen.vartype = PGC_BOOL;
4231  num_vars++;
4232  }
4233 
4234  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4235  {
4236  struct config_int *conf = &ConfigureNamesInt[i];
4237 
4238  conf->gen.vartype = PGC_INT;
4239  num_vars++;
4240  }
4241 
4242  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4243  {
4244  struct config_real *conf = &ConfigureNamesReal[i];
4245 
4246  conf->gen.vartype = PGC_REAL;
4247  num_vars++;
4248  }
4249 
4250  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4251  {
4252  struct config_string *conf = &ConfigureNamesString[i];
4253 
4254  conf->gen.vartype = PGC_STRING;
4255  num_vars++;
4256  }
4257 
4258  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4259  {
4260  struct config_enum *conf = &ConfigureNamesEnum[i];
4261 
4262  conf->gen.vartype = PGC_ENUM;
4263  num_vars++;
4264  }
4265 
4266  /*
4267  * Create table with 20% slack
4268  */
4269  size_vars = num_vars + num_vars / 4;
4270 
4271  guc_vars = (struct config_generic **)
4272  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
4273 
4274  num_vars = 0;
4275 
4276  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4277  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
4278 
4279  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4280  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
4281 
4282  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4283  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
4284 
4285  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4286  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
4287 
4288  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4289  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
4290 
4291  if (guc_variables)
4292  free(guc_variables);
4293  guc_variables = guc_vars;
4294  num_guc_variables = num_vars;
4295  size_guc_variables = size_vars;
4296  qsort((void *) guc_variables, num_guc_variables,
4297  sizeof(struct config_generic *), guc_var_compare);
4298 }
4299 
4300 /*
4301  * Add a new GUC variable to the list of known variables. The
4302  * list is expanded if needed.
4303  */
4304 static bool
4305 add_guc_variable(struct config_generic *var, int elevel)
4306 {
4307  if (num_guc_variables + 1 >= size_guc_variables)
4308  {
4309  /*
4310  * Increase the vector by 25%
4311  */
4312  int size_vars = size_guc_variables + size_guc_variables / 4;
4313  struct config_generic **guc_vars;
4314 
4315  if (size_vars == 0)
4316  {
4317  size_vars = 100;
4318  guc_vars = (struct config_generic **)
4319  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
4320  }
4321  else
4322  {
4323  guc_vars = (struct config_generic **)
4324  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
4325  }
4326 
4327  if (guc_vars == NULL)
4328  return false; /* out of memory */
4329 
4330  guc_variables = guc_vars;
4331  size_guc_variables = size_vars;
4332  }
4333  guc_variables[num_guc_variables++] = var;
4334  qsort((void *) guc_variables, num_guc_variables,
4335  sizeof(struct config_generic *), guc_var_compare);
4336  return true;
4337 }
4338 
4339 /*
4340  * Create and add a placeholder variable for a custom variable name.
4341  */
4342 static struct config_generic *
4343 add_placeholder_variable(const char *name, int elevel)
4344 {
4345  size_t sz = sizeof(struct config_string) + sizeof(char *);
4346  struct config_string *var;
4347  struct config_generic *gen;
4348 
4349  var = (struct config_string *) guc_malloc(elevel, sz);
4350  if (var == NULL)
4351  return NULL;
4352  memset(var, 0, sz);
4353  gen = &var->gen;
4354 
4355  gen->name = guc_strdup(elevel, name);
4356  if (gen->name == NULL)
4357  {
4358  free(var);
4359  return NULL;
4360  }
4361 
4362  gen->context = PGC_USERSET;
4363  gen->group = CUSTOM_OPTIONS;
4364  gen->short_desc = "GUC placeholder variable";
4366  gen->vartype = PGC_STRING;
4367 
4368  /*
4369  * The char* is allocated at the end of the struct since we have no
4370  * 'static' place to point to. Note that the current value, as well as
4371  * the boot and reset values, start out NULL.
4372  */
4373  var->variable = (char **) (var + 1);
4374 
4375  if (!add_guc_variable((struct config_generic *) var, elevel))
4376  {
4377  free((void *) gen->name);
4378  free(var);
4379  return NULL;
4380  }
4381 
4382  return gen;
4383 }
4384 
4385 /*
4386  * Look up option NAME. If it exists, return a pointer to its record,
4387  * else return NULL. If create_placeholders is true, we'll create a
4388  * placeholder record for a valid-looking custom variable name.
4389  */
4390 static struct config_generic *
4391 find_option(const char *name, bool create_placeholders, int elevel)
4392 {
4393  const char **key = &name;
4394  struct config_generic **res;
4395  int i;
4396 
4397  Assert(name);
4398 
4399  /*
4400  * By equating const char ** with struct config_generic *, we are assuming
4401  * the name field is first in config_generic.
4402  */
4403  res = (struct config_generic **) bsearch((void *) &key,
4404  (void *) guc_variables,
4405  num_guc_variables,
4406  sizeof(struct config_generic *),
4407  guc_var_compare);
4408  if (res)
4409  return *res;
4410 
4411  /*
4412  * See if the name is an obsolete name for a variable. We assume that the
4413  * set of supported old names is short enough that a brute-force search is
4414  * the best way.
4415  */
4416  for (i = 0; map_old_guc_names[i] != NULL; i += 2)
4417  {
4418  if (guc_name_compare(name, map_old_guc_names[i]) == 0)
4419  return find_option(map_old_guc_names[i + 1], false, elevel);
4420  }
4421 
4422  if (create_placeholders)
4423  {
4424  /*
4425  * Check if the name is qualified, and if so, add a placeholder.
4426  */
4427  if (strchr(name, GUC_QUALIFIER_SEPARATOR) != NULL)
4428  return add_placeholder_variable(name, elevel);
4429  }
4430 
4431  /* Unknown name */
4432  return NULL;
4433 }
4434 
4435 
4436 /*
4437  * comparator for qsorting and bsearching guc_variables array
4438  */
4439 static int
4440 guc_var_compare(const void *a, const void *b)
4441 {
4442  const struct config_generic *confa = *(struct config_generic *const *) a;
4443  const struct config_generic *confb = *(struct config_generic *const *) b;
4444 
4445  return guc_name_compare(confa->name, confb->name);
4446 }
4447 
4448 /*
4449  * the bare comparison function for GUC names
4450  */
4451 static int
4452 guc_name_compare(const char *namea, const char *nameb)
4453 {
4454  /*
4455  * The temptation to use strcasecmp() here must be resisted, because the
4456  * array ordering has to remain stable across setlocale() calls. So, build
4457  * our own with a simple ASCII-only downcasing.
4458  */
4459  while (*namea && *nameb)
4460  {
4461  char cha = *namea++;
4462  char chb = *nameb++;
4463 
4464  if (cha >= 'A' && cha <= 'Z')
4465  cha += 'a' - 'A';
4466  if (chb >= 'A' && chb <= 'Z')
4467  chb += 'a' - 'A';
4468  if (cha != chb)
4469  return cha - chb;
4470  }
4471  if (*namea)
4472  return 1; /* a is longer */
4473  if (*nameb)
4474  return -1; /* b is longer */
4475  return 0;
4476 }
4477 
4478 
4479 /*
4480  * Initialize GUC options during program startup.
4481  *
4482  * Note that we cannot read the config file yet, since we have not yet
4483  * processed command-line switches.
4484  */
4485 void
4487 {
4488  int i;
4489 
4490  /*
4491  * Before log_line_prefix could possibly receive a nonempty setting, make
4492  * sure that timezone processing is minimally alive (see elog.c).
4493  */
4495 
4496  /*
4497  * Build sorted array of all GUC variables.
4498  */
4500 
4501  /*
4502  * Load all variables with their compiled-in defaults, and initialize
4503  * status fields as needed.
4504  */
4505  for (i = 0; i < num_guc_variables; i++)
4506  {
4507  InitializeOneGUCOption(guc_variables[i]);
4508  }
4509 
4510  guc_dirty = false;
4511 
4512  reporting_enabled = false;
4513 
4514  /*
4515  * Prevent any attempt to override the transaction modes from
4516  * non-interactive sources.
4517  */
4518  SetConfigOption("transaction_isolation", "default",
4520  SetConfigOption("transaction_read_only", "no",
4522  SetConfigOption("transaction_deferrable", "no",
4524 
4525  /*
4526  * For historical reasons, some GUC parameters can receive defaults from
4527  * environment variables. Process those settings.
4528  */
4530 }
4531 
4532 /*
4533  * Assign any GUC values that can come from the server's environment.
4534  *
4535  * This is called from InitializeGUCOptions, and also from ProcessConfigFile
4536  * to deal with the possibility that a setting has been removed from
4537  * postgresql.conf and should now get a value from the environment.
4538  * (The latter is a kludge that should probably go away someday; if so,
4539  * fold this back into InitializeGUCOptions.)
4540  */
4541 static void
4543 {
4544  char *env;
4545  long stack_rlimit;
4546 
4547  env = getenv("PGPORT");
4548  if (env != NULL)
4550 
4551  env = getenv("PGDATESTYLE");
4552  if (env != NULL)
4553  SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
4554 
4555  env = getenv("PGCLIENTENCODING");
4556  if (env != NULL)
4557  SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
4558 
4559  /*
4560  * rlimit isn't exactly an "environment variable", but it behaves about
4561  * the same. If we can identify the platform stack depth rlimit, increase
4562  * default stack depth setting up to whatever is safe (but at most 2MB).
4563  */
4564  stack_rlimit = get_stack_depth_rlimit();
4565  if (stack_rlimit > 0)
4566  {
4567  long new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;
4568 
4569  if (new_limit > 100)
4570  {
4571  char limbuf[16];
4572 
4573  new_limit = Min(new_limit, 2048);
4574  sprintf(limbuf, "%ld", new_limit);
4575  SetConfigOption("max_stack_depth", limbuf,
4577  }
4578  }
4579 }
4580 
4581 /*
4582  * Initialize one GUC option variable to its compiled-in default.
4583  *
4584  * Note: the reason for calling check_hooks is not that we think the boot_val
4585  * might fail, but that the hooks might wish to compute an "extra" struct.
4586  */
4587 static void
4589 {
4590  gconf->status = 0;
4591  gconf->source = PGC_S_DEFAULT;
4592  gconf->reset_source = PGC_S_DEFAULT;
4593  gconf->scontext = PGC_INTERNAL;
4594  gconf->reset_scontext = PGC_INTERNAL;
4595  gconf->stack = NULL;
4596  gconf->extra = NULL;
4597  gconf->sourcefile = NULL;
4598  gconf->sourceline = 0;
4599 
4600  switch (gconf->vartype)
4601  {
4602  case PGC_BOOL:
4603  {
4604  struct config_bool *conf = (struct config_bool *) gconf;
4605  bool newval = conf->boot_val;
4606  void *extra = NULL;
4607 
4608  if (!call_bool_check_hook(conf, &newval, &extra,
4609  PGC_S_DEFAULT, LOG))
4610  elog(FATAL, "failed to initialize %s to %d",
4611  conf->gen.name, (int) newval);
4612  if (conf->assign_hook)
4613  conf->assign_hook(newval, extra);
4614  *conf->variable = conf->reset_val = newval;
4615  conf->gen.extra = conf->reset_extra = extra;
4616  break;
4617  }
4618  case PGC_INT:
4619  {
4620  struct config_int *conf = (struct config_int *) gconf;
4621  int newval = conf->boot_val;
4622  void *extra = NULL;
4623 
4624  Assert(newval >= conf->min);
4625  Assert(newval <= conf->max);
4626  if (!call_int_check_hook(conf, &newval, &extra,
4627  PGC_S_DEFAULT, LOG))
4628  elog(FATAL, "failed to initialize %s to %d",
4629  conf->gen.name, newval);
4630  if (conf->assign_hook)
4631  conf->assign_hook(newval, extra);
4632  *conf->variable = conf->reset_val = newval;
4633  conf->gen.extra = conf->reset_extra = extra;
4634  break;
4635  }
4636  case PGC_REAL:
4637  {
4638  struct config_real *conf = (struct config_real *) gconf;
4639  double newval = conf->boot_val;
4640  void *extra = NULL;
4641 
4642  Assert(newval >= conf->min);
4643  Assert(newval <= conf->max);
4644  if (!call_real_check_hook(conf, &newval, &extra,
4645  PGC_S_DEFAULT, LOG))
4646  elog(FATAL, "failed to initialize %s to %g",
4647  conf->gen.name, newval);
4648  if (conf->assign_hook)
4649  conf->assign_hook(newval, extra);
4650  *conf->variable = conf->reset_val = newval;
4651  conf->gen.extra = conf->reset_extra = extra;
4652  break;
4653  }
4654  case PGC_STRING:
4655  {
4656  struct config_string *conf = (struct config_string *) gconf;
4657  char *newval;
4658  void *extra = NULL;
4659 
4660  /* non-NULL boot_val must always get strdup'd */
4661  if (conf->boot_val != NULL)
4662  newval = guc_strdup(FATAL, conf->boot_val);
4663  else
4664  newval = NULL;
4665 
4666  if (!call_string_check_hook(conf, &newval, &extra,
4667  PGC_S_DEFAULT, LOG))
4668  elog(FATAL, "failed to initialize %s to \"%s\"",
4669  conf->gen.name, newval ? newval : "");
4670  if (conf->assign_hook)
4671  conf->assign_hook(newval, extra);
4672  *conf->variable = conf->reset_val = newval;
4673  conf->gen.extra = conf->reset_extra = extra;
4674  break;
4675  }
4676  case PGC_ENUM:
4677  {
4678  struct config_enum *conf = (struct config_enum *) gconf;
4679  int newval = conf->boot_val;
4680  void *extra = NULL;
4681 
4682  if (!call_enum_check_hook(conf, &newval, &extra,
4683  PGC_S_DEFAULT, LOG))
4684  elog(FATAL, "failed to initialize %s to %d",
4685  conf->gen.name, newval);
4686  if (conf->assign_hook)
4687  conf->assign_hook(newval, extra);
4688  *conf->variable = conf->reset_val = newval;
4689  conf->gen.extra = conf->reset_extra = extra;
4690  break;
4691  }
4692  }
4693 }
4694 
4695 
4696 /*
4697  * Select the configuration files and data directory to be used, and
4698  * do the initial read of postgresql.conf.
4699  *
4700  * This is called after processing command-line switches.
4701  * userDoption is the -D switch value if any (NULL if unspecified).
4702  * progname is just for use in error messages.
4703  *
4704  * Returns true on success; on failure, prints a suitable error message
4705  * to stderr and returns false.
4706  */
4707 bool
4708 SelectConfigFiles(const char *userDoption, const char *progname)
4709 {
4710  char *configdir;
4711  char *fname;
4712  struct stat stat_buf;
4713 
4714  /* configdir is -D option, or $PGDATA if no -D */
4715  if (userDoption)
4716  configdir = make_absolute_path(userDoption);
4717  else
4718  configdir = make_absolute_path(getenv("PGDATA"));
4719 
4720  if (configdir && stat(configdir, &stat_buf) != 0)
4721  {
4722  write_stderr("%s: could not access directory \"%s\": %s\n",
4723  progname,
4724  configdir,
4725  strerror(errno));
4726  if (errno == ENOENT)
4727  write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
4728  return false;
4729  }
4730 
4731  /*
4732  * Find the configuration file: if config_file was specified on the
4733  * command line, use it, else use configdir/postgresql.conf. In any case
4734  * ensure the result is an absolute path, so that it will be interpreted
4735  * the same way by future backends.
4736  */
4737  if (ConfigFileName)
4738  fname = make_absolute_path(ConfigFileName);
4739  else if (configdir)
4740  {
4741  fname = guc_malloc(FATAL,
4742  strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
4743  sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
4744  }
4745  else
4746  {
4747  write_stderr("%s does not know where to find the server configuration file.\n"
4748  "You must specify the --config-file or -D invocation "
4749  "option or set the PGDATA environment variable.\n",
4750  progname);
4751  return false;
4752  }
4753 
4754  /*
4755  * Set the ConfigFileName GUC variable to its final value, ensuring that
4756  * it can't be overridden later.
4757  */
4758  SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4759  free(fname);
4760 
4761  /*
4762  * Now read the config file for the first time.
4763  */
4764  if (stat(ConfigFileName, &stat_buf) != 0)
4765  {
4766  write_stderr("%s: could not access the server configuration file \"%s\": %s\n",
4767  progname, ConfigFileName, strerror(errno));
4768  free(configdir);
4769  return false;
4770  }
4771 
4772  /*
4773  * Read the configuration file for the first time. This time only the
4774  * data_directory parameter is picked up to determine the data directory,
4775  * so that we can read the PG_AUTOCONF_FILENAME file next time.
4776  */
4778 
4779  /*
4780  * If the data_directory GUC variable has been set, use that as DataDir;
4781  * otherwise use configdir if set; else punt.
4782  *
4783  * Note: SetDataDir will copy and absolute-ize its argument, so we don't
4784  * have to.
4785  */
4786  if (data_directory)
4787  SetDataDir(data_directory);
4788  else if (configdir)
4789  SetDataDir(configdir);
4790  else
4791  {
4792  write_stderr("%s does not know where to find the database system data.\n"
4793  "This can be specified as \"data_directory\" in \"%s\", "
4794  "or by the -D invocation option, or by the "
4795  "PGDATA environment variable.\n",
4796  progname, ConfigFileName);
4797  return false;
4798  }
4799 
4800  /*
4801  * Reflect the final DataDir value back into the data_directory GUC var.
4802  * (If you are wondering why we don't just make them a single variable,
4803  * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
4804  * child backends specially. XXX is that still true? Given that we now
4805  * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
4806  * DataDir in advance.)
4807  */
4809 
4810  /*
4811  * Now read the config file a second time, allowing any settings in the
4812  * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but
4813  * since we have to determine the DataDir before we can find the autoconf
4814  * file, the alternatives seem worse.)
4815  */
4817 
4818  /*
4819  * If timezone_abbreviations wasn't set in the configuration file, install
4820  * the default value. We do it this way because we can't safely install a
4821  * "real" value until my_exec_path is set, which may not have happened
4822  * when InitializeGUCOptions runs, so the bootstrap default value cannot
4823  * be the real desired default.
4824  */
4826 
4827  /*
4828  * Figure out where pg_hba.conf is, and make sure the path is absolute.
4829  */
4830  if (HbaFileName)
4831  fname = make_absolute_path(HbaFileName);
4832  else if (configdir)
4833  {
4834  fname = guc_malloc(FATAL,
4835  strlen(configdir) + strlen(HBA_FILENAME) + 2);
4836  sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
4837  }
4838  else
4839  {
4840  write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
4841  "This can be specified as \"hba_file\" in \"%s\", "
4842  "or by the -D invocation option, or by the "
4843  "PGDATA environment variable.\n",
4844  progname, ConfigFileName);
4845  return false;
4846  }
4847  SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4848  free(fname);
4849 
4850  /*
4851  * Likewise for pg_ident.conf.
4852  */
4853  if (IdentFileName)
4854  fname = make_absolute_path(IdentFileName);
4855  else if (configdir)
4856  {
4857  fname = guc_malloc(FATAL,
4858  strlen(configdir) + strlen(IDENT_FILENAME) + 2);
4859  sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
4860  }
4861  else
4862  {
4863  write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
4864  "This can be specified as \"ident_file\" in \"%s\", "
4865  "or by the -D invocation option, or by the "
4866  "PGDATA environment variable.\n",
4867  progname, ConfigFileName);
4868  return false;
4869  }
4870  SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
4871  free(fname);
4872 
4873  free(configdir);
4874 
4875  return true;
4876 }
4877 
4878 
4879 /*
4880  * Reset all options to their saved default values (implements RESET ALL)
4881  */
4882 void
4884 {
4885  int i;
4886 
4887  for (i = 0; i < num_guc_variables; i++)
4888  {
4889  struct config_generic *gconf = guc_variables[i];
4890 
4891  /* Don't reset non-SET-able values */
4892  if (gconf->context != PGC_SUSET &&
4893  gconf->context != PGC_USERSET)
4894  continue;
4895  /* Don't reset if special exclusion from RESET ALL */
4896  if (gconf->flags & GUC_NO_RESET_ALL)
4897  continue;
4898  /* No need to reset if wasn't SET */
4899  if (gconf->source <= PGC_S_OVERRIDE)
4900  continue;
4901 
4902  /* Save old value to support transaction abort */
4904 
4905  switch (gconf->vartype)
4906  {
4907  case PGC_BOOL:
4908  {
4909  struct config_bool *conf = (struct config_bool *) gconf;
4910 
4911  if (conf->assign_hook)
4912  conf->assign_hook(conf->reset_val,
4913  conf->reset_extra);
4914  *conf->variable = conf->reset_val;
4915  set_extra_field(&conf->gen, &conf->gen.extra,
4916  conf->reset_extra);
4917  break;
4918  }
4919  case PGC_INT:
4920  {
4921  struct config_int *conf = (struct config_int *) gconf;
4922 
4923  if (conf->assign_hook)
4924  conf->assign_hook(conf->reset_val,
4925  conf->reset_extra);
4926  *conf->variable = conf->reset_val;
4927  set_extra_field(&conf->gen, &conf->gen.extra,
4928  conf->reset_extra);
4929  break;
4930  }
4931  case PGC_REAL:
4932  {
4933  struct config_real *conf = (struct config_real *) gconf;
4934 
4935  if (conf->assign_hook)
4936  conf->assign_hook(conf->reset_val,
4937  conf->reset_extra);
4938  *conf->variable = conf->reset_val;
4939  set_extra_field(&conf->gen, &conf->gen.extra,
4940  conf->reset_extra);
4941  break;
4942  }
4943  case PGC_STRING:
4944  {
4945  struct config_string *conf = (struct config_string *) gconf;
4946 
4947  if (conf->assign_hook)
4948  conf->assign_hook(conf->reset_val,
4949  conf->reset_extra);
4950  set_string_field(conf, conf->variable, conf->reset_val);
4951  set_extra_field(&conf->gen, &conf->gen.extra,
4952  conf->reset_extra);
4953  break;
4954  }
4955  case PGC_ENUM:
4956  {
4957  struct config_enum *conf = (struct config_enum *) gconf;
4958 
4959  if (conf->assign_hook)
4960  conf->assign_hook(conf->reset_val,
4961  conf->reset_extra);
4962  *conf->variable = conf->reset_val;
4963  set_extra_field(&conf->gen, &conf->gen.extra,
4964  conf->reset_extra);
4965  break;
4966  }
4967  }
4968 
4969  gconf->source = gconf->reset_source;
4970  gconf->scontext = gconf->reset_scontext;
4971 
4972  if (gconf->flags & GUC_REPORT)
4973  ReportGUCOption(gconf);
4974  }
4975 }
4976 
4977 
4978 /*
4979  * push_old_value
4980  * Push previous state during transactional assignment to a GUC variable.
4981  */
4982 static void
4984 {
4985  GucStack *stack;
4986 
4987  /* If we're not inside a nest level, do nothing */
4988  if (GUCNestLevel == 0)
4989  return;
4990 
4991  /* Do we already have a stack entry of the current nest level? */
4992  stack = gconf->stack;
4993  if (stack && stack->nest_level >= GUCNestLevel)
4994  {
4995  /* Yes, so adjust its state if necessary */
4996  Assert(stack->nest_level == GUCNestLevel);
4997  switch (action)
4998  {
4999  case GUC_ACTION_SET:
5000  /* SET overrides any prior action at same nest level */
5001  if (stack->state == GUC_SET_LOCAL)
5002  {
5003  /* must discard old masked value */
5004  discard_stack_value(gconf, &stack->masked);
5005  }
5006  stack->state = GUC_SET;
5007  break;
5008  case GUC_ACTION_LOCAL:
5009  if (stack->state == GUC_SET)
5010  {
5011  /* SET followed by SET LOCAL, remember SET's value */
5012  stack->masked_scontext = gconf->scontext;
5013  set_stack_value(gconf, &stack->masked);
5014  stack->state = GUC_SET_LOCAL;
5015  }
5016  /* in all other cases, no change to stack entry */
5017  break;
5018  case GUC_ACTION_SAVE:
5019  /* Could only have a prior SAVE of same variable */
5020  Assert(stack->state == GUC_SAVE);
5021  break;
5022  }
5023  Assert(guc_dirty); /* must be set already */
5024  return;
5025  }
5026 
5027  /*
5028  * Push a new stack entry
5029  *
5030  * We keep all the stack entries in TopTransactionContext for simplicity.
5031  */
5033  sizeof(GucStack));
5034 
5035  stack->prev = gconf->stack;
5036  stack->nest_level = GUCNestLevel;
5037  switch (action)
5038  {
5039  case GUC_ACTION_SET:
5040  stack->state = GUC_SET;
5041  break;
5042  case GUC_ACTION_LOCAL:
5043  stack->state = GUC_LOCAL;
5044  break;
5045  case GUC_ACTION_SAVE:
5046  stack->state = GUC_SAVE;
5047  break;
5048  }
5049  stack->source = gconf->source;
5050  stack->scontext = gconf->scontext;
5051  set_stack_value(gconf, &stack->prior);
5052 
5053  gconf->stack = stack;
5054 
5055  /* Ensure we remember to pop at end of xact */
5056  guc_dirty = true;
5057 }
5058 
5059 
5060 /*
5061  * Do GUC processing at main transaction start.
5062  */
5063 void
5065 {
5066  /*
5067  * The nest level should be 0 between transactions; if it isn't, somebody
5068  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
5069  * throw a warning but make no other effort to clean up.
5070  */
5071  if (GUCNestLevel != 0)
5072  elog(WARNING, "GUC nest level = %d at transaction start",
5073  GUCNestLevel);
5074  GUCNestLevel = 1;
5075 }
5076 
5077 /*
5078  * Enter a new nesting level for GUC values. This is called at subtransaction
5079  * start, and when entering a function that has proconfig settings, and in
5080  * some other places where we want to set GUC variables transiently.
5081  * NOTE we must not risk error here, else subtransaction start will be unhappy.
5082  */
5083 int
5085 {
5086  return ++GUCNestLevel;
5087 }
5088 
5089 /*
5090  * Do GUC processing at transaction or subtransaction commit or abort, or
5091  * when exiting a function that has proconfig settings, or when undoing a
5092  * transient assignment to some GUC variables. (The name is thus a bit of
5093  * a misnomer; perhaps it should be ExitGUCNestLevel or some such.)
5094  * During abort, we discard all GUC settings that were applied at nesting
5095  * levels >= nestLevel. nestLevel == 1 corresponds to the main transaction.
5096  */
5097 void
5098 AtEOXact_GUC(bool isCommit, int nestLevel)
5099 {
5100  bool still_dirty;
5101  int i;
5102 
5103  /*
5104  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
5105  * abort, if there is a failure during transaction start before
5106  * AtStart_GUC is called.
5107  */
5108  Assert(nestLevel > 0 &&
5109  (nestLevel <= GUCNestLevel ||
5110  (nestLevel == GUCNestLevel + 1 && !isCommit)));
5111 
5112  /* Quick exit if nothing's changed in this transaction */
5113  if (!guc_dirty)
5114  {
5115  GUCNestLevel = nestLevel - 1;
5116  return;
5117  }
5118 
5119  still_dirty = false;
5120  for (i = 0; i < num_guc_variables; i++)
5121  {
5122  struct config_generic *gconf = guc_variables[i];
5123  GucStack *stack;
5124 
5125  /*
5126  * Process and pop each stack entry within the nest level. To simplify
5127  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
5128  * we allow failure exit from code that uses a local nest level to be
5129  * recovered at the surrounding transaction or subtransaction abort;
5130  * so there could be more than one stack entry to pop.
5131  */
5132  while ((stack = gconf->stack) != NULL &&
5133  stack->nest_level >= nestLevel)
5134  {
5135  GucStack *prev = stack->prev;
5136  bool restorePrior = false;
5137  bool restoreMasked = false;
5138  bool changed;
5139 
5140  /*
5141  * In this next bit, if we don't set either restorePrior or
5142  * restoreMasked, we must "discard" any unwanted fields of the
5143  * stack entries to avoid leaking memory. If we do set one of
5144  * those flags, unused fields will be cleaned up after restoring.
5145  */
5146  if (!isCommit) /* if abort, always restore prior value */
5147  restorePrior = true;
5148  else if (stack->state == GUC_SAVE)
5149  restorePrior = true;
5150  else if (stack->nest_level == 1)
5151  {
5152  /* transaction commit */
5153  if (stack->state == GUC_SET_LOCAL)
5154  restoreMasked = true;
5155  else if (stack->state == GUC_SET)
5156  {
5157  /* we keep the current active value */
5158  discard_stack_value(gconf, &stack->prior);
5159  }
5160  else /* must be GUC_LOCAL */
5161  restorePrior = true;
5162  }
5163  else if (prev == NULL ||
5164  prev->nest_level < stack->nest_level - 1)
5165  {
5166  /* decrement entry's level and do not pop it */
5167  stack->nest_level--;
5168  continue;
5169  }
5170  else
5171  {
5172  /*
5173  * We have to merge this stack entry into prev. See README for
5174  * discussion of this bit.
5175  */
5176  switch (stack->state)
5177  {
5178  case GUC_SAVE:
5179  Assert(false); /* can't get here */
5180 
5181  case GUC_SET:
5182  /* next level always becomes SET */
5183  discard_stack_value(gconf, &stack->prior);
5184  if (prev->state == GUC_SET_LOCAL)
5185  discard_stack_value(gconf, &prev->masked);
5186  prev->state = GUC_SET;
5187  break;
5188 
5189  case GUC_LOCAL:
5190  if (prev->state == GUC_SET)
5191  {
5192  /* LOCAL migrates down */
5193  prev->masked_scontext = stack->scontext;
5194  prev->masked = stack->prior;
5195  prev->state = GUC_SET_LOCAL;
5196  }
5197  else
5198  {
5199  /* else just forget this stack level */
5200  discard_stack_value(gconf, &stack->prior);
5201  }
5202  break;
5203 
5204  case GUC_SET_LOCAL:
5205  /* prior state at this level no longer wanted */
5206  discard_stack_value(gconf, &stack->prior);
5207  /* copy down the masked state */
5208  prev->masked_scontext = stack->masked_scontext;
5209  if (prev->state == GUC_SET_LOCAL)
5210  discard_stack_value(gconf, &prev->masked);
5211  prev->masked = stack->masked;
5212  prev->state = GUC_SET_LOCAL;
5213  break;
5214  }
5215  }
5216 
5217  changed = false;
5218 
5219  if (restorePrior || restoreMasked)
5220  {
5221  /* Perform appropriate restoration of the stacked value */
5222  config_var_value newvalue;
5223  GucSource newsource;
5224  GucContext newscontext;
5225 
5226  if (restoreMasked)
5227  {
5228  newvalue = stack->masked;
5229  newsource = PGC_S_SESSION;
5230  newscontext = stack->masked_scontext;
5231  }
5232  else
5233  {
5234  newvalue = stack->prior;
5235  newsource = stack->source;
5236  newscontext = stack->scontext;
5237  }
5238 
5239  switch (gconf->vartype)
5240  {
5241  case PGC_BOOL:
5242  {
5243  struct config_bool *conf = (struct config_bool *) gconf;
5244  bool newval = newvalue.val.boolval;
5245  void *newextra = newvalue.extra;
5246 
5247  if (*conf->variable != newval ||
5248  conf->gen.extra != newextra)
5249  {
5250  if (conf->assign_hook)
5251  conf->assign_hook(newval, newextra);
5252  *conf->variable = newval;
5253  set_extra_field(&conf->gen, &conf->gen.extra,
5254  newextra);
5255  changed = true;
5256  }
5257  break;
5258  }
5259  case PGC_INT:
5260  {
5261  struct config_int *conf = (struct config_int *) gconf;
5262  int newval = newvalue.val.intval;
5263  void *newextra = newvalue.extra;
5264 
5265  if (*conf->variable != newval ||
5266  conf->gen.extra != newextra)
5267  {
5268  if (conf->assign_hook)
5269  conf->assign_hook(newval, newextra);
5270  *conf->variable = newval;
5271  set_extra_field(&conf->gen, &conf->gen.extra,
5272  newextra);
5273  changed = true;
5274  }
5275  break;
5276  }
5277  case PGC_REAL:
5278  {
5279  struct config_real *conf = (struct config_real *) gconf;
5280  double newval = newvalue.val.realval;
5281  void *newextra = newvalue.extra;
5282 
5283  if (*conf->variable != newval ||
5284  conf->gen.extra != newextra)
5285  {
5286  if (conf->assign_hook)
5287  conf->assign_hook(newval, newextra);
5288  *conf->variable = newval;
5289  set_extra_field(&conf->gen, &conf->gen.extra,
5290  newextra);
5291  changed = true;
5292  }
5293  break;
5294  }
5295  case PGC_STRING:
5296  {
5297  struct config_string *conf = (struct config_string *) gconf;
5298  char *newval = newvalue.val.stringval;
5299  void *newextra = newvalue.extra;
5300 
5301  if (*conf->variable != newval ||
5302  conf->gen.extra != newextra)
5303  {
5304  if (conf->assign_hook)
5305  conf->assign_hook(newval, newextra);
5306  set_string_field(conf, conf->variable, newval);
5307  set_extra_field(&conf->gen, &conf->gen.extra,
5308  newextra);
5309  changed = true;
5310  }
5311 
5312  /*
5313  * Release stacked values if not used anymore. We
5314  * could use discard_stack_value() here, but since
5315  * we have type-specific code anyway, might as
5316  * well inline it.
5317  */
5318  set_string_field(conf, &stack->prior.val.stringval, NULL);
5319  set_string_field(conf, &stack->masked.val.stringval, NULL);
5320  break;
5321  }
5322  case PGC_ENUM:
5323  {
5324  struct config_enum *conf = (struct config_enum *) gconf;
5325  int newval = newvalue.val.enumval;
5326  void *newextra = newvalue.extra;
5327 
5328  if (*conf->variable != newval ||
5329  conf->gen.extra != newextra)
5330  {
5331  if (conf->assign_hook)
5332  conf->assign_hook(newval, newextra);
5333  *conf->variable = newval;
5334  set_extra_field(&conf->gen, &conf->gen.extra,
5335  newextra);
5336  changed = true;
5337  }
5338  break;
5339  }
5340  }
5341 
5342  /*
5343  * Release stacked extra values if not used anymore.
5344  */
5345  set_extra_field(gconf, &(stack->prior.extra), NULL);
5346  set_extra_field(gconf, &(stack->masked.extra), NULL);
5347 
5348  /* And restore source information */
5349  gconf->source = newsource;
5350  gconf->scontext = newscontext;
5351  }
5352 
5353  /* Finish popping the state stack */
5354  gconf->stack = prev;
5355  pfree(stack);
5356 
5357  /* Report new value if we changed it */
5358  if (changed && (gconf->flags & GUC_REPORT))
5359  ReportGUCOption(gconf);
5360  } /* end of stack-popping loop */
5361 
5362  if (stack != NULL)
5363  still_dirty = true;
5364  }
5365 
5366  /* If there are no remaining stack entries, we can reset guc_dirty */
5367  guc_dirty = still_dirty;
5368 
5369  /* Update nesting level */
5370  GUCNestLevel = nestLevel - 1;
5371 }
5372 
5373 
5374 /*
5375  * Start up automatic reporting of changes to variables marked GUC_REPORT.
5376  * This is executed at completion of backend startup.
5377  */
5378 void
5380 {
5381  int i;
5382 
5383  /*
5384  * Don't do anything unless talking to an interactive frontend of protocol
5385  * 3.0 or later.
5386  */
5387  if (whereToSendOutput != DestRemote ||
5389  return;
5390 
5391  reporting_enabled = true;
5392 
5393  /* Transmit initial values of interesting variables */
5394  for (i = 0; i < num_guc_variables; i++)
5395  {
5396  struct config_generic *conf = guc_variables[i];
5397 
5398  if (conf->flags & GUC_REPORT)
5399  ReportGUCOption(conf);
5400  }
5401 }
5402 
5403 /*
5404  * ReportGUCOption: if appropriate, transmit option value to frontend
5405  */
5406 static void
5408 {
5409  if (reporting_enabled && (record->flags & GUC_REPORT))
5410  {
5411  char *val = _ShowOption(record, false);
5412  StringInfoData msgbuf;
5413 
5414  pq_beginmessage(&msgbuf, 'S');
5415  pq_sendstring(&msgbuf, record->name);
5416  pq_sendstring(&msgbuf, val);
5417  pq_endmessage(&msgbuf);
5418 
5419  pfree(val);
5420  }
5421 }
5422 
5423 /*
5424  * Convert a value from one of the human-friendly units ("kB", "min" etc.)
5425  * to the given base unit. 'value' and 'unit' are the input value and unit
5426  * to convert from. The converted value is stored in *base_value.
5427  *
5428  * Returns true on success, false if the input unit is not recognized.
5429  */
5430 static bool
5431 convert_to_base_unit(int64 value, const char *unit,
5432  int base_unit, int64 *base_value)
5433 {
5434  const unit_conversion *table;
5435  int i;
5436 
5437  if (base_unit & GUC_UNIT_MEMORY)
5439  else
5441 
5442  for (i = 0; *table[i].unit; i++)
5443  {
5444  if (base_unit == table[i].base_unit &&
5445  strcmp(unit, table[i].unit) == 0)
5446  {
5447  if (table[i].multiplier < 0)
5448  *base_value = value / (-table[i].multiplier);
5449  else
5450  *base_value = value * table[i].multiplier;
5451  return true;
5452  }
5453  }
5454  return false;
5455 }
5456 
5457 /*
5458  * Convert a value in some base unit to a human-friendly unit. The output
5459  * unit is chosen so that it's the greatest unit that can represent the value
5460  * without loss. For example, if the base unit is GUC_UNIT_KB, 1024 is
5461  * converted to 1 MB, but 1025 is represented as 1025 kB.
5462  */
5463 static void
5464 convert_from_base_unit(int64 base_value, int base_unit,
5465  int64 *value, const char **unit)
5466 {
5467  const unit_conversion *table;
5468  int i;
5469 
5470  *unit = NULL;
5471 
5472  if (base_unit & GUC_UNIT_MEMORY)
5474  else
5476 
5477  for (i = 0; *table[i].unit; i++)
5478  {
5479  if (base_unit == table[i].base_unit)
5480  {
5481  /*
5482  * Accept the first conversion that divides the value evenly. We
5483  * assume that the conversions for each base unit are ordered from
5484  * greatest unit to the smallest!
5485  */
5486  if (table[i].multiplier < 0)
5487  {
5488  *value = base_value * (-table[i].multiplier);
5489  *unit = table[i].unit;
5490  break;
5491  }
5492  else if (base_value % table[i].multiplier == 0)
5493  {
5494  *value = base_value / table[i].multiplier;
5495  *unit = table[i].unit;
5496  break;
5497  }
5498  }
5499  }
5500 
5501  Assert(*unit != NULL);
5502 }
5503 
5504 
5505 /*
5506  * Try to parse value as an integer. The accepted formats are the
5507  * usual decimal, octal, or hexadecimal formats, optionally followed by
5508  * a unit name if "flags" indicates a unit is allowed.
5509  *
5510  * If the string parses okay, return true, else false.
5511  * If okay and result is not NULL, return the value in *result.
5512  * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
5513  * HINT message, or NULL if no hint provided.
5514  */
5515 bool
5516 parse_int(const char *value, int *result, int flags, const char **hintmsg)
5517 {
5518  int64 val;
5519  char *endptr;
5520 
5521  /* To suppress compiler warnings, always set output params */
5522  if (result)
5523  *result = 0;
5524  if (hintmsg)
5525  *hintmsg = NULL;
5526 
5527  /* We assume here that int64 is at least as wide as long */
5528  errno = 0;
5529  val = strtol(value, &endptr, 0);
5530 
5531  if (endptr == value)
5532  return false; /* no HINT for integer syntax error */
5533 
5534  if (errno == ERANGE || val != (int64) ((int32) val))
5535  {
5536  if (hintmsg)
5537  *hintmsg = gettext_noop("Value exceeds integer range.");
5538  return false;
5539  }
5540 
5541  /* allow whitespace between integer and unit */
5542  while (isspace((unsigned char) *endptr))
5543  endptr++;
5544 
5545  /* Handle possible unit */
5546  if (*endptr != '\0')
5547  {
5548  char unit[MAX_UNIT_LEN + 1];
5549  int unitlen;
5550  bool converted = false;
5551 
5552  if ((flags & GUC_UNIT) == 0)
5553  return false; /* this setting does not accept a unit */
5554 
5555  unitlen = 0;
5556  while (*endptr != '\0' && !isspace((unsigned char) *endptr) &&
5557  unitlen < MAX_UNIT_LEN)
5558  unit[unitlen++] = *(endptr++);
5559  unit[unitlen] = '\0';
5560  /* allow whitespace after unit */
5561  while (isspace((unsigned char) *endptr))
5562  endptr++;
5563 
5564  if (*endptr == '\0')
5565  converted = convert_to_base_unit(val, unit, (flags & GUC_UNIT),
5566  &val);
5567  if (!converted)
5568  {
5569  /* invalid unit, or garbage after the unit; set hint and fail. */
5570  if (hintmsg)
5571  {
5572  if (flags & GUC_UNIT_MEMORY)
5573  *hintmsg = memory_units_hint;
5574  else
5575  *hintmsg = time_units_hint;
5576  }
5577  return false;
5578  }
5579 
5580  /* Check for overflow due to units conversion */
5581  if (val != (int64) ((int32) val))
5582  {
5583  if (hintmsg)
5584  *hintmsg = gettext_noop("Value exceeds integer range.");
5585  return false;
5586  }
5587  }
5588 
5589  if (result)
5590  *result = (int) val;
5591  return true;
5592 }
5593 
5594 
5595 
5596 /*
5597  * Try to parse value as a floating point number in the usual format.
5598  * If the string parses okay, return true, else false.
5599  * If okay and result is not NULL, return the value in *result.
5600  */
5601 bool
5602 parse_real(const char *value, double *result)
5603 {
5604  double val;
5605  char *endptr;
5606 
5607  if (result)
5608  *result = 0; /* suppress compiler warning */
5609 
5610  errno = 0;
5611  val = strtod(value, &endptr);
5612  if (endptr == value || errno == ERANGE)
5613  return false;
5614 
5615  /* allow whitespace after number */
5616  while (isspace((unsigned char) *endptr))
5617  endptr++;
5618  if (*endptr != '\0')
5619  return false;
5620 
5621  if (result)
5622  *result = val;
5623  return true;
5624 }
5625 
5626 
5627 /*
5628  * Lookup the name for an enum option with the selected value.
5629  * Should only ever be called with known-valid values, so throws
5630  * an elog(ERROR) if the enum option is not found.
5631  *
5632  * The returned string is a pointer to static data and not
5633  * allocated for modification.
5634  */
5635 const char *
5637 {
5638  const struct config_enum_entry *entry;
5639 
5640  for (entry = record->options; entry && entry->name; entry++)
5641  {
5642  if (entry->val == val)
5643  return entry->name;
5644  }
5645 
5646  elog(ERROR, "could not find enum option %d for %s",
5647  val, record->gen.name);
5648  return NULL; /* silence compiler */
5649 }
5650 
5651 
5652 /*
5653  * Lookup the value for an enum option with the selected name
5654  * (case-insensitive).
5655  * If the enum option is found, sets the retval value and returns
5656  * true. If it's not found, return false and retval is set to 0.
5657  */
5658 bool
5659 config_enum_lookup_by_name(struct config_enum *record, const char *value,
5660  int *retval)
5661 {
5662  const struct config_enum_entry *entry;
5663 
5664  for (entry = record->options; entry && entry->name; entry++)
5665  {
5666  if (pg_strcasecmp(value, entry->name) == 0)
5667  {
5668  *retval = entry->val;
5669  return true;
5670  }
5671  }
5672 
5673  *retval = 0;
5674  return false;
5675 }
5676 
5677 
5678 /*
5679  * Return a list of all available options for an enum, excluding
5680  * hidden ones, separated by the given separator.
5681  * If prefix is non-NULL, it is added before the first enum value.
5682  * If suffix is non-NULL, it is added to the end of the string.
5683  */
5684 static char *
5685 config_enum_get_options(struct config_enum *record, const char *prefix,
5686  const char *suffix, const char *separator)
5687 {
5688  const struct config_enum_entry *entry;
5689  StringInfoData retstr;
5690  int seplen;
5691 
5692  initStringInfo(&retstr);
5693  appendStringInfoString(&retstr, prefix);
5694 
5695  seplen = strlen(separator);
5696  for (entry = record->options; entry && entry->name; entry++)
5697  {
5698  if (!entry->hidden)
5699  {
5700  appendStringInfoString(&retstr, entry->name);
5701  appendBinaryStringInfo(&retstr, separator, seplen);
5702  }
5703  }
5704 
5705  /*
5706  * All the entries may have been hidden, leaving the string empty if no
5707  * prefix was given. This indicates a broken GUC setup, since there is no
5708  * use for an enum without any values, so we just check to make sure we
5709  * don't write to invalid memory instead of actually trying to do
5710  * something smart with it.
5711  */
5712  if (retstr.len >= seplen)
5713  {
5714  /* Replace final separator */
5715  retstr.data[retstr.len - seplen] = '\0';
5716  retstr.len -= seplen;
5717  }
5718 
5719  appendStringInfoString(&retstr, suffix);
5720 
5721  return retstr.data;
5722 }
5723 
5724 /*
5725  * Parse and validate a proposed value for the specified configuration
5726  * parameter.
5727  *
5728  * This does built-in checks (such as range limits for an integer parameter)
5729  * and also calls any check hook the parameter may have.
5730  *
5731  * record: GUC variable's info record
5732  * name: variable name (should match the record of course)
5733  * value: proposed value, as a string
5734  * source: identifies source of value (check hooks may need this)
5735  * elevel: level to log any error reports at
5736  * newval: on success, converted parameter value is returned here
5737  * newextra: on success, receives any "extra" data returned by check hook
5738  * (caller must initialize *newextra to NULL)
5739  *
5740  * Returns true if OK, false if not (or throws error, if elevel >= ERROR)
5741  */
5742 static bool
5744  const char *name, const char *value,
5745  GucSource source, int elevel,
5746  union config_var_val *newval, void **newextra)
5747 {
5748  switch (record->vartype)
5749  {
5750  case PGC_BOOL:
5751  {
5752  struct config_bool *conf = (struct config_bool *) record;
5753 
5754  if (!parse_bool(value, &newval->boolval))
5755  {
5756  ereport(elevel,
5757  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5758  errmsg("parameter \"%s\" requires a Boolean value",
5759  name)));
5760  return false;
5761  }
5762 
5763  if (!call_bool_check_hook(conf, &newval->boolval, newextra,
5764  source, elevel))
5765  return false;
5766  }
5767  break;
5768  case PGC_INT:
5769  {
5770  struct config_int *conf = (struct config_int *) record;
5771  const char *hintmsg;
5772 
5773  if (!parse_int(value, &newval->intva