PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_class.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_class.h
4  * definition of the system "relation" relation (pg_class)
5  * along with the relation's initial contents.
6  *
7  *
8  * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * src/include/catalog/pg_class.h
12  *
13  * NOTES
14  * the genbki.pl script reads this file and generates .bki
15  * information from the DATA() statements.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PG_CLASS_H
20 #define PG_CLASS_H
21 
22 #include "catalog/genbki.h"
23 
24 /* ----------------
25  * pg_class definition. cpp turns this into
26  * typedef struct FormData_pg_class
27  * ----------------
28  */
29 #define RelationRelationId 1259
30 #define RelationRelation_Rowtype_Id 83
31 
33 {
34  NameData relname; /* class name */
35  Oid relnamespace; /* OID of namespace containing this class */
36  Oid reltype; /* OID of entry in pg_type for table's
37  * implicit row type */
38  Oid reloftype; /* OID of entry in pg_type for underlying
39  * composite type */
40  Oid relowner; /* class owner */
41  Oid relam; /* index access method; 0 if not an index */
42  Oid relfilenode; /* identifier of physical storage file */
43 
44  /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
45  Oid reltablespace; /* identifier of table space for relation */
46  int32 relpages; /* # of blocks (not always up-to-date) */
47  float4 reltuples; /* # of tuples (not always up-to-date) */
48  int32 relallvisible; /* # of all-visible blocks (not always
49  * up-to-date) */
50  Oid reltoastrelid; /* OID of toast table; 0 if none */
51  bool relhasindex; /* T if has (or has had) any indexes */
52  bool relisshared; /* T if shared across databases */
53  char relpersistence; /* see RELPERSISTENCE_xxx constants below */
54  char relkind; /* see RELKIND_xxx constants below */
55  int16 relnatts; /* number of user attributes */
56 
57  /*
58  * Class pg_attribute must contain exactly "relnatts" user attributes
59  * (with attnums ranging from 1 to relnatts) for this class. It may also
60  * contain entries with negative attnums for system attributes.
61  */
62  int16 relchecks; /* # of CHECK constraints for class */
63  bool relhasoids; /* T if we generate OIDs for rows of rel */
64  bool relhaspkey; /* has (or has had) PRIMARY KEY index */
65  bool relhasrules; /* has (or has had) any rules */
66  bool relhastriggers; /* has (or has had) any TRIGGERs */
67  bool relhassubclass; /* has (or has had) derived classes */
68  bool relrowsecurity; /* row security is enabled or not */
69  bool relforcerowsecurity; /* row security forced for owners or not */
70  bool relispopulated; /* matview currently holds query results */
71  char relreplident; /* see REPLICA_IDENTITY_xxx constants */
72  TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
73  TransactionId relminmxid; /* all multixacts in this rel are >= this.
74  * this is really a MultiXactId */
75 
76 #ifdef CATALOG_VARLEN /* variable-length fields start here */
77  /* NOTE: These fields are not present in a relcache entry's rd_rel field. */
78  aclitem relacl[1]; /* access permissions */
79  text reloptions[1]; /* access-method-specific options */
80 #endif
82 
83 /* Size of fixed part of pg_class tuples, not counting var-length fields */
84 #define CLASS_TUPLE_SIZE \
85  (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId))
86 
87 /* ----------------
88  * Form_pg_class corresponds to a pointer to a tuple with
89  * the format of pg_class relation.
90  * ----------------
91  */
93 
94 /* ----------------
95  * compiler constants for pg_class
96  * ----------------
97  */
98 
99 #define Natts_pg_class 31
100 #define Anum_pg_class_relname 1
101 #define Anum_pg_class_relnamespace 2
102 #define Anum_pg_class_reltype 3
103 #define Anum_pg_class_reloftype 4
104 #define Anum_pg_class_relowner 5
105 #define Anum_pg_class_relam 6
106 #define Anum_pg_class_relfilenode 7
107 #define Anum_pg_class_reltablespace 8
108 #define Anum_pg_class_relpages 9
109 #define Anum_pg_class_reltuples 10
110 #define Anum_pg_class_relallvisible 11
111 #define Anum_pg_class_reltoastrelid 12
112 #define Anum_pg_class_relhasindex 13
113 #define Anum_pg_class_relisshared 14
114 #define Anum_pg_class_relpersistence 15
115 #define Anum_pg_class_relkind 16
116 #define Anum_pg_class_relnatts 17
117 #define Anum_pg_class_relchecks 18
118 #define Anum_pg_class_relhasoids 19
119 #define Anum_pg_class_relhaspkey 20
120 #define Anum_pg_class_relhasrules 21
121 #define Anum_pg_class_relhastriggers 22
122 #define Anum_pg_class_relhassubclass 23
123 #define Anum_pg_class_relrowsecurity 24
124 #define Anum_pg_class_relforcerowsecurity 25
125 #define Anum_pg_class_relispopulated 26
126 #define Anum_pg_class_relreplident 27
127 #define Anum_pg_class_relfrozenxid 28
128 #define Anum_pg_class_relminmxid 29
129 #define Anum_pg_class_relacl 30
130 #define Anum_pg_class_reloptions 31
131 
132 /* ----------------
133  * initial contents of pg_class
134  *
135  * NOTE: only "bootstrapped" relations need to be declared here. Be sure that
136  * the OIDs listed here match those given in their CATALOG macros, and that
137  * the relnatts values are correct.
138  * ----------------
139  */
140 
141 /*
142  * Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId;
143  * similarly, "1" in relminmxid stands for FirstMultiXactId
144  */
145 DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f f t n 3 1 _null_ _null_ ));
146 DESCR("");
147 DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f f f f t n 3 1 _null_ _null_ ));
148 DESCR("");
149 DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f f f f t n 3 1 _null_ _null_ ));
150 DESCR("");
151 DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 31 0 t f f f f f f t n 3 1 _null_ _null_ ));
152 DESCR("");
153 
154 
155 #define RELKIND_RELATION 'r' /* ordinary table */
156 #define RELKIND_INDEX 'i' /* secondary index */
157 #define RELKIND_SEQUENCE 'S' /* sequence object */
158 #define RELKIND_TOASTVALUE 't' /* for out-of-line values */
159 #define RELKIND_VIEW 'v' /* view */
160 #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
161 #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
162 #define RELKIND_MATVIEW 'm' /* materialized view */
163 
164 #define RELPERSISTENCE_PERMANENT 'p' /* regular table */
165 #define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */
166 #define RELPERSISTENCE_TEMP 't' /* temporary table */
167 
168 /* default selection for replica identity (primary key or nothing) */
169 #define REPLICA_IDENTITY_DEFAULT 'd'
170 /* no replica identity is logged for this relation */
171 #define REPLICA_IDENTITY_NOTHING 'n'
172 /* all columns are logged as replica identity */
173 #define REPLICA_IDENTITY_FULL 'f'
174 /*
175  * an explicitly chosen candidate key's columns are used as identity;
176  * will still be set if the index has been dropped, in that case it
177  * has the same meaning as 'd'
178  */
179 #define REPLICA_IDENTITY_INDEX 'i'
180 #endif /* PG_CLASS_H */
#define BKI_SCHEMA_MACRO
Definition: genbki.h:30
#define BKI_BOOTSTRAP
Definition: genbki.h:26
signed short int16
Definition: c.h:252
DESCR("")
uint32 TransactionId
Definition: c.h:393
DATA(insert OID=1247(pg_typePGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f f t n 3 1 _null_ _null_))
unsigned int Oid
Definition: postgres_ext.h:31
signed int int32
Definition: c.h:253
static char * relname(char const *dir, char const *base)
Definition: zic.c:755
Definition: c.h:488
#define BKI_ROWTYPE_OID(oid)
Definition: genbki.h:29
float float4
Definition: c.h:376
FormData_pg_class
Definition: pg_class.h:81
FormData_pg_class * Form_pg_class
Definition: pg_class.h:92
CATALOG(pg_class, 1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
Definition: pg_class.h:32
Definition: c.h:434