summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2018-04-09 18:39:58 +0000
committerTom Lane2018-04-09 18:39:58 +0000
commitaf1a949109d8212711df943c053b1038c0afdae1 (patch)
tree3d532e1bcd3ce3dfd1fa7dbb41480e25d342981e
parentf5543d47bcb2fee2ab69220f51e2078c11e19843 (diff)
Further cleanup of client dependencies on src/include/catalog headers.
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/[email protected]
-rw-r--r--contrib/pageinspect/rawpage.c1
-rw-r--r--contrib/pg_prewarm/pg_prewarm.c1
-rw-r--r--src/backend/access/index/indexam.c1
-rw-r--r--src/backend/access/rmgrdesc/smgrdesc.c1
-rw-r--r--src/backend/access/rmgrdesc/xactdesc.c1
-rw-r--r--src/backend/access/transam/xact.c1
-rw-r--r--src/backend/access/transam/xlogfuncs.c1
-rw-r--r--src/backend/access/transam/xlogutils.c1
-rw-r--r--src/backend/catalog/storage.c1
-rw-r--r--src/backend/commands/vacuumlazy.c1
-rw-r--r--src/backend/replication/basebackup.c1
-rw-r--r--src/backend/storage/file/fd.c1
-rw-r--r--src/backend/storage/file/reinit.c1
-rw-r--r--src/backend/storage/smgr/md.c1
-rw-r--r--src/bin/initdb/initdb.c2
-rw-r--r--src/bin/pg_rewind/copy_fetch.c2
-rw-r--r--src/bin/pg_rewind/filemap.c1
-rw-r--r--src/bin/pg_rewind/libpq_fetch.c1
-rw-r--r--src/common/relpath.c1
-rw-r--r--src/include/catalog/catalog.h9
-rw-r--r--src/include/common/relpath.h16
21 files changed, 17 insertions, 29 deletions
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
index 3d4d4f6f93..72f1d21e1b 100644
--- a/contrib/pageinspect/rawpage.c
+++ b/contrib/pageinspect/rawpage.c
@@ -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"
diff --git a/contrib/pg_prewarm/pg_prewarm.c b/contrib/pg_prewarm/pg_prewarm.c
index 7f084462b1..3cbb7c2b88 100644
--- a/contrib/pg_prewarm/pg_prewarm.c
+++ b/contrib/pg_prewarm/pg_prewarm.c
@@ -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"
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 91247f0fa5..22b5cc921f 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -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"
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index 517de60084..df1ad38b5a 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -14,7 +14,6 @@
*/
#include "postgres.h"
-#include "catalog/catalog.h"
#include "catalog/storage_xlog.h"
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 3b3c95f810..9b40f447ff 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -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"
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index b88d4ccf74..948733c1e3 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -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"
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 316edbe3c5..9731742978 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -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"
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index 89da25c207..52fe55e2af 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -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"
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index cff49bae9e..5df4382b7e 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -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"
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index d2a006671a..5649a70800 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -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"
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index bfbd1fd382..50c052e993 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -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"
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 36eea9d11d..f772dfe93f 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -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"
diff --git a/src/backend/storage/file/reinit.c b/src/backend/storage/file/reinit.c
index 7b8a1253c4..74ff6c359b 100644
--- a/src/backend/storage/file/reinit.c
+++ b/src/backend/storage/file/reinit.c
@@ -16,7 +16,6 @@
#include <unistd.h>
-#include "catalog/catalog.h"
#include "common/relpath.h"
#include "storage/copydir.h"
#include "storage/fd.h"
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index bb96881cad..2ec103e604 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -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"
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index e9f22c764e..4907a37903 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -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"
diff --git a/src/bin/pg_rewind/copy_fetch.c b/src/bin/pg_rewind/copy_fetch.c
index 04db409675..160a912847 100644
--- a/src/bin/pg_rewind/copy_fetch.c
+++ b/src/bin/pg_rewind/copy_fetch.c
@@ -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);
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index c3fc519895..e45e6d44ec 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -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"
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c
index fa845bbf7d..9a085ea258 100644
--- a/src/bin/pg_rewind/libpq_fetch.c
+++ b/src/bin/pg_rewind/libpq_fetch.c
@@ -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"
diff --git a/src/common/relpath.c b/src/common/relpath.c
index f0fa6742b3..e8170ed712 100644
--- a/src/common/relpath.c
+++ b/src/common/relpath.c
@@ -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"
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
index 3e280b3750..197e77f7f4 100644
--- a/src/include/catalog/catalog.h
+++ b/src/include/catalog/catalog.h
@@ -14,18 +14,9 @@
#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);
diff --git a/src/include/common/relpath.h b/src/include/common/relpath.h
index 9137dc9ed3..82d817a53c 100644
--- a/src/include/common/relpath.h
+++ b/src/include/common/relpath.h
@@ -14,6 +14,22 @@
#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.
*
* The physical storage of a relation consists of one or more forks.