diff options
Diffstat (limited to 'src/include/common/relpath.h')
-rw-r--r-- | src/include/common/relpath.h | 60 |
1 files changed, 46 insertions, 14 deletions
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 */ |