Further cleanup of client dependencies on src/include/catalog headers.
authorTom Lane <[email protected]>
Mon, 9 Apr 2018 18:39:58 +0000 (14:39 -0400)
committerTom Lane <[email protected]>
Mon, 9 Apr 2018 18:39:58 +0000 (14:39 -0400)
In commit 9c0a0de4c, I'd failed to notice that catalog/catalog.h
should also be considered a frontend-unsafe header, because it includes
(and needs) the full form of pg_class.h, not to mention relcache.h.
However, various frontend code was depending on it to get
TABLESPACE_VERSION_DIRECTORY, so refactoring of some sort is called for.

The cleanest answer seems to be to move TABLESPACE_VERSION_DIRECTORY,
as well as the OIDCHARS symbol, to common/relpath.h.  Do that, and mop up
inclusions as necessary.  (I found that quite a few current users of
catalog/catalog.h don't seem to need it at all anymore, apparently as a
result of the refactorings that created common/relpath.[hc].  And
initdb.c needed it only as a route to pg_class_d.h.)

Discussion: https://postgr.es/m/6629.1523294509@sss.pgh.pa.us

21 files changed:
contrib/pageinspect/rawpage.c
contrib/pg_prewarm/pg_prewarm.c
src/backend/access/index/indexam.c
src/backend/access/rmgrdesc/smgrdesc.c
src/backend/access/rmgrdesc/xactdesc.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlogfuncs.c
src/backend/access/transam/xlogutils.c
src/backend/catalog/storage.c
src/backend/commands/vacuumlazy.c
src/backend/replication/basebackup.c
src/backend/storage/file/fd.c
src/backend/storage/file/reinit.c
src/backend/storage/smgr/md.c
src/bin/initdb/initdb.c
src/bin/pg_rewind/copy_fetch.c
src/bin/pg_rewind/filemap.c
src/bin/pg_rewind/libpq_fetch.c
src/common/relpath.c
src/include/catalog/catalog.h
src/include/common/relpath.h

index 3d4d4f6f930bfde8a81a4659ae08ce662282b730..72f1d21e1b76b2595e3c22804b9cdd21fdabe132 100644 (file)
@@ -18,7 +18,6 @@
 #include "pageinspect.h"
 
 #include "access/htup_details.h"
-#include "catalog/catalog.h"
 #include "catalog/namespace.h"
 #include "catalog/pg_type.h"
 #include "funcapi.h"
index 7f084462b1b4acea9f4dc39d54ed464077be7b15..3cbb7c2b889ac3953727840beea61e37ee9df42f 100644 (file)
@@ -16,7 +16,6 @@
 #include <unistd.h>
 
 #include "access/heapam.h"
-#include "catalog/catalog.h"
 #include "fmgr.h"
 #include "miscadmin.h"
 #include "storage/bufmgr.h"
index 91247f0fa59133d1a2bd69c4e17283e4196ad1e3..22b5cc921f820eeba776cbfed73399dc5e46b662 100644 (file)
@@ -73,7 +73,6 @@
 #include "access/relscan.h"
 #include "access/transam.h"
 #include "access/xlog.h"
-#include "catalog/catalog.h"
 #include "catalog/index.h"
 #include "pgstat.h"
 #include "storage/bufmgr.h"
index 517de600841456ff5f3061a38ff32d61fbae7a2f..df1ad38b5a1d67e8f85dc92416a040c63b063c23 100644 (file)
@@ -14,7 +14,6 @@
  */
 #include "postgres.h"
 
-#include "catalog/catalog.h"
 #include "catalog/storage_xlog.h"
 
 
index 3b3c95f8104c27b9a7426723a4e9be2e9956eec7..9b40f447ff183d8883977f7d4fdcca1afb0fb8c7 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "access/transam.h"
 #include "access/xact.h"
-#include "catalog/catalog.h"
 #include "storage/sinval.h"
 #include "storage/standbydefs.h"
 #include "utils/timestamp.h"
index b88d4ccf746847878809e172b80745589fd451b4..948733c1e3dd8d07896c22a1a20b1c0b4511ef82 100644 (file)
@@ -30,7 +30,6 @@
 #include "access/xlog.h"
 #include "access/xloginsert.h"
 #include "access/xlogutils.h"
-#include "catalog/catalog.h"
 #include "catalog/namespace.h"
 #include "catalog/storage.h"
 #include "commands/async.h"
index 316edbe3c5857826c74427fbef04a90bc89100b4..973174297863feaab062e0c01246b612028f936b 100644 (file)
@@ -20,7 +20,6 @@
 #include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "access/xlogutils.h"
-#include "catalog/catalog.h"
 #include "catalog/pg_type.h"
 #include "funcapi.h"
 #include "miscadmin.h"
index 89da25c207c7549d40a5b1aafe375c071fd109f1..52fe55e2afb5782916fdf138c5b8185f9e8df560 100644 (file)
@@ -23,7 +23,6 @@
 #include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "access/xlogutils.h"
-#include "catalog/catalog.h"
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/smgr.h"
index cff49bae9ea01224b8822b2de741f35a66534303..5df4382b7e70dae4c86e3682a6cc73f29a40c64f 100644 (file)
@@ -24,7 +24,6 @@
 #include "access/xlog.h"
 #include "access/xloginsert.h"
 #include "access/xlogutils.h"
-#include "catalog/catalog.h"
 #include "catalog/storage.h"
 #include "catalog/storage_xlog.h"
 #include "storage/freespace.h"
index d2a006671ac8dfe2152c8469b5a6fc4f88f33a34..5649a70800db3e4ab061edfb7bec4de142d0cb80 100644 (file)
@@ -44,7 +44,6 @@
 #include "access/transam.h"
 #include "access/visibilitymap.h"
 #include "access/xlog.h"
-#include "catalog/catalog.h"
 #include "catalog/storage.h"
 #include "commands/dbcommands.h"
 #include "commands/progress.h"
index bfbd1fd3821ea7daf9400f01eab6e1062f930580..50c052e993598a07f55675e5e9046a8d3b6af86d 100644 (file)
@@ -17,7 +17,6 @@
 #include <time.h>
 
 #include "access/xlog_internal.h"      /* for pg_start/stop_backup */
-#include "catalog/catalog.h"
 #include "catalog/pg_type.h"
 #include "common/file_perm.h"
 #include "lib/stringinfo.h"
index 36eea9d11d05e67a1066988ab9dbf841e99aa488..f772dfe93f757644c1da0e03156d48022db0bf1c 100644 (file)
@@ -82,7 +82,6 @@
 #include "miscadmin.h"
 #include "access/xact.h"
 #include "access/xlog.h"
-#include "catalog/catalog.h"
 #include "catalog/pg_tablespace.h"
 #include "common/file_perm.h"
 #include "pgstat.h"
index 7b8a1253c481619944306ce81677a775ab29782f..74ff6c359b53ff55564f95214810b28631d6e2dd 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <unistd.h>
 
-#include "catalog/catalog.h"
 #include "common/relpath.h"
 #include "storage/copydir.h"
 #include "storage/fd.h"
index bb96881cad9bebf929b4a73ff9732f7aa3aa9ec2..2ec103e60479739c357ab2f67b6bc6e1dc9d34cf 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "miscadmin.h"
 #include "access/xlog.h"
-#include "catalog/catalog.h"
 #include "pgstat.h"
 #include "portability/instr_time.h"
 #include "postmaster/bgwriter.h"
index e9f22c764eb0bcdb5533a049a56d978826e63e52..4907a379038d5b7cf0d653886fd4588c9e5288cb 100644 (file)
@@ -60,8 +60,8 @@
 #endif
 
 #include "access/xlog_internal.h"
-#include "catalog/catalog.h"
 #include "catalog/pg_authid_d.h"
+#include "catalog/pg_class_d.h" /* pgrminclude ignore */
 #include "catalog/pg_collation_d.h"
 #include "common/file_perm.h"
 #include "common/file_utils.h"
index 04db4096755734301b0e2cd8cc8aa06eb2041f5f..160a91284771bdfbb34ccf0445acd28372568158 100644 (file)
@@ -21,8 +21,6 @@
 #include "logging.h"
 #include "pg_rewind.h"
 
-#include "catalog/catalog.h"
-
 static void recurse_dir(const char *datadir, const char *path,
                        process_file_callback_t callback);
 
index c3fc519895e4746052459d825bd747a8c6eb0708..e45e6d44ec764bfd19b365464199deb35c1945a5 100644 (file)
@@ -19,7 +19,6 @@
 #include "pg_rewind.h"
 
 #include "common/string.h"
-#include "catalog/catalog.h"
 #include "catalog/pg_tablespace_d.h"
 #include "storage/fd.h"
 
index fa845bbf7d741e9149dbd2228684c3aaefd79b30..9a085ea258f583e11092f13724a6b433bedf5049 100644 (file)
@@ -22,7 +22,6 @@
 #include "logging.h"
 
 #include "libpq-fe.h"
-#include "catalog/catalog.h"
 #include "catalog/pg_type_d.h"
 #include "fe_utils/connect.h"
 #include "port/pg_bswap.h"
index f0fa6742b3bec3971bba9b3f9d9303cd66f5f6fb..e8170ed712ec13d3dac99ef013d99f3033d520d6 100644 (file)
@@ -18,7 +18,6 @@
 #include "postgres_fe.h"
 #endif
 
-#include "catalog/catalog.h"
 #include "catalog/pg_tablespace_d.h"
 #include "common/relpath.h"
 #include "storage/backendid.h"
index 3e280b3750892832cd6d5000a8b68a35f5f27eee..197e77f7f4ff5bb335dddab5d412f7d3329d57b6 100644 (file)
 #ifndef CATALOG_H
 #define CATALOG_H
 
-/*
- *     'pgrminclude ignore' needed here because CppAsString2() does not throw
- *     an error if the symbol is not defined.
- */
-#include "catalog/catversion.h" /* pgrminclude ignore */
 #include "catalog/pg_class.h"
 #include "utils/relcache.h"
 
-#define OIDCHARS               10              /* max chars printed by %u */
-#define TABLESPACE_VERSION_DIRECTORY   "PG_" PG_MAJORVERSION "_" \
-                                                                       CppAsString2(CATALOG_VERSION_NO)
-
 
 extern bool IsSystemRelation(Relation relation);
 extern bool IsToastRelation(Relation relation);
index 9137dc9ed3949ea6fa62b25a825f85880e257419..82d817a53c7540973603cadde560a1c4484e8818 100644 (file)
 #ifndef RELPATH_H
 #define RELPATH_H
 
+/*
+ *     'pgrminclude ignore' needed here because CppAsString2() does not throw
+ *     an error if the symbol is not defined.
+ */
+#include "catalog/catversion.h" /* pgrminclude ignore */
+
+
+/*
+ * Name of major-version-specific tablespace subdirectories
+ */
+#define TABLESPACE_VERSION_DIRECTORY   "PG_" PG_MAJORVERSION "_" \
+                                                                       CppAsString2(CATALOG_VERSION_NO)
+
+/* Characters to allow for an OID in a relation path */
+#define OIDCHARS               10              /* max chars printed by %u */
+
 /*
  * Stuff for fork names.
  *