Skip to content

Commit d9d873b

Browse files
committed
Clean up some inconsistencies with GUC declarations
This is similar to 7d25958, and this commit takes care of all the remaining inconsistencies between the initial value used in the C variable associated to a GUC and its default value stored in the GUC tables (as of pg_settings.boot_val). Some of the initial values of the GUCs updated rely on a compile-time default. These are refactored so as the GUC table and its C declaration use the same values. This makes everything consistent with other places, backend_flush_after, bgwriter_flush_after, port, checkpoint_flush_after doing so already, for example. Extracted from a larger patch by Peter Smith. The spots updated in the modules are from me. Author: Peter Smith, Michael Paquier Reviewed-by: Nathan Bossart, Tom Lane, Justin Pryzby Discussion: https://postgr.es/m/CAHut+PtHE0XSfjjRQ6D4v7+dqzCw=d+1a64ujra4EX8aoc_Z+w@mail.gmail.com
1 parent a9f8ca6 commit d9d873b

File tree

19 files changed

+70
-58
lines changed

19 files changed

+70
-58
lines changed

contrib/auth_delay/auth_delay.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
PG_MODULE_MAGIC;
2222

2323
/* GUC Variables */
24-
static int auth_delay_milliseconds;
24+
static int auth_delay_milliseconds = 0;
2525

2626
/* Original Hook */
2727
static ClientAuthentication_hook_type original_client_auth_hook = NULL;

contrib/pg_prewarm/autoprewarm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static AutoPrewarmSharedState *apw_state = NULL;
103103

104104
/* GUC variables. */
105105
static bool autoprewarm = true; /* start worker? */
106-
static int autoprewarm_interval; /* dump interval */
106+
static int autoprewarm_interval = 300; /* dump interval */
107107

108108
/*
109109
* Module load callback.

contrib/pg_stat_statements/pg_stat_statements.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@ static const struct config_enum_entry track_options[] =
283283
{NULL, 0, false}
284284
};
285285

286-
static int pgss_max; /* max # statements to track */
287-
static int pgss_track; /* tracking level */
288-
static bool pgss_track_utility; /* whether to track utility commands */
289-
static bool pgss_track_planning; /* whether to track planning duration */
290-
static bool pgss_save; /* whether to save stats across shutdown */
286+
static int pgss_max = 5000; /* max # statements to track */
287+
static int pgss_track = PGSS_TRACK_TOP; /* tracking level */
288+
static bool pgss_track_utility = true; /* whether to track utility commands */
289+
static bool pgss_track_planning = false; /* whether to track planning
290+
* duration */
291+
static bool pgss_save = true; /* whether to save stats across shutdown */
291292

292293

293294
#define pgss_enabled(level) \

contrib/pg_trgm/trgm_op.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _PG_init(void)
6868
"Sets the threshold used by the % operator.",
6969
"Valid range is 0.0 .. 1.0.",
7070
&similarity_threshold,
71-
0.3,
71+
0.3f,
7272
0.0,
7373
1.0,
7474
PGC_USERSET,
@@ -80,7 +80,7 @@ _PG_init(void)
8080
"Sets the threshold used by the <% operator.",
8181
"Valid range is 0.0 .. 1.0.",
8282
&word_similarity_threshold,
83-
0.6,
83+
0.6f,
8484
0.0,
8585
1.0,
8686
PGC_USERSET,
@@ -92,7 +92,7 @@ _PG_init(void)
9292
"Sets the threshold used by the <<% operator.",
9393
"Valid range is 0.0 .. 1.0.",
9494
&strict_word_similarity_threshold,
95-
0.5,
95+
0.5f,
9696
0.0,
9797
1.0,
9898
PGC_USERSET,

contrib/sepgsql/hooks.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static sepgsql_context_info_t sepgsql_context_info;
5757
/*
5858
* GUC: sepgsql.permissive = (on|off)
5959
*/
60-
static bool sepgsql_permissive;
60+
static bool sepgsql_permissive = false;
6161

