aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/rmgrdesc/smgrdesc.c1
-rw-r--r--src/backend/access/rmgrdesc/xactdesc.c1
-rw-r--r--src/backend/access/rmgrdesc/xlogdesc.c1
-rw-r--r--src/backend/access/transam/xlogutils.c1
-rw-r--r--src/backend/catalog/catalog.c51
-rw-r--r--src/backend/commands/tablecmds.c1
-rw-r--r--src/backend/commands/tablespace.c7
-rw-r--r--src/backend/replication/basebackup.c2
-rw-r--r--src/backend/replication/logical/reorderbuffer.c11
-rw-r--r--src/backend/storage/buffer/bufmgr.c1
-rw-r--r--src/backend/storage/buffer/localbuf.c1
-rw-r--r--src/backend/storage/file/fd.c1
-rw-r--r--src/backend/storage/smgr/md.c1
-rw-r--r--src/backend/utils/adt/dbsize.c1
-rw-r--r--src/backend/utils/adt/misc.c1
-rw-r--r--src/backend/utils/cache/relcache.c1
-rw-r--r--src/common/relpath.c137
-rw-r--r--src/include/catalog/catalog.h12
-rw-r--r--src/include/common/relpath.h60
-rw-r--r--src/include/storage/relfilenode.h23
20 files changed, 162 insertions, 153 deletions
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index 2e451a9ea8d..aa72d4c4c3a 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 e8fabc174e2..7c43d4c06fd 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 cc9a472e1fa..e3d7b6681f3 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 05e74de9211..b7829ff4c6d 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 282e0b9ae8c..3ec360c2be5 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 f5ae98ff80e..619aa78d809 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 9421dc2e4e0..357e6e19741 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/<dboid>/<relid>.<nnn>'. FYI, we never actually reference the
- * whole path, but mkdir() uses the first two parts.
+ * 'PG_XXX/<dboid>/<relid>_<fork>.<nnn>'. 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 f611f591b61..42e66f2fed7 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -18,8 +18,8 @@
#include <time.h>
#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 4493930eda0..a89099b5036 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -50,28 +50,20 @@
#include <unistd.h>
#include <sys/stat.h>
-#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 4e46ddbba29..246f31bfe14 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 054aff717c7..62adc1ce6ba 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 42dbe87ca4b..0560bf9d72b 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 8133a337f7b..921861b0bd5 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 78fe4688226..68ab0e19061 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 e3893db6585..241f738d608 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 c8cea028d4e..c947bff4fca 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 fbb5de6922b..fc8b2732eaa 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 */
@@ -37,6 +39,32 @@ const char *const forkNames[] = {
};
/*
+ * 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
* fork (as opposed to an oddly named stray file that somehow ended
@@ -63,80 +91,117 @@ forkname_chars(const char *str, ForkNumber *fork)
return len;
}
}
+ if (fork)
+ *fork = InvalidForkNumber;
return 0;
}
+
+/*
+ * GetDatabasePath - construct path to a database directory
+ *
+ * Result is a palloc'd string.
+ *
+ * XXX this must agree with GetRelationPath()!
+ */
+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);
+ }
+}
+
/*
- * relpathbackend - construct path to a relation's file
+ * 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 *
-relpathbackend(RelFileNode rnode, BackendId backend, ForkNumber forknum)
+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 534a0815920..9d63ac22c8e 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 23a226d058e..cdd9316f08b 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 MAX_FORKNUM INIT_FORKNUM
-#define OIDCHARS 10 /* max chars printed by %u */
-#define TABLESPACE_VERSION_DIRECTORY "PG_" PG_MAJORVERSION "_" \
- CppAsString2(CATALOG_VERSION_NO)
+#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 8616bd3a1ec..d5b772ca9f6 100644
--- a/src/include/storage/relfilenode.h
+++ b/src/include/storage/relfilenode.h
@@ -14,31 +14,10 @@
#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
* separately. Note, however, that a "physical" relation is comprised of