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