6262
bool
6363
sepgsql_get_permissive(void)
@@ -68,7 +68,7 @@ sepgsql_get_permissive(void)
6868
/*
6969
* GUC: sepgsql.debug_audit = (on|off)
7070
*/
71-
static bool sepgsql_debug_audit;
71+
static bool sepgsql_debug_audit = false;
7272

7373
bool
7474
sepgsql_get_debug_audit(void)

src/backend/access/transam/xact.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
* User-tweakable parameters
7676
*/
7777
int DefaultXactIsoLevel = XACT_READ_COMMITTED;
78-
int XactIsoLevel;
78+
int XactIsoLevel = XACT_READ_COMMITTED;
7979

8080
bool DefaultXactReadOnly = false;
8181
bool XactReadOnly;

src/backend/access/transam/xlog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool wal_init_zero = true;
131131
bool wal_recycle = true;
132132
bool log_checkpoints = true;
133133
int sync_method = DEFAULT_SYNC_METHOD;
134-
int wal_level = WAL_LEVEL_MINIMAL;
134+
int wal_level = WAL_LEVEL_REPLICA;
135135
int CommitDelay = 0; /* precommit delay in microseconds */
136136
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
137137
int wal_retrieve_retry_interval = 5000;

src/backend/libpq/be-secure.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ char *SSLECDHCurve;
5858
/* GUC variable: if false, prefer client ciphers */
5959
bool SSLPreferServerCiphers;
6060

61-
int ssl_min_protocol_version;
62-
int ssl_max_protocol_version;
61+
int ssl_min_protocol_version = PG_TLS1_2_VERSION;
62+
int ssl_max_protocol_version = PG_TLS_ANY;
6363

6464
/* ------------------------------------------------------------ */
6565
/* Procedures common to all secure sessions */

src/backend/postmaster/postmaster.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ BackgroundWorker *MyBgworkerEntry = NULL;
196196

197197

198198
/* The socket number we are listening for connections on */
199-
int PostPortNumber;
199+
int PostPortNumber = DEF_PGPORT;
200200

201201
/* The directory names for Unix socket(s) */
202202
char *Unix_socket_directories;

src/backend/storage/buffer/bufmgr.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,22 @@ bool track_io_timing = false;
142142
* for buffers not belonging to tablespaces that have their
143143
* effective_io_concurrency parameter set.
144144
*/
145-
int effective_io_concurrency = 0;
145+
int effective_io_concurrency = DEFAULT_EFFECTIVE_IO_CONCURRENCY;
146146

147147
/*
148148
* Like effective_io_concurrency, but used by maintenance code paths that might
149149
* benefit from a higher setting because they work on behalf of many sessions.
150150
* Overridden by the tablespace setting of the same name.
151151
*/
152-
int maintenance_io_concurrency = 0;
152+
int maintenance_io_concurrency = DEFAULT_MAINTENANCE_IO_CONCURRENCY;
153153

154154
/*
155155
* GUC variables about triggering kernel writeback for buffers written; OS
156156
* dependent defaults are set via the GUC mechanism.
157157
*/
158-
int checkpoint_flush_after = 0;
159-
int bgwriter_flush_after = 0;
160-
int backend_flush_after = 0;
158+
int checkpoint_flush_after = DEFAULT_CHECKPOINT_FLUSH_AFTER;
159+
int bgwriter_flush_after = DEFAULT_BGWRITER_FLUSH_AFTER;
160+
int backend_flush_after = DEFAULT_BACKEND_FLUSH_AFTER;
161161

162162
/* local state for StartBufferIO and related functions */
163163
static BufferDesc *InProgressBuf = NULL;

src/backend/storage/ipc/dsm_impl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const struct config_enum_entry dynamic_shared_memory_options[] = {
109109
};
110110

111111
/* Implementation selector. */
112-
int dynamic_shared_memory_type;
112+
int dynamic_shared_memory_type = DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE;
113113

