| 1 | /*------------------------------------------------------------------------- | 
|---|
| 2 | * | 
|---|
| 3 | * relpath.h | 
|---|
| 4 | *		Declarations for GetRelationPath() and friends | 
|---|
| 5 | * | 
|---|
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group | 
|---|
| 7 | * Portions Copyright (c) 1994, Regents of the University of California | 
|---|
| 8 | * | 
|---|
| 9 | * src/include/common/relpath.h | 
|---|
| 10 | * | 
|---|
| 11 | *------------------------------------------------------------------------- | 
|---|
| 12 | */ | 
|---|
| 13 | #ifndef RELPATH_H | 
|---|
| 14 | #define RELPATH_H | 
|---|
| 15 |  | 
|---|
| 16 | /* | 
|---|
| 17 | *	'pgrminclude ignore' needed here because CppAsString2() does not throw | 
|---|
| 18 | *	an error if the symbol is not defined. | 
|---|
| 19 | */ | 
|---|
| 20 | #include "catalog/catversion.h" /* pgrminclude ignore */ | 
|---|
| 21 |  | 
|---|
| 22 |  | 
|---|
| 23 | /* | 
|---|
| 24 | * Name of major-version-specific tablespace subdirectories | 
|---|
| 25 | */ | 
|---|
| 26 | #define TABLESPACE_VERSION_DIRECTORY	"PG_" PG_MAJORVERSION "_" \ | 
|---|
| 27 | CppAsString2(CATALOG_VERSION_NO) | 
|---|
| 28 |  | 
|---|
| 29 | /* Characters to allow for an OID in a relation path */ | 
|---|
| 30 | #define OIDCHARS		10		/* max chars printed by %u */ | 
|---|
| 31 |  | 
|---|
| 32 | /* | 
|---|
| 33 | * Stuff for fork names. | 
|---|
| 34 | * | 
|---|
| 35 | * The physical storage of a relation consists of one or more forks. | 
|---|
| 36 | * The main fork is always created, but in addition to that there can be | 
|---|
| 37 | * additional forks for storing various metadata. ForkNumber is used when | 
|---|
| 38 | * we need to refer to a specific fork in a relation. | 
|---|
| 39 | */ | 
|---|
| 40 | typedef enum ForkNumber | 
|---|
| 41 | { | 
|---|
| 42 | InvalidForkNumber = -1, | 
|---|
| 43 | MAIN_FORKNUM = 0, | 
|---|
| 44 | FSM_FORKNUM, | 
|---|
| 45 | VISIBILITYMAP_FORKNUM, | 
|---|
| 46 | INIT_FORKNUM | 
|---|
| 47 |  | 
|---|
| 48 | /* | 
|---|
| 49 | * NOTE: if you add a new fork, change MAX_FORKNUM and possibly | 
|---|
| 50 | * FORKNAMECHARS below, and update the forkNames array in | 
|---|
| 51 | * src/common/relpath.c | 
|---|
| 52 | */ | 
|---|
| 53 | } ForkNumber; | 
|---|
| 54 |  | 
|---|
| 55 | #define MAX_FORKNUM		INIT_FORKNUM | 
|---|
| 56 |  | 
|---|
| 57 | #define FORKNAMECHARS	4		/* max chars for a fork name */ | 
|---|
| 58 |  | 
|---|
| 59 | extern const char *const forkNames[]; | 
|---|
| 60 |  | 
|---|
| 61 | extern ForkNumber forkname_to_number(const char *forkName); | 
|---|
| 62 | extern int	forkname_chars(const char *str, ForkNumber *fork); | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | * Stuff for computing filesystem pathnames for relations. | 
|---|
| 66 | */ | 
|---|
| 67 | extern char *GetDatabasePath(Oid dbNode, Oid spcNode); | 
|---|
| 68 |  | 
|---|
| 69 | extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode, | 
|---|
| 70 | int backendId, ForkNumber forkNumber); | 
|---|
| 71 |  | 
|---|
| 72 | /* | 
|---|
| 73 | * Wrapper macros for GetRelationPath.  Beware of multiple | 
|---|
| 74 | * evaluation of the RelFileNode or RelFileNodeBackend argument! | 
|---|
| 75 | */ | 
|---|
| 76 |  | 
|---|
| 77 | /* First argument is a RelFileNode */ | 
|---|
| 78 | #define relpathbackend(rnode, backend, forknum) \ | 
|---|
| 79 | GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \ | 
|---|
| 80 | backend, forknum) | 
|---|
| 81 |  | 
|---|
| 82 | /* First argument is a RelFileNode */ | 
|---|
| 83 | #define relpathperm(rnode, forknum) \ | 
|---|
| 84 | relpathbackend(rnode, InvalidBackendId, forknum) | 
|---|
| 85 |  | 
|---|
| 86 | /* First argument is a RelFileNodeBackend */ | 
|---|
| 87 | #define relpath(rnode, forknum) \ | 
|---|
| 88 | relpathbackend((rnode).node, (rnode).backend, forknum) | 
|---|
| 89 |  | 
|---|
| 90 | #endif							/* RELPATH_H */ | 
|---|
| 91 |  | 
|---|