PostgreSQL Source Code
git master
relfilelocator.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* relfilelocator.h
4
* Physical access information for relations.
5
*
6
*
7
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
9
*
10
* src/include/storage/relfilelocator.h
11
*
12
*-------------------------------------------------------------------------
13
*/
14
#ifndef RELFILELOCATOR_H
15
#define RELFILELOCATOR_H
16
17
#include "
common/relpath.h
"
18
#include "
storage/procnumber.h
"
19
20
/*
21
* RelFileLocator must provide all that we need to know to physically access
22
* a relation, with the exception of the backend's proc number, which can be
23
* provided separately. Note, however, that a "physical" relation is
24
* comprised of multiple files on the filesystem, as each fork is stored as
25
* a separate file, and each fork can be divided into multiple segments. See
26
* md.c.
27
*
28
* spcOid identifies the tablespace of the relation. It corresponds to
29
* pg_tablespace.oid.
30
*
31
* dbOid identifies the database of the relation. It is zero for
32
* "shared" relations (those common to all databases of a cluster).
33
* Nonzero dbOid values correspond to pg_database.oid.
34
*
35
* relNumber identifies the specific relation. relNumber corresponds to
36
* pg_class.relfilenode (NOT pg_class.oid, because we need to be able
37
* to assign new physical files to relations in some situations).
38
* Notice that relNumber is only unique within a database in a particular
39
* tablespace.
40
*
41
* Note: spcOid must be GLOBALTABLESPACE_OID if and only if dbOid is
42
* zero. We support shared relations only in the "global" tablespace.
43
*
44
* Note: in pg_class we allow reltablespace == 0 to denote that the
45
* relation is stored in its database's "default" tablespace (as
46
* identified by pg_database.dattablespace). However this shorthand
47
* is NOT allowed in RelFileLocator structs --- the real tablespace ID
48
* must be supplied when setting spcOid.
49
*
50
* Note: in pg_class, relfilenode can be zero to denote that the relation
51
* is a "mapped" relation, whose current true filenode number is available
52
* from relmapper.c. Again, this case is NOT allowed in RelFileLocators.
53
*
54
* Note: various places use RelFileLocator in hashtable keys. Therefore,
55
* there *must not* be any unused padding bytes in this struct. That
56
* should be safe as long as all the fields are of type Oid.
57
*/
58
typedef
struct
RelFileLocator
59
{
60
Oid
spcOid
;
/* tablespace */
61
Oid
dbOid
;
/* database */
62
RelFileNumber
relNumber
;
/* relation */
63
}
RelFileLocator
;
64
65
/*
66
* Augmenting a relfilelocator with the backend's proc number provides all the
67
* information we need to locate the physical storage. 'backend' is
68
* INVALID_PROC_NUMBER for regular relations (those accessible to more than
69
* one backend), or the owning backend's proc number for backend-local
70
* relations. Backend-local relations are always transient and removed in
71
* case of a database crash; they are never WAL-logged or fsync'd.
72
*/
73
typedef
struct
RelFileLocatorBackend
74
{
75
RelFileLocator
locator
;
76
ProcNumber
backend
;
77
}
RelFileLocatorBackend
;
78
79
#define RelFileLocatorBackendIsTemp(rlocator) \
80
((rlocator).backend != INVALID_PROC_NUMBER)
81
82
/*
83
* Note: RelFileLocatorEquals and RelFileLocatorBackendEquals compare relNumber
84
* first since that is most likely to be different in two unequal
85
* RelFileLocators. It is probably redundant to compare spcOid if the other
86
* fields are found equal, but do it anyway to be sure. Likewise for checking
87
* the backend number in RelFileLocatorBackendEquals.
88
*/
89
#define RelFileLocatorEquals(locator1, locator2) \
90
((locator1).relNumber == (locator2).relNumber && \
91
(locator1).dbOid == (locator2).dbOid && \
92
(locator1).spcOid == (locator2).spcOid)
93
94
#define RelFileLocatorBackendEquals(locator1, locator2) \
95
((locator1).locator.relNumber == (locator2).locator.relNumber && \
96
(locator1).locator.dbOid == (locator2).locator.dbOid && \
97
(locator1).backend == (locator2).backend && \
98
(locator1).locator.spcOid == (locator2).locator.spcOid)
99
100
#endif
/* RELFILELOCATOR_H */
Oid
unsigned int Oid
Definition:
postgres_ext.h:31
procnumber.h
ProcNumber
int ProcNumber
Definition:
procnumber.h:24
RelFileLocator
struct RelFileLocator RelFileLocator
RelFileLocatorBackend
struct RelFileLocatorBackend RelFileLocatorBackend
relpath.h
RelFileNumber
Oid RelFileNumber
Definition:
relpath.h:25
RelFileLocatorBackend
Definition:
relfilelocator.h:74
RelFileLocatorBackend::backend
ProcNumber backend
Definition:
relfilelocator.h:76
RelFileLocatorBackend::locator
RelFileLocator locator
Definition:
relfilelocator.h:75
RelFileLocator
Definition:
relfilelocator.h:59
RelFileLocator::spcOid
Oid spcOid
Definition:
relfilelocator.h:60
RelFileLocator::relNumber
RelFileNumber relNumber
Definition:
relfilelocator.h:62
RelFileLocator::dbOid
Oid dbOid
Definition:
relfilelocator.h:61
src
include
storage
relfilelocator.h
Generated on Wed Nov 6 2024 18:13:25 for PostgreSQL Source Code by
1.9.1