114114
/* Amount of space reserved for DSM segments in the main area. */
115115
int min_dynamic_shared_memory;

src/backend/utils/adt/xml.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595

9696
/* GUC variables */
97-
int xmlbinary;
98-
int xmloption;
97+
int xmlbinary = XMLBINARY_BASE64;
98+
int xmloption = XMLOPTION_CONTENT;
9999

100100
#ifdef USE_LIBXML
101101

src/backend/utils/cache/plancache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void PlanCacheObjectCallback(Datum arg, int cacheid, uint32 hashvalue);
116116
static void PlanCacheSysCallback(Datum arg, int cacheid, uint32 hashvalue);
117117

118118
/* GUC parameter */
119-
int plan_cache_mode;
119+
int plan_cache_mode = PLAN_CACHE_MODE_AUTO;
120120

121121
/*
122122
* InitPlanCache: initialize module during InitPostgres.

src/backend/utils/error/elog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extern bool redirection_done;
107107
emit_log_hook_type emit_log_hook = NULL;
108108

109109
/* GUC parameters */
110-
int Log_error_verbosity = PGERROR_VERBOSE;
110+
int Log_error_verbosity = PGERROR_DEFAULT;
111111
char *Log_line_prefix = NULL; /* format for extra log line info */
112112
int Log_destination = LOG_DESTINATION_STDERR;
113113
char *Log_destination_string = NULL;

src/backend/utils/init/globals.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ int max_parallel_maintenance_workers = 2;
133133
* MaxBackends is computed by PostmasterMain after modules have had a chance to
134134
* register background workers.
135135
*/
136-
int NBuffers = 1000;
137-
int MaxConnections = 90;
136+
int NBuffers = 16384;
137+
int MaxConnections = 100;
138138
int max_worker_processes = 8;
139139
int max_parallel_workers = 8;
140140
int MaxBackends = 0;

src/backend/utils/misc/guc_tables.c

+22-28
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ int ssl_renegotiation_limit;
526526
* This really belongs in pg_shmem.c, but is defined here so that it doesn't
527527
* need to be duplicated in all the different implementations of pg_shmem.c.
528528
*/
529-
int huge_pages;
529+
int huge_pages = HUGE_PAGES_TRY;
530530
int huge_page_size;
531531

532532
/*
@@ -543,7 +543,14 @@ static char *locale_ctype;
543543
static char *server_encoding_string;
544544
static char *server_version_string;
545545
static int server_version_num;
546-
static int syslog_facility;
546+
547+
#ifdef HAVE_SYSLOG
548+
#define DEFAULT_SYSLOG_FACILITY LOG_LOCAL0
549+
#else
550+
#define DEFAULT_SYSLOG_FACILITY 0
551+
#endif
552+
static int syslog_facility = DEFAULT_SYSLOG_FACILITY;
553+
547554
static char *timezone_string;
548555
static char *log_timezone_string;
549556
static char *timezone_abbreviations_string;
@@ -559,7 +566,14 @@ static int shared_memory_size_in_huge_pages;
559566
static int wal_block_size;
560567
static bool data_checksums;
561568
static bool integer_datetimes;
562-
static bool assert_enabled;
569+
570+
#ifdef USE_ASSERT_CHECKING
571+
#define DEFAULT_ASSERT_ENABLED true
572+
#else
573+
#define DEFAULT_ASSERT_ENABLED false
574+
#endif
575+
static bool assert_enabled = DEFAULT_ASSERT_ENABLED;
576+
563577
static char *recovery_target_timeline_string;
564578
static char *recovery_target_string;
565579
static char *recovery_target_xid_string;
@@ -1181,11 +1195,7 @@ struct config_bool ConfigureNamesBool[] =
11811195
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
11821196
},
11831197
&assert_enabled,
1184-
#ifdef USE_ASSERT_CHECKING
1185-
true,
1186-
#else
1187-
false,
1188-
#endif
1198+
DEFAULT_ASSERT_ENABLED,
11891199
NULL, NULL, NULL
11901200
},
11911201

@@ -1357,11 +1367,7 @@ struct config_bool ConfigureNamesBool[] =
13571367
gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.")
13581368
},
13591369
&update_process_title,
1360-
#ifdef WIN32
1361-
false,
1362-
#else
1363-
true,
1364-
#endif
1370+
DEFAULT_UPDATE_PROCESS_TITLE,
13651371
NULL, NULL, NULL
13661372
},
13671373

@@ -2888,11 +2894,7 @@ struct config_int ConfigureNamesInt[] =
28882894
GUC_EXPLAIN
28892895
},
28902896
&effective_io_concurrency,
2891-
#ifdef USE_PREFETCH
2892-
1,
2893-
#else
2894-
0,
2895-
#endif
2897+
DEFAULT_EFFECTIVE_IO_CONCURRENCY,
28962898
0, MAX_IO_CONCURRENCY,
28972899
check_effective_io_concurrency, NULL, NULL
28982900
},
@@ -2906,11 +2908,7 @@ struct config_int ConfigureNamesInt[] =
29062908
GUC_EXPLAIN
29072909
},
29082910
&maintenance_io_concurrency,
2909-
#ifdef USE_PREFETCH
2910-
10,
2911-
#else
2912-
0,
2913-
#endif
2911+
DEFAULT_MAINTENANCE_IO_CONCURRENCY,
29142912
0, MAX_IO_CONCURRENCY,
29152913
check_maintenance_io_concurrency, assign_maintenance_io_concurrency,
29162914
NULL
@@ -4613,11 +4611,7 @@ struct config_enum ConfigureNamesEnum[] =
46134611
NULL
46144612
},
46154613
&syslog_facility,
4616-
#ifdef HAVE_SYSLOG
4617-
LOG_LOCAL0,
4618-
#else
4619-
0,
4620-
#endif
4614+
DEFAULT_SYSLOG_FACILITY,
46214615
syslog_facility_options,
46224616
NULL, assign_syslog_facility, NULL
46234617
},

src/backend/utils/misc/ps_status.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#include "utils/ps_status.h"
3131

3232
extern char **environ;
33-
bool update_process_title = true;
3433

34+
/* GUC variable */
35+
bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
3536

3637
/*
3738
* Alternative ways of updating ps display:

src/include/storage/bufmgr.h

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ extern PGDLLIMPORT bool zero_damaged_pages;
6969
extern PGDLLIMPORT int bgwriter_lru_maxpages;
7070
extern PGDLLIMPORT double bgwriter_lru_multiplier;
7171
extern PGDLLIMPORT bool track_io_timing;
72+
73+
/* only applicable when prefetching is available */
74+
#ifdef USE_PREFETCH
75+
#define DEFAULT_EFFECTIVE_IO_CONCURRENCY 1
76+
#define DEFAULT_MAINTENANCE_IO_CONCURRENCY 10
77+
#else
78+
#define DEFAULT_EFFECTIVE_IO_CONCURRENCY 0
79+
#define DEFAULT_MAINTENANCE_IO_CONCURRENCY 0
80+
#endif
7281
extern PGDLLIMPORT int effective_io_concurrency;
7382
extern PGDLLIMPORT int maintenance_io_concurrency;
7483

src/include/utils/ps_status.h

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
#ifndef PS_STATUS_H
1313
#define PS_STATUS_H
1414

15+
/* disabled on Windows as the performance overhead can be significant */
16+
#ifdef WIN32
17+
#define DEFAULT_UPDATE_PROCESS_TITLE false
18+
#else
19+
#define DEFAULT_UPDATE_PROCESS_TITLE true
20+
#endif
21+
1522
extern PGDLLIMPORT bool update_process_title;
1623

1724
extern char **save_ps_display_args(int argc, char **argv);

0 commit comments

Comments
 (0)