Move all extern declarations for GUC variables to header files
authorPeter Eisentraut <[email protected]>
Wed, 24 Jul 2024 04:21:39 +0000 (06:21 +0200)
committerPeter Eisentraut <[email protected]>
Wed, 24 Jul 2024 04:31:07 +0000 (06:31 +0200)
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 declared in a header
file and some only pulled in via ad-hoc extern declarations in various
.c files.

Also add PGDLLIMPORT qualifications to those variables.  These were
previously missing because src/tools/mark_pgdllimport.pl has only been
used with header files.

This also fixes -Wmissing-variable-declarations warnings for GUC
variables (not yet part of the standard warning options).

Reviewed-by: Andres Freund <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/e0a62134-83da-4ba4-8cdb-ceb0111c95ce@eisentraut.org

12 files changed:
src/backend/commands/variable.c
src/backend/utils/error/elog.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc_tables.c
src/include/access/syncscan.h
src/include/access/xlog.h
src/include/access/xlogutils.h
src/include/commands/tablespace.h
src/include/storage/bufpage.h
src/include/tcop/backend_startup.h
src/include/tcop/tcopprot.h
src/include/utils/guc.h

index 9345131711ed89965f1291e89833100d943d830d..f44d942aa4d45cd3eddfc2b54326911ae6bd8538 100644 (file)
@@ -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)
index 479e312ba72db78992828a5b3ccaf35f51b8409e..943d8588f3d645a164c9f1b9f3887b2c6dc6f2ea 100644 (file)
@@ -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
 
index b0947a4cf153d3578470bce8f30743d8b6d38e7d..0c593b81b4e333d5fb3701b8149cd629409377bf 100644 (file)
@@ -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.
index 630ed0f1629f92ca5ccf3b49a8e0561b277243e0..f6fcdebb0312c0df761c941d7f165ea976b0ac62 100644 (file)
@@ -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"
 #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"
 #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.
  *
index 00b6c0dfc635d3734525ba0fecdca36aac2fef20..e6ee91fc08ac3c780a470d0374adec4afa6436ca 100644 (file)
 #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);
index c40fd56b291fd4cabea1af1a8079e6cda6d1a651..365a18a08bb1b66332c886aaef739fb9a62abc65 100644 (file)
@@ -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;
 
index e24613e8f8174a9b7ba0393753dcdaecd58bb389..20950ce0336ca76706f7ce68e2ec842d771758aa 100644 (file)
@@ -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
index b6cec632db9ad8135114745763331c0555d80620..6ab2402896df12419307cf724ec3f97f62776af4 100644 (file)
@@ -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 */
index d0df02d39c5268dce460d750e63ae5018b9a4ab9..df91e80eceec2d1371007eecd291aa0346f98a69 100644 (file)
@@ -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).
index 16a68c7758456c3dafee73f3572578b0c84a2d6f..993b013afddc64d657b2b477cebf25d4c18775b7 100644 (file)
@@ -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
index 643ce9cffab611c83c07790ca4b7d286a0c5c811..147a294950efd8bafb3efadc2b0f026b913179d8 100644 (file)
@@ -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);
index ff506bf48d9a79050f2767062b4fdada41478f6a..cd2cee3dfe02a3c88b79ad472f4d37cf10f3e4de 100644 (file)
@@ -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
  */