On Sat, Dec 14, 2013 at 04:52:28PM +0100, Andres Freund wrote:
> Hi,
> 
> Compiling postgres with said option in CFLAGS really gives an astounding
> number of warnings. Except some bison/flex generated ones, none of them
> looks acceptable to me.
> Most are just file local variables with a missing static and easy to
> fix. Several other are actually shared variables, where people simply
> haven't bothered to add the variable to a header. Some of them with
> comments declaring that fact, others adding longer comments, even others
> adding longer comments about that fact.
> 
> I've attached the output of such a compilation run for those without
> clang.

Now that pg_upgrade has stabilized, I think it is time to centralize all
the pg_upgrade_support control variables in a single C include file that
can be used by the backend and by pg_upgrade_support.  This will
eliminate the compiler warnings too.

The attached patch accomplishes this.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +
diff --git a/contrib/pg_upgrade_support/pg_upgrade_support.c b/contrib/pg_upgrade_support/pg_upgrade_support.c
new file mode 100644
index 99e64c4..6e30deb
*** a/contrib/pg_upgrade_support/pg_upgrade_support.c
--- b/contrib/pg_upgrade_support/pg_upgrade_support.c
***************
*** 11,16 ****
--- 11,17 ----
  
  #include "postgres.h"
  
+ #include "catalog/binary_upgrade.h"
  #include "catalog/namespace.h"
  #include "catalog/pg_type.h"
  #include "commands/extension.h"
***************
*** 24,40 ****
  PG_MODULE_MAGIC;
  #endif
  
- extern PGDLLIMPORT Oid binary_upgrade_next_pg_type_oid;
- extern PGDLLIMPORT Oid binary_upgrade_next_array_pg_type_oid;
- extern PGDLLIMPORT Oid binary_upgrade_next_toast_pg_type_oid;
- 
- extern PGDLLIMPORT Oid binary_upgrade_next_heap_pg_class_oid;
- extern PGDLLIMPORT Oid binary_upgrade_next_index_pg_class_oid;
- extern PGDLLIMPORT Oid binary_upgrade_next_toast_pg_class_oid;
- 
- extern PGDLLIMPORT Oid binary_upgrade_next_pg_enum_oid;
- extern PGDLLIMPORT Oid binary_upgrade_next_pg_authid_oid;
- 
  Datum		set_next_pg_type_oid(PG_FUNCTION_ARGS);
  Datum		set_next_array_pg_type_oid(PG_FUNCTION_ARGS);
  Datum		set_next_toast_pg_type_oid(PG_FUNCTION_ARGS);
--- 25,30 ----
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
new file mode 100644
index 6f2e142..032a20e
*** a/src/backend/catalog/heap.c
--- b/src/backend/catalog/heap.c
***************
*** 34,39 ****
--- 34,40 ----
  #include "access/sysattr.h"
  #include "access/transam.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
new file mode 100644
index aa31429..7ad9720
*** a/src/backend/catalog/index.c
--- b/src/backend/catalog/index.c
***************
*** 30,35 ****
--- 30,36 ----
  #include "access/visibilitymap.h"
  #include "access/xact.h"
  #include "bootstrap/bootstrap.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
new file mode 100644
index 35899b4..23d2a41
*** a/src/backend/catalog/pg_enum.c
--- b/src/backend/catalog/pg_enum.c
***************
*** 17,22 ****
--- 17,23 ----
  #include "access/heapam.h"
  #include "access/htup_details.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/catalog.h"
  #include "catalog/indexing.h"
  #include "catalog/pg_enum.h"
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
new file mode 100644
index 23ac3dd..634915b
*** a/src/backend/catalog/pg_type.c
--- b/src/backend/catalog/pg_type.c
***************
*** 17,22 ****
--- 17,23 ----
  #include "access/heapam.h"
  #include "access/htup_details.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
  #include "catalog/objectaccess.h"
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
new file mode 100644
index 385d64d..f58e434
*** a/src/backend/catalog/toasting.c
--- b/src/backend/catalog/toasting.c
***************
*** 16,21 ****
--- 16,22 ----
  
  #include "access/tuptoaster.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
***************
*** 31,38 ****
  #include "utils/syscache.h"
  
  /* Potentially set by contrib/pg_upgrade_support functions */
- extern Oid	binary_upgrade_next_toast_pg_class_oid;
- 
  Oid			binary_upgrade_next_toast_pg_type_oid = InvalidOid;
  
  static bool create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
--- 32,37 ----
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
new file mode 100644
index d4a14ca..959b3f2
*** a/src/backend/commands/typecmds.c
--- b/src/backend/commands/typecmds.c
***************
*** 35,40 ****
--- 35,41 ----
  #include "access/heapam.h"
  #include "access/htup_details.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
new file mode 100644
index e101a86..ca1906d
*** a/src/backend/commands/user.c
--- b/src/backend/commands/user.c
***************
*** 16,21 ****
--- 16,22 ----
  #include "access/heapam.h"
  #include "access/htup_details.h"
  #include "access/xact.h"
+ #include "catalog/binary_upgrade.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
  #include "catalog/objectaccess.h"
diff --git a/src/include/catalog/binary_upgrade.h b/src/include/catalog/binary_upgrade.h
new file mode 100644
index ...169d769
*** a/src/include/catalog/binary_upgrade.h
--- b/src/include/catalog/binary_upgrade.h
***************
*** 0 ****
--- 1,29 ----
+ /*-------------------------------------------------------------------------
+  *
+  * binary_upgrade.h
+  *	  variables used for binary upgrades
+  *
+  *
+  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+  * Portions Copyright (c) 1994, Regents of the University of California
+  *
+  * src/include/catalog/binary_upgrade.h
+  *
+  *-------------------------------------------------------------------------
+  */
+ #ifndef BINARY_UPGRADE_H
+ #define BINARY_UPGRADE_H
+ 
+ extern PGDLLIMPORT Oid binary_upgrade_next_pg_type_oid;
+ extern PGDLLIMPORT Oid binary_upgrade_next_array_pg_type_oid;
+ extern PGDLLIMPORT Oid binary_upgrade_next_toast_pg_type_oid;
+ 
+ extern PGDLLIMPORT Oid binary_upgrade_next_heap_pg_class_oid;
+ extern PGDLLIMPORT Oid binary_upgrade_next_index_pg_class_oid;
+ extern PGDLLIMPORT Oid binary_upgrade_next_toast_pg_class_oid;
+ 
+ extern PGDLLIMPORT Oid binary_upgrade_next_pg_enum_oid;
+ extern PGDLLIMPORT Oid binary_upgrade_next_pg_authid_oid;
+ 
+ #endif   /* BINARY_UPGRADE_H */
+ 
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to