diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/contrib/pg_xlogdump/pg_xlogdump.c
index 3fb9099649..31b5d7589a 100644
--- a/contrib/pg_xlogdump/pg_xlogdump.c
+++ b/contrib/pg_xlogdump/pg_xlogdump.c
@@ -19,7 +19,6 @@
#include "access/xlogreader.h"
#include "access/transam.h"
#include "common/fe_memutils.h"
-#include "common/relpath.h"
#include "getopt_long.h"
#include "rmgrdesc.h"
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 3a83ab2216..d04dd747af 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -16847,7 +16847,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
bigint
Disk space used by the specified fork ('main',
- 'fsm' or 'vm'>)
+ 'fsm', 'vm'>, or 'init'>)
of the specified table or index
@@ -16951,14 +16951,16 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
pg_relation_size> accepts the OID or name of a table, index or
- toast table, and returns the on-disk size in bytes. Specifying
- 'main' or leaving out the second argument returns the
- size of the main data fork of the relation. Specifying
- 'fsm' returns the size of the
- Free Space Map (see ) associated with the
- relation. Specifying 'vm' returns the size of the
- Visibility Map (see ) associated with the
- relation. Note that this function shows the size of only one fork;
+ toast table, and returns the on-disk size in bytes.
+ Specifying 'main' or leaving out the second argument
+ returns the size of the main data fork of the relation.
+ Specifying 'fsm' returns the size of the Free Space
+ Map (see ) associated with the relation.
+ Specifying 'vm' returns the size of the Visibility
+ Map (see ) associated with the relation.
+ Specifying 'init' returns the size of the
+ initialization fork, if any, associated with the relation.
+ Note that this function shows the size of only one fork;
for most purposes it is more convenient to use the higher-level
functions pg_total_relation_size> or
pg_table_size>.
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index 2e451a9ea8..aa72d4c4c3 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -16,7 +16,6 @@
#include "catalog/catalog.h"
#include "catalog/storage_xlog.h"
-#include "common/relpath.h"
void
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index e8fabc174e..7c43d4c06f 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -16,7 +16,6 @@
#include "access/xact.h"
#include "catalog/catalog.h"
-#include "common/relpath.h"
#include "storage/sinval.h"
#include "utils/timestamp.h"
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index cc9a472e1f..e3d7b6681f 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -17,7 +17,6 @@
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "catalog/pg_control.h"
-#include "common/relpath.h"
#include "utils/guc.h"
#include "utils/timestamp.h"
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index 05e74de921..b7829ff4c6 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -20,7 +20,6 @@
#include "access/xlog.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
-#include "common/relpath.h"
#include "storage/smgr.h"
#include "utils/guc.h"
#include "utils/hsearch.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 282e0b9ae8..3ec360c2be 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -37,7 +37,6 @@
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/toasting.h"
-#include "common/relpath.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/fmgroids.h"
@@ -45,56 +44,6 @@
#include "utils/tqual.h"
-
-/*
- * forkname_to_number - look up fork number by name
- */
-ForkNumber
-forkname_to_number(char *forkName)
-{
- ForkNumber forkNum;
-
- for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- if (strcmp(forkNames[forkNum], forkName) == 0)
- return forkNum;
-
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid fork name"),
- errhint("Valid fork names are \"main\", \"fsm\", and \"vm\".")));
- return InvalidForkNumber; /* keep compiler quiet */
-}
-
-/*
- * GetDatabasePath - construct path to a database dir
- *
- * Result is a palloc'd string.
- *
- * XXX this must agree with relpath()!
- */
-char *
-GetDatabasePath(Oid dbNode, Oid spcNode)
-{
- if (spcNode == GLOBALTABLESPACE_OID)
- {
- /* Shared system relations live in {datadir}/global */
- Assert(dbNode == 0);
- return pstrdup("global");
- }
- else if (spcNode == DEFAULTTABLESPACE_OID)
- {
- /* The default tablespace is {datadir}/base */
- return psprintf("base/%u", dbNode);
- }
- else
- {
- /* All other tablespaces are accessed via symlinks */
- return psprintf("pg_tblspc/%u/%s/%u",
- spcNode, TABLESPACE_VERSION_DIRECTORY, dbNode);
- }
-}
-
-
/*
* IsSystemRelation
* True iff the relation is either a system catalog or toast table.
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f5ae98ff80..619aa78d80 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -51,7 +51,6 @@
#include "commands/tablespace.h"
#include "commands/trigger.h"
#include "commands/typecmds.h"
-#include "common/relpath.h"
#include "executor/executor.h"
#include "foreign/foreign.h"
#include "miscadmin.h"
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 9421dc2e4e..357e6e1974 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -68,7 +68,6 @@
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "commands/user.h"
-#include "common/relpath.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
#include "storage/fd.h"
@@ -278,11 +277,11 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
/*
* Check that location isn't too long. Remember that we're going to append
- * 'PG_XXX//.'. FYI, we never actually reference the
- * whole path, but mkdir() uses the first two parts.
+ * 'PG_XXX//_.'. FYI, we never actually
+ * reference the whole path here, but mkdir() uses the first two parts.
*/
if (strlen(location) + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 +
- OIDCHARS + 1 + OIDCHARS + 1 + OIDCHARS > MAXPGPATH)
+ OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1 + OIDCHARS > MAXPGPATH)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("tablespace location \"%s\" is too long",
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index f611f591b6..42e66f2fed 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -18,8 +18,8 @@
#include
#include "access/xlog_internal.h" /* for pg_start/stop_backup */
+#include "catalog/catalog.h"
#include "catalog/pg_type.h"
-#include "common/relpath.h"
#include "lib/stringinfo.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 4493930eda..a89099b503 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -50,28 +50,20 @@
#include
#include
-#include "miscadmin.h"
-
#include "access/rewriteheap.h"
#include "access/transam.h"
#include "access/tuptoaster.h"
#include "access/xact.h"
-
#include "catalog/catalog.h"
-
-#include "common/relpath.h"
-
#include "lib/binaryheap.h"
-
+#include "miscadmin.h"
#include "replication/logical.h"
#include "replication/reorderbuffer.h"
#include "replication/slot.h"
#include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */
-
#include "storage/bufmgr.h"
#include "storage/fd.h"
#include "storage/sinval.h"
-
#include "utils/builtins.h"
#include "utils/combocid.h"
#include "utils/memdebug.h"
@@ -80,6 +72,7 @@
#include "utils/relfilenodemap.h"
#include "utils/tqual.h"
+
/* entry for a hash table we use to map from xid to our transaction state */
typedef struct ReorderBufferTXNByIdEnt
{
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 4e46ddbba2..246f31bfe1 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -35,7 +35,6 @@
#include "catalog/catalog.h"
#include "catalog/storage.h"
-#include "common/relpath.h"
#include "executor/instrument.h"
#include "miscadmin.h"
#include "pg_trace.h"
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c
index 054aff717c..62adc1ce6b 100644
--- a/src/backend/storage/buffer/localbuf.c
+++ b/src/backend/storage/buffer/localbuf.c
@@ -16,7 +16,6 @@
#include "postgres.h"
#include "catalog/catalog.h"
-#include "common/relpath.h"
#include "executor/instrument.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 42dbe87ca4..0560bf9d72 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -71,7 +71,6 @@
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
-#include "common/relpath.h"
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/ipc.h"
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 8133a337f7..921861b0bd 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -28,7 +28,6 @@
#include "miscadmin.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
-#include "common/relpath.h"
#include "portability/instr_time.h"
#include "postmaster/bgwriter.h"
#include "storage/fd.h"
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 78fe468822..68ab0e1906 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -21,7 +21,6 @@
#include "catalog/pg_tablespace.h"
#include "commands/dbcommands.h"
#include "commands/tablespace.h"
-#include "common/relpath.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/acl.h"
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index e3893db658..241f738d60 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -25,7 +25,6 @@
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
-#include "common/relpath.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "parser/keywords.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index c8cea028d4..c947bff4fc 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -56,7 +56,6 @@
#include "catalog/schemapg.h"
#include "catalog/storage.h"
#include "commands/trigger.h"
-#include "common/relpath.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/planmain.h"
diff --git a/src/common/relpath.c b/src/common/relpath.c
index fbb5de6922..fc8b2732ea 100644
--- a/src/common/relpath.c
+++ b/src/common/relpath.c
@@ -1,6 +1,8 @@
/*-------------------------------------------------------------------------
* relpath.c
- * Shared frontend/backend code to find out pathnames of relation files
+ * Shared frontend/backend code to compute pathnames of relation files
+ *
+ * This module also contains some logic associated with fork names.
*
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
@@ -16,18 +18,18 @@
#include "postgres_fe.h"
#endif
+#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
#include "common/relpath.h"
#include "storage/backendid.h"
-#define FORKNAMECHARS 4 /* max chars for a fork name */
/*
* Lookup table of fork name by fork number.
*
- * If you add a new entry, remember to update the errhint below, and the
- * documentation for pg_relation_size(). Also keep FORKNAMECHARS above
- * up-to-date.
+ * If you add a new entry, remember to update the errhint in
+ * forkname_to_number() below, and update the SGML documentation for
+ * pg_relation_size().
*/
const char *const forkNames[] = {
"main", /* MAIN_FORKNUM */
@@ -36,6 +38,32 @@ const char *const forkNames[] = {
"init" /* INIT_FORKNUM */
};
+/*
+ * forkname_to_number - look up fork number by name
+ *
+ * In backend, we throw an error for no match; in frontend, we just
+ * return InvalidForkNumber.
+ */
+ForkNumber
+forkname_to_number(const char *forkName)
+{
+ ForkNumber forkNum;
+
+ for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
+ if (strcmp(forkNames[forkNum], forkName) == 0)
+ return forkNum;
+
+#ifndef FRONTEND
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid fork name"),
+ errhint("Valid fork names are \"main\", \"fsm\", "
+ "\"vm\", and \"init\".")));
+#endif
+
+ return InvalidForkNumber;
+}
+
/*
* forkname_chars
* We use this to figure out whether a filename could be a relation
@@ -63,80 +91,117 @@ forkname_chars(const char *str, ForkNumber *fork)
return len;
}
}
+ if (fork)
+ *fork = InvalidForkNumber;
return 0;
}
+
/*
- * relpathbackend - construct path to a relation's file
+ * GetDatabasePath - construct path to a database directory
*
* Result is a palloc'd string.
+ *
+ * XXX this must agree with GetRelationPath()!
*/
char *
-relpathbackend(RelFileNode rnode, BackendId backend, ForkNumber forknum)
+GetDatabasePath(Oid dbNode, Oid spcNode)
+{
+ if (spcNode == GLOBALTABLESPACE_OID)
+ {
+ /* Shared system relations live in {datadir}/global */
+ Assert(dbNode == 0);
+ return pstrdup("global");
+ }
+ else if (spcNode == DEFAULTTABLESPACE_OID)
+ {
+ /* The default tablespace is {datadir}/base */
+ return psprintf("base/%u", dbNode);
+ }
+ else
+ {
+ /* All other tablespaces are accessed via symlinks */
+ return psprintf("pg_tblspc/%u/%s/%u",
+ spcNode, TABLESPACE_VERSION_DIRECTORY, dbNode);
+ }
+}
+
+/*
+ * GetRelationPath - construct path to a relation's file
+ *
+ * Result is a palloc'd string.
+ *
+ * Note: ideally, backendId would be declared as type BackendId, but relpath.h
+ * would have to include a backend-only header to do that; doesn't seem worth
+ * the trouble considering BackendId is just int anyway.
+ */
+char *
+GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
+ int backendId, ForkNumber forkNumber)
{
char *path;
- if (rnode.spcNode == GLOBALTABLESPACE_OID)
+ if (spcNode == GLOBALTABLESPACE_OID)
{
/* Shared system relations live in {datadir}/global */
- Assert(rnode.dbNode == 0);
- Assert(backend == InvalidBackendId);
- if (forknum != MAIN_FORKNUM)
+ Assert(dbNode == 0);
+ Assert(backendId == InvalidBackendId);
+ if (forkNumber != MAIN_FORKNUM)
path = psprintf("global/%u_%s",
- rnode.relNode, forkNames[forknum]);
+ relNode, forkNames[forkNumber]);
else
- path = psprintf("global/%u", rnode.relNode);
+ path = psprintf("global/%u", relNode);
}
- else if (rnode.spcNode == DEFAULTTABLESPACE_OID)
+ else if (spcNode == DEFAULTTABLESPACE_OID)
{
/* The default tablespace is {datadir}/base */
- if (backend == InvalidBackendId)
+ if (backendId == InvalidBackendId)
{
- if (forknum != MAIN_FORKNUM)
+ if (forkNumber != MAIN_FORKNUM)
path = psprintf("base/%u/%u_%s",
- rnode.dbNode, rnode.relNode,
- forkNames[forknum]);
+ dbNode, relNode,
+ forkNames[forkNumber]);
else
path = psprintf("base/%u/%u",
- rnode.dbNode, rnode.relNode);
+ dbNode, relNode);
}
else
{
- if (forknum != MAIN_FORKNUM)
+ if (forkNumber != MAIN_FORKNUM)
path = psprintf("base/%u/t%d_%u_%s",
- rnode.dbNode, backend, rnode.relNode,
- forkNames[forknum]);
+ dbNode, backendId, relNode,
+ forkNames[forkNumber]);
else
path = psprintf("base/%u/t%d_%u",
- rnode.dbNode, backend, rnode.relNode);
+ dbNode, backendId, relNode);
}
}
else
{
/* All other tablespaces are accessed via symlinks */
- if (backend == InvalidBackendId)
+ if (backendId == InvalidBackendId)
{
- if (forknum != MAIN_FORKNUM)
+ if (forkNumber != MAIN_FORKNUM)
path = psprintf("pg_tblspc/%u/%s/%u/%u_%s",
- rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
- rnode.dbNode, rnode.relNode,
- forkNames[forknum]);
+ spcNode, TABLESPACE_VERSION_DIRECTORY,
+ dbNode, relNode,
+ forkNames[forkNumber]);
else
path = psprintf("pg_tblspc/%u/%s/%u/%u",
- rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
- rnode.dbNode, rnode.relNode);
+ spcNode, TABLESPACE_VERSION_DIRECTORY,
+ dbNode, relNode);
}
else
{
- if (forknum != MAIN_FORKNUM)
+ if (forkNumber != MAIN_FORKNUM)
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u_%s",
- rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
- rnode.dbNode, backend, rnode.relNode,
- forkNames[forknum]);
+ spcNode, TABLESPACE_VERSION_DIRECTORY,
+ dbNode, backendId, relNode,
+ forkNames[forkNumber]);
else
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u",
- rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
- rnode.dbNode, backend, rnode.relNode);
+ spcNode, TABLESPACE_VERSION_DIRECTORY,
+ dbNode, backendId, relNode);
}
}
return path;
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
index 534a081592..9d63ac22c8 100644
--- a/src/include/catalog/catalog.h
+++ b/src/include/catalog/catalog.h
@@ -14,13 +14,17 @@
#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 "storage/relfilenode.h"
#include "utils/relcache.h"
-extern ForkNumber forkname_to_number(char *forkName);
-
-extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
+#define OIDCHARS 10 /* max chars printed by %u */
+#define TABLESPACE_VERSION_DIRECTORY "PG_" PG_MAJORVERSION "_" \
+ CppAsString2(CATALOG_VERSION_NO)
extern bool IsSystemRelation(Relation relation);
diff --git a/src/include/common/relpath.h b/src/include/common/relpath.h
index 23a226d058..cdd9316f08 100644
--- a/src/include/common/relpath.h
+++ b/src/include/common/relpath.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* relpath.h
- * Declarations for relpath() and friends
+ * Declarations for GetRelationPath() and friends
*
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
@@ -14,29 +14,61 @@
#define RELPATH_H
/*
- * 'pgrminclude ignore' needed here because CppAsString2() does not throw
- * an error if the symbol is not defined.
+ * Stuff for fork names.
+ *
+ * The physical storage of a relation consists of one or more forks.
+ * The main fork is always created, but in addition to that there can be
+ * additional forks for storing various metadata. ForkNumber is used when
+ * we need to refer to a specific fork in a relation.
*/
-#include "catalog/catversion.h" /* pgrminclude ignore */
-#include "storage/relfilenode.h"
+typedef enum ForkNumber
+{
+ InvalidForkNumber = -1,
+ MAIN_FORKNUM = 0,
+ FSM_FORKNUM,
+ VISIBILITYMAP_FORKNUM,
+ INIT_FORKNUM
+ /*
+ * NOTE: if you add a new fork, change MAX_FORKNUM and possibly
+ * FORKNAMECHARS below, and update the forkNames array in
+ * src/common/relpath.c
+ */
+} ForkNumber;
-#define OIDCHARS 10 /* max chars printed by %u */
-#define TABLESPACE_VERSION_DIRECTORY "PG_" PG_MAJORVERSION "_" \
- CppAsString2(CATALOG_VERSION_NO)
+#define MAX_FORKNUM INIT_FORKNUM
+
+#define FORKNAMECHARS 4 /* max chars for a fork name */
extern const char *const forkNames[];
+extern ForkNumber forkname_to_number(const char *forkName);
extern int forkname_chars(const char *str, ForkNumber *fork);
-extern char *relpathbackend(RelFileNode rnode, BackendId backend,
- ForkNumber forknum);
-/* First argument is a RelFileNodeBackend */
-#define relpath(rnode, forknum) \
- relpathbackend((rnode).node, (rnode).backend, (forknum))
+/*
+ * Stuff for computing filesystem pathnames for relations.
+ */
+extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
+
+extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
+ int backendId, ForkNumber forkNumber);
+
+/*
+ * Wrapper macros for GetRelationPath. Beware of multiple
+ * evaluation of the RelFileNode or RelFileNodeBackend argument!
+ */
+
+/* First argument is a RelFileNode */
+#define relpathbackend(rnode, backend, forknum) \
+ GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \
+ backend, forknum)
/* First argument is a RelFileNode */
#define relpathperm(rnode, forknum) \
- relpathbackend((rnode), InvalidBackendId, (forknum))
+ relpathbackend(rnode, InvalidBackendId, forknum)
+
+/* First argument is a RelFileNodeBackend */
+#define relpath(rnode, forknum) \
+ relpathbackend((rnode).node, (rnode).backend, forknum)
#endif /* RELPATH_H */
diff --git a/src/include/storage/relfilenode.h b/src/include/storage/relfilenode.h
index 8616bd3a1e..d5b772ca9f 100644
--- a/src/include/storage/relfilenode.h
+++ b/src/include/storage/relfilenode.h
@@ -14,30 +14,9 @@
#ifndef RELFILENODE_H
#define RELFILENODE_H
+#include "common/relpath.h"
#include "storage/backendid.h"
-/*
- * The physical storage of a relation consists of one or more forks. The
- * main fork is always created, but in addition to that there can be
- * additional forks for storing various metadata. ForkNumber is used when
- * we need to refer to a specific fork in a relation.
- */
-typedef enum ForkNumber
-{
- InvalidForkNumber = -1,
- MAIN_FORKNUM = 0,
- FSM_FORKNUM,
- VISIBILITYMAP_FORKNUM,
- INIT_FORKNUM
-
- /*
- * NOTE: if you add a new fork, change MAX_FORKNUM below and update the
- * forkNames array in src/common/relpath.c
- */
-} ForkNumber;
-
-#define MAX_FORKNUM INIT_FORKNUM
-
/*
* RelFileNode must provide all that we need to know to physically access
* a relation, with the exception of the backend ID, which can be provided