From fd602ed3766af43f3cc4128a34f5d68b6d413f5f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 17 Jun 2024 09:29:24 +0200 Subject: [PATCH v2 07/10] Fix -Wmissing-variable-declarations warnings for GUC variables Add extern declarations in appropriate header files for global variables related to GUC. In many cases, this was handled quite inconsistently before, with some GUC variables from the same module declared in a header file and some not. Discussion: https://www.postgresql.org/message-id/flat/e0a62134-83da-4ba4-8cdb-ceb0111c95ce@eisentraut.org --- src/backend/commands/variable.c | 1 - src/backend/utils/error/elog.c | 2 -- src/backend/utils/misc/guc.c | 3 --- src/backend/utils/misc/guc_tables.c | 24 +++++++----------------- src/include/access/syncscan.h | 5 +++++ src/include/access/xlog.h | 2 ++ src/include/access/xlogutils.h | 3 +++ src/include/commands/tablespace.h | 2 ++ src/include/storage/bufpage.h | 3 +++ src/include/tcop/backend_startup.h | 3 +++ src/include/tcop/tcopprot.h | 1 + src/include/utils/guc.h | 25 +++++++++++++++++++++++++ 12 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 9345131711e..f44d942aa4d 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -901,7 +901,6 @@ assign_session_authorization(const char *newval, void *extra) * a translation of "none" to InvalidOid. Otherwise this is much like * SET SESSION AUTHORIZATION. */ -extern char *role_string; /* in guc_tables.c */ bool check_role(char **newval, void **extra, GucSource source) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index e9077714211..b73fd933249 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -136,8 +136,6 @@ static void write_syslog(int level, const char *line); #endif #ifdef WIN32 -extern char *event_source; - static void write_eventlog(int level, const char *line, int len); #endif diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 547cecde240..99f079d95c2 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -82,9 +82,6 @@ char *GUC_check_errmsg_string; char *GUC_check_errdetail_string; char *GUC_check_errhint_string; -/* Kluge: for speed, we examine this GUC variable's value directly */ -extern bool in_hot_standby_guc; - /* * Unit conversion tables. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index bdd18ed7fce..93767bf7a0c 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -34,6 +34,7 @@ #include "access/xlog_internal.h" #include "access/xlogprefetcher.h" #include "access/xlogrecovery.h" +#include "access/xlogutils.h" #include "archive/archive_module.h" #include "catalog/namespace.h" #include "catalog/storage.h" @@ -71,10 +72,12 @@ #include "replication/slotsync.h" #include "replication/syncrep.h" #include "storage/bufmgr.h" +#include "storage/bufpage.h" #include "storage/large_object.h" #include "storage/pg_shmem.h" #include "storage/predicate.h" #include "storage/standby.h" +#include "tcop/backend_startup.h" #include "tcop/tcopprot.h" #include "tsearch/ts_cache.h" #include "utils/builtins.h" @@ -90,28 +93,15 @@ #include "utils/rls.h" #include "utils/xml.h" +#ifdef TRACE_SYNCSCAN +#include "access/syncscan.h" +#endif + /* This value is normally passed in from the Makefile */ #ifndef PG_KRB_SRVTAB #define PG_KRB_SRVTAB "" #endif -/* XXX these should appear in other modules' header files */ -extern bool Log_disconnections; -extern bool Trace_connection_negotiation; -extern int CommitDelay; -extern int CommitSiblings; -extern char *default_tablespace; -extern char *temp_tablespaces; -extern bool ignore_checksum_failure; -extern bool ignore_invalid_pages; - -#ifdef TRACE_SYNCSCAN -extern bool trace_syncscan; -#endif -#ifdef DEBUG_BOUNDED_SORT -extern bool optimize_bounded_sort; -#endif - /* * Options for enum values defined in this module. * diff --git a/src/include/access/syncscan.h b/src/include/access/syncscan.h index 00b6c0dfc63..e6ee91fc08a 100644 --- a/src/include/access/syncscan.h +++ b/src/include/access/syncscan.h @@ -17,6 +17,11 @@ #include "storage/block.h" #include "utils/relcache.h" +/* GUC variables */ +#ifdef TRACE_SYNCSCAN +extern PGDLLIMPORT bool trace_syncscan; +#endif + extern void ss_report_location(Relation rel, BlockNumber location); extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks); extern void SyncScanShmemInit(void); diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index c40fd56b291..365a18a08bb 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -52,6 +52,8 @@ extern PGDLLIMPORT bool wal_recycle; extern PGDLLIMPORT bool *wal_consistency_checking; extern PGDLLIMPORT char *wal_consistency_checking_string; extern PGDLLIMPORT bool log_checkpoints; +extern PGDLLIMPORT int CommitDelay; +extern PGDLLIMPORT int CommitSiblings; extern PGDLLIMPORT bool track_wal_io_timing; extern PGDLLIMPORT int wal_decode_buffer_size; diff --git a/src/include/access/xlogutils.h b/src/include/access/xlogutils.h index e24613e8f81..20950ce0336 100644 --- a/src/include/access/xlogutils.h +++ b/src/include/access/xlogutils.h @@ -14,6 +14,9 @@ #include "access/xlogreader.h" #include "storage/bufmgr.h" +/* GUC variable */ +extern PGDLLIMPORT bool ignore_invalid_pages; + /* * Prior to 8.4, all activity during recovery was carried out by the startup * process. This local variable continues to be used in many parts of the diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h index b6cec632db9..6ab2402896d 100644 --- a/src/include/commands/tablespace.h +++ b/src/include/commands/tablespace.h @@ -19,6 +19,8 @@ #include "lib/stringinfo.h" #include "nodes/parsenodes.h" +extern PGDLLIMPORT char *default_tablespace; +extern PGDLLIMPORT char *temp_tablespaces; extern PGDLLIMPORT bool allow_in_place_tablespaces; /* XLOG stuff */ diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index d0df02d39c5..df91e80ecee 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -19,6 +19,9 @@ #include "storage/item.h" #include "storage/off.h" +/* GUC variable */ +extern PGDLLIMPORT bool ignore_checksum_failure; + /* * A postgres disk page is an abstraction layered on top of a postgres * disk block (which is simply a unit of i/o, see block.h). diff --git a/src/include/tcop/backend_startup.h b/src/include/tcop/backend_startup.h index 16a68c77584..993b013afdd 100644 --- a/src/include/tcop/backend_startup.h +++ b/src/include/tcop/backend_startup.h @@ -14,6 +14,9 @@ #ifndef BACKEND_STARTUP_H #define BACKEND_STARTUP_H +/* GUCs */ +extern PGDLLIMPORT bool Trace_connection_negotiation; + /* * CAC_state is passed from postmaster to the backend process, to indicate * whether the connection should be accepted, or if the process should just diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 643ce9cffab..147a294950e 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -40,6 +40,7 @@ typedef enum LOGSTMT_ALL, /* log all statements */ } LogStmtLevel; +extern PGDLLIMPORT bool Log_disconnections; extern PGDLLIMPORT int log_statement; extern List *pg_parse_query(const char *query_string); diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index ff506bf48d9..cd2cee3dfe0 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -250,6 +250,7 @@ extern PGDLLIMPORT bool log_planner_stats; extern PGDLLIMPORT bool log_executor_stats; extern PGDLLIMPORT bool log_statement_stats; extern PGDLLIMPORT bool log_btree_build_stats; +extern PGDLLIMPORT char *event_source; extern PGDLLIMPORT bool check_function_bodies; extern PGDLLIMPORT bool current_role_is_superuser; @@ -285,10 +286,34 @@ extern PGDLLIMPORT int tcp_keepalives_interval; extern PGDLLIMPORT int tcp_keepalives_count; extern PGDLLIMPORT int tcp_user_timeout; +extern PGDLLIMPORT char *role_string; +extern PGDLLIMPORT bool in_hot_standby_guc; + #ifdef TRACE_SORT extern PGDLLIMPORT bool trace_sort; #endif +#ifdef DEBUG_BOUNDED_SORT +extern PGDLLIMPORT bool optimize_bounded_sort; +#endif + +/* + * Declarations for options for enum values + * + * For most parameters, these are defined statically inside guc_tables.c. But + * for some parameters, the definitions require symbols that are not easily + * available inside guc_tables.c, so they are instead defined in their home + * modules. For those, we keep the extern declarations here. (An alternative + * would be to put the extern declarations in the modules' header files, but + * that would then require including the definition of struct + * config_enum_entry into those header files.) + */ +extern const struct config_enum_entry archive_mode_options[]; +extern const struct config_enum_entry dynamic_shared_memory_options[]; +extern const struct config_enum_entry recovery_target_action_options[]; +extern const struct config_enum_entry wal_level_options[]; +extern const struct config_enum_entry wal_sync_method_options[]; + /* * Functions exported by guc.c */ -- 2.45.2