1 /*-------------------------------------------------------------------------
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: pgsql/src/include/storage/relfilenode.h,v 1.21 2008/12/03 13:05:22 heikki Exp $
12 *-------------------------------------------------------------------------
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,
30 * NOTE: if you add a new fork, change MAX_FORKNUM below and update the
31 * forkNames array in catalog.c
35 #define MAX_FORKNUM VISIBILITYMAP_FORKNUM
38 * RelFileNode must provide all that we need to know to physically access
39 * a relation. Note, however, that a "physical" relation is comprised of
40 * multiple files on the filesystem, as each fork is stored as a separate
41 * file, and each fork can be divided into multiple segments. See md.c.
43 * spcNode identifies the tablespace of the relation. It corresponds to
46 * dbNode identifies the database of the relation. It is zero for
47 * "shared" relations (those common to all databases of a cluster).
48 * Nonzero dbNode values correspond to pg_database.oid.
50 * relNode identifies the specific relation. relNode corresponds to
51 * pg_class.relfilenode (NOT pg_class.oid, because we need to be able
52 * to assign new physical files to relations in some situations).
53 * Notice that relNode is only unique within a particular database.
55 * Note: spcNode must be GLOBALTABLESPACE_OID if and only if dbNode is
56 * zero. We support shared relations only in the "global" tablespace.
58 * Note: in pg_class we allow reltablespace == 0 to denote that the
59 * relation is stored in its database's "default" tablespace (as
60 * identified by pg_database.dattablespace). However this shorthand
61 * is NOT allowed in RelFileNode structs --- the real tablespace ID
62 * must be supplied when setting spcNode.
64 typedef struct RelFileNode
66 Oid spcNode; /* tablespace */
67 Oid dbNode; /* database */
68 Oid relNode; /* relation */
72 * Note: RelFileNodeEquals compares relNode first since that is most likely
73 * to be different in two unequal RelFileNodes. It is probably redundant
74 * to compare spcNode if the other two fields are found equal, but do it
77 #define RelFileNodeEquals(node1, node2) \
78 ((node1).relNode == (node2).relNode && \
79 (node1).dbNode == (node2).dbNode && \
80 (node1).spcNode == (node2).spcNode)
82 #endif /* RELFILENODE_H */