PostgreSQL Source Code  git master
pg_class.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_class.h
4  * definition of the "relation" system catalog (pg_class)
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/catalog/pg_class.h
11  *
12  * NOTES
13  * The Catalog.pm module reads this file and derives schema
14  * information.
15  *
16  *-------------------------------------------------------------------------
17  */
18 #ifndef PG_CLASS_H
19 #define PG_CLASS_H
20 
21 #include "catalog/genbki.h"
22 #include "catalog/pg_class_d.h"
23 
24 /* ----------------
25  * pg_class definition. cpp turns this into
26  * typedef struct FormData_pg_class
27  * ----------------
28  */
29 CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,RelationRelation_Rowtype_Id) BKI_SCHEMA_MACRO
30 {
31  /* oid */
32  Oid oid;
33 
34  /* class name */
36 
37  /* OID of namespace containing this class */
38  Oid relnamespace BKI_DEFAULT(PGNSP);
39 
40  /* OID of entry in pg_type for table's implicit row type */
41  Oid reltype BKI_LOOKUP(pg_type);
42 
43  /* OID of entry in pg_type for underlying composite type */
44  Oid reloftype BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
45 
46  /* class owner */
47  Oid relowner BKI_DEFAULT(PGUID);
48 
49  /* access method; 0 if not a table / index */
50  Oid relam BKI_LOOKUP(pg_am);
51 
52  /* identifier of physical storage file */
53  /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
55 
56  /* identifier of table space for relation (0 means default for database) */
57  Oid reltablespace BKI_DEFAULT(0) BKI_LOOKUP(pg_tablespace);
58 
59  /* # of blocks (not always up-to-date) */
61 
62  /* # of tuples (not always up-to-date) */
64 
65  /* # of all-visible blocks (not always up-to-date) */
67 
68  /* OID of toast table; 0 if none */
70 
71  /* T if has (or has had) any indexes */
73 
74  /* T if shared across databases */
76 
77  /* see RELPERSISTENCE_xxx constants below */
79 
80  /* see RELKIND_xxx constants below */
81  char relkind;
82 
83  /* number of user attributes */
85 
86  /*
87  * Class pg_attribute must contain exactly "relnatts" user attributes
88  * (with attnums ranging from 1 to relnatts) for this class. It may also
89  * contain entries with negative attnums for system attributes.
90  */
91 
92  /* # of CHECK constraints for class */
94 
95  /* has (or has had) any rules */
97 
98  /* has (or has had) any TRIGGERs */
100 
101  /* has (or has had) child tables or indexes */
103 
104  /* row security is enabled or not */
106 
107  /* row security forced for owners or not */
109 
110  /* matview currently holds query results */
112 
113  /* see REPLICA_IDENTITY_xxx constants */
115 
116  /* is relation a partition? */
118 
119  /* heap for rewrite during DDL, link to original rel */
120  Oid relrewrite BKI_DEFAULT(0);
121 
122  /* all Xids < this are frozen in this rel */
124 
125  /* all multixacts in this rel are >= this; it is really a MultiXactId */
127 
128 #ifdef CATALOG_VARLEN /* variable-length fields start here */
129  /* NOTE: These fields are not present in a relcache entry's rd_rel field. */
130  /* access permissions */
131  aclitem relacl[1];
132 
133  /* access-method-specific options */
134  text reloptions[1];
135 
136  /* partition bound node tree */
137  pg_node_tree relpartbound;
138 #endif
140 
141 /* Size of fixed part of pg_class tuples, not counting var-length fields */
142 #define CLASS_TUPLE_SIZE \
143  (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId))
144 
145 /* ----------------
146  * Form_pg_class corresponds to a pointer to a tuple with
147  * the format of pg_class relation.
148  * ----------------
149  */
151 
152 #ifdef EXPOSE_TO_CLIENT_CODE
153 
154 #define RELKIND_RELATION 'r' /* ordinary table */
155 #define RELKIND_INDEX 'i' /* secondary index */
156 #define RELKIND_SEQUENCE 'S' /* sequence object */
157 #define RELKIND_TOASTVALUE 't' /* for out-of-line values */
158 #define RELKIND_VIEW 'v' /* view */
159 #define RELKIND_MATVIEW 'm' /* materialized view */
160 #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
161 #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
162 #define RELKIND_PARTITIONED_TABLE 'p' /* partitioned table */
163 #define RELKIND_PARTITIONED_INDEX 'I' /* partitioned index */
164 
165 #define RELPERSISTENCE_PERMANENT 'p' /* regular table */
166 #define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */
167 #define RELPERSISTENCE_TEMP 't' /* temporary table */
168 
169 /* default selection for replica identity (primary key or nothing) */
170 #define REPLICA_IDENTITY_DEFAULT 'd'
171 /* no replica identity is logged for this relation */
172 #define REPLICA_IDENTITY_NOTHING 'n'
173 /* all columns are logged as replica identity */
174 #define REPLICA_IDENTITY_FULL 'f'
175 /*
176  * an explicitly chosen candidate key's columns are used as replica identity.
177  * Note this will still be set if the index has been dropped; in that case it
178  * has the same meaning as 'd'.
179  */
180 #define REPLICA_IDENTITY_INDEX 'i'
181 
182 /*
183  * Relation kinds that have physical storage. These relations normally have
184  * relfilenode set to non-zero, but it can also be zero if the relation is
185  * mapped.
186  */
187 #define RELKIND_HAS_STORAGE(relkind) \
188  ((relkind) == RELKIND_RELATION || \
189  (relkind) == RELKIND_INDEX || \
190  (relkind) == RELKIND_SEQUENCE || \
191  (relkind) == RELKIND_TOASTVALUE || \
192  (relkind) == RELKIND_MATVIEW)
193 
194 
195 #endif /* EXPOSE_TO_CLIENT_CODE */
196 
197 #endif /* PG_CLASS_H */
#define BKI_BOOTSTRAP
Definition: genbki.h:26
signed short int16
Definition: c.h:346
char relreplident
Definition: pg_class.h:114
bool relispopulated
Definition: pg_class.h:111
uint32 TransactionId
Definition: c.h:508
bool relhassubclass
Definition: pg_class.h:102
CATALOG(pg_class, 1259, RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83
bool relhasrules
Definition: pg_class.h:96
int32 relallvisible
Definition: pg_class.h:66
RelationRelation_Rowtype_Id BKI_SCHEMA_MACRO
Definition: pg_class.h:30
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
int32 relpages
Definition: pg_class.h:60
char relkind
Definition: pg_class.h:81
signed int int32
Definition: c.h:347
Oid relnamespace BKI_DEFAULT(PGNSP)
char relpersistence
Definition: pg_class.h:78
bool relisshared
Definition: pg_class.h:75
Oid relfilenode
Definition: pg_class.h:54
Definition: c.h:604
bool relforcerowsecurity
Definition: pg_class.h:108
bool relispartition
Definition: pg_class.h:117
Oid reltoastrelid
Definition: pg_class.h:69
bool relrowsecurity
Definition: pg_class.h:105
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition: genbki.h:28
int16 relnatts
Definition: pg_class.h:84
float float4
Definition: c.h:491
int16 relchecks
Definition: pg_class.h:93
TransactionId relminmxid
Definition: pg_class.h:126
bool relhasindex
Definition: pg_class.h:72
Oid reltype BKI_LOOKUP(pg_type)
bool relhastriggers
Definition: pg_class.h:99
FormData_pg_class
Definition: pg_class.h:139
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150
TransactionId relfrozenxid
Definition: pg_class.h:123
Definition: c.h:550
float4 reltuples
Definition: pg_class.h:63