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
#include "pageinspect.h"
#include "access/htup_details.h"
-#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
#include <unistd.h>
#include "access/heapam.h"
-#include "catalog/catalog.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
#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"
*/
#include "postgres.h"
-#include "catalog/catalog.h"
#include "catalog/storage_xlog.h"
#include "access/transam.h"
#include "access/xact.h"
-#include "catalog/catalog.h"
#include "storage/sinval.h"
#include "storage/standbydefs.h"
#include "utils/timestamp.h"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#include <unistd.h>
-#include "catalog/catalog.h"
#include "common/relpath.h"
#include "storage/copydir.h"
#include "storage/fd.h"
#include "miscadmin.h"
#include "access/xlog.h"
-#include "catalog/catalog.h"
#include "pgstat.h"
#include "portability/instr_time.h"
#include "postmaster/bgwriter.h"
#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"
#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);
#include "pg_rewind.h"
#include "common/string.h"
-#include "catalog/catalog.h"
#include "catalog/pg_tablespace_d.h"
#include "storage/fd.h"
#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"
#include "postgres_fe.h"
#endif
-#include "catalog/catalog.h"
#include "catalog/pg_tablespace_d.h"
#include "common/relpath.h"
#include "storage/backendid.h"
#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);
#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.
*