Use fork names instead of numbers in the file names for additional
[PostgreSQL.git] / src / include / storage / relfilenode.h
blobcb0d44ef3105db02fe655ef7409147dd6fcaef46
1 /*-------------------------------------------------------------------------
3 * relfilenode.h
4 * Physical access information for relations.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
14 #ifndef RELFILENODE_H
15 #define RELFILENODE_H
18 * The physical storage of a relation consists of one or more forks. The
19 * main fork is always created, but in addition to that there can be
20 * additional forks for storing various metadata. ForkNumber is used when
21 * we need to refer to a specific fork in a relation.
23 typedef enum ForkNumber
25 InvalidForkNumber = -1,
26 MAIN_FORKNUM = 0,
27 FSM_FORKNUM
29 * NOTE: if you add a new fork, change MAX_FORKNUM below and update the
30 * forkNames array in catalog.c
32 } ForkNumber;
34 #define MAX_FORKNUM FSM_FORKNUM
37 * RelFileNode must provide all that we need to know to physically access
38 * a relation. Note, however, that a "physical" relation is comprised of
39 * multiple files on the filesystem, as each fork is stored as a separate
40 * file, and each fork can be divided into multiple segments. See md.c.
42 * spcNode identifies the tablespace of the relation. It corresponds to
43 * pg_tablespace.oid.
45 * dbNode identifies the database of the relation. It is zero for
46 * "shared" relations (those common to all databases of a cluster).
47 * Nonzero dbNode values correspond to pg_database.oid.
49 * relNode identifies the specific relation. relNode corresponds to
50 * pg_class.relfilenode (NOT pg_class.oid, because we need to be able
51 * to assign new physical files to relations in some situations).
52 * Notice that relNode is only unique within a particular database.
54 * Note: spcNode must be GLOBALTABLESPACE_OID if and only if dbNode is
55 * zero. We support shared relations only in the "global" tablespace.
57 * Note: in pg_class we allow reltablespace == 0 to denote that the
58 * relation is stored in its database's "default" tablespace (as
59 * identified by pg_database.dattablespace). However this shorthand
60 * is NOT allowed in RelFileNode structs --- the real tablespace ID
61 * must be supplied when setting spcNode.
63 typedef struct RelFileNode
65 Oid spcNode; /* tablespace */
66 Oid dbNode; /* database */
67 Oid relNode; /* relation */
68 } RelFileNode;
71 * Note: RelFileNodeEquals compares relNode first since that is most likely
72 * to be different in two unequal RelFileNodes. It is probably redundant
73 * to compare spcNode if the other two fields are found equal, but do it
74 * anyway to be sure.
76 #define RelFileNodeEquals(node1, node2) \
77 ((node1).relNode == (node2).relNode && \
78 (node1).dbNode == (node2).dbNode && \
79 (node1).spcNode == (node2).spcNode)
82 * RelFileFork identifies a particular fork of a relation.
84 typedef struct RelFileFork
86 RelFileNode rnode;
87 ForkNumber forknum;
88 } RelFileFork;
90 #endif /* RELFILENODE_H */