PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
relpath.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * relpath.h
4  * Declarations for GetRelationPath() and friends
5  *
6  * Portions Copyright (c) 1996-2017, 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  * Stuff for fork names.
18  *
19  * The physical storage of a relation consists of one or more forks.
20  * The main fork is always created, but in addition to that there can be
21  * additional forks for storing various metadata. ForkNumber is used when
22  * we need to refer to a specific fork in a relation.
23  */
24 typedef enum ForkNumber
25 {
31 
32  /*
33  * NOTE: if you add a new fork, change MAX_FORKNUM and possibly
34  * FORKNAMECHARS below, and update the forkNames array in
35  * src/common/relpath.c
36  */
37 } ForkNumber;
38 
39 #define MAX_FORKNUM INIT_FORKNUM
40 
41 #define FORKNAMECHARS 4 /* max chars for a fork name */
42 
43 extern const char *const forkNames[];
44 
45 extern ForkNumber forkname_to_number(const char *forkName);
46 extern int forkname_chars(const char *str, ForkNumber *fork);
47 
48 /*
49  * Stuff for computing filesystem pathnames for relations.
50  */
51 extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
52 
53 extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
54  int backendId, ForkNumber forkNumber);
55 
56 /*
57  * Wrapper macros for GetRelationPath. Beware of multiple
58  * evaluation of the RelFileNode or RelFileNodeBackend argument!
59  */
60 
61 /* First argument is a RelFileNode */
62 #define relpathbackend(rnode, backend, forknum) \
63  GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \
64  backend, forknum)
65 
66 /* First argument is a RelFileNode */
67 #define relpathperm(rnode, forknum) \
68  relpathbackend(rnode, InvalidBackendId, forknum)
69 
70 /* First argument is a RelFileNodeBackend */
71 #define relpath(rnode, forknum) \
72  relpathbackend((rnode).node, (rnode).backend, forknum)
73 
74 #endif /* RELPATH_H */
ForkNumber forkname_to_number(const char *forkName)
Definition: relpath.c:48
char * GetDatabasePath(Oid dbNode, Oid spcNode)
Definition: relpath.c:108
unsigned int Oid
Definition: postgres_ext.h:31
char * GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode, int backendId, ForkNumber forkNumber)
Definition: relpath.c:139
const char *const forkNames[]
Definition: relpath.c:34
ForkNumber
Definition: relpath.h:24
int forkname_chars(const char *str, ForkNumber *fork)
Definition: relpath.c:79