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/6629.1523294509@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2018-04-09 14:39:58 -04:00
parent f5543d47bc
commit af1a949109
21 changed files with 17 additions and 29 deletions

View 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"

View 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"

View 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"

View File

@ -14,7 +14,6 @@
*/
#include "postgres.h"
#include "catalog/catalog.h"
#include "catalog/storage_xlog.h"

View 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"

View 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"

View 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"

View 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"

View 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"

View 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"

View 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"

View 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"

View File

@ -16,7 +16,6 @@
#include <unistd.h>
#include "catalog/catalog.h"
#include "common/relpath.h"
#include "storage/copydir.h"
#include "storage/fd.h"

View 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"

View 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"

View 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);

View 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"

View 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"

View 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"

View File

@ -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);

View File

@ -13,6 +13,22 @@
#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.
*