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-2018, 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  NameData relname; /* class name */
32  Oid relnamespace; /* OID of namespace containing this class */
33  Oid reltype; /* OID of entry in pg_type for table's
34  * implicit row type */
35  Oid reloftype; /* OID of entry in pg_type for underlying
36  * composite type */
37  Oid relowner; /* class owner */
38  Oid relam; /* index access method; 0 if not an index */
39  Oid relfilenode; /* identifier of physical storage file */
40 
41  /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
42  Oid reltablespace; /* identifier of table space for relation */
43  int32 relpages; /* # of blocks (not always up-to-date) */
44  float4 reltuples; /* # of tuples (not always up-to-date) */
45  int32 relallvisible; /* # of all-visible blocks (not always
46  * up-to-date) */
47  Oid reltoastrelid; /* OID of toast table; 0 if none */
48  bool relhasindex; /* T if has (or has had) any indexes */
49  bool relisshared; /* T if shared across databases */
50  char relpersistence; /* see RELPERSISTENCE_xxx constants below */
51  char relkind; /* see RELKIND_xxx constants below */
52  int16 relnatts; /* number of user attributes */
53 
54  /*
55  * Class pg_attribute must contain exactly "relnatts" user attributes
56  * (with attnums ranging from 1 to relnatts) for this class. It may also
57  * contain entries with negative attnums for system attributes.
58  */
59  int16 relchecks; /* # of CHECK constraints for class */
60  bool relhasoids; /* T if we generate OIDs for rows of rel */
61  bool relhasrules; /* has (or has had) any rules */
62  bool relhastriggers; /* has (or has had) any TRIGGERs */
63  bool relhassubclass; /* has (or has had) derived classes */
64  bool relrowsecurity; /* row security is enabled or not */
65  bool relforcerowsecurity; /* row security forced for owners or
66  * not */
67  bool relispopulated; /* matview currently holds query results */
68  char relreplident; /* see REPLICA_IDENTITY_xxx constants */
69  bool relispartition; /* is relation a partition? */
70  Oid relrewrite; /* heap for rewrite during DDL, link to original rel */
71  TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
72  TransactionId relminmxid; /* all multixacts in this rel are >= this.
73  * this is really a MultiXactId */
74 
75 #ifdef CATALOG_VARLEN /* variable-length fields start here */
76  /* NOTE: These fields are not present in a relcache entry's rd_rel field. */
77  aclitem relacl[1]; /* access permissions */
78  text reloptions[1]; /* access-method-specific options */
79  pg_node_tree relpartbound; /* partition bound node tree */
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 #ifdef EXPOSE_TO_CLIENT_CODE
95 
96 #define RELKIND_RELATION 'r' /* ordinary table */
97 #define RELKIND_INDEX 'i' /* secondary index */
98 #define RELKIND_SEQUENCE 'S' /* sequence object */
99 #define RELKIND_TOASTVALUE 't' /* for out-of-line values */
100 #define RELKIND_VIEW 'v' /* view */
101 #define RELKIND_MATVIEW 'm' /* materialized view */
102 #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
103 #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
104 #define RELKIND_PARTITIONED_TABLE 'p' /* partitioned table */
105 #define RELKIND_PARTITIONED_INDEX 'I' /* partitioned index */
106 
107 #define RELPERSISTENCE_PERMANENT 'p' /* regular table */
108 #define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */
109 #define RELPERSISTENCE_TEMP 't' /* temporary table */
110 
111 /* default selection for replica identity (primary key or nothing) */
112 #define REPLICA_IDENTITY_DEFAULT 'd'
113 /* no replica identity is logged for this relation */
114 #define REPLICA_IDENTITY_NOTHING 'n'
115 /* all columns are logged as replica identity */
116 #define REPLICA_IDENTITY_FULL 'f'
117 /*
118  * an explicitly chosen candidate key's columns are used as replica identity.
119  * Note this will still be set if the index has been dropped; in that case it
120  * has the same meaning as 'd'.
121  */
122 #define REPLICA_IDENTITY_INDEX 'i'
123 
124 #endif /* EXPOSE_TO_CLIENT_CODE */
125 
126 #endif /* PG_CLASS_H */
#define BKI_BOOTSTRAP
Definition: genbki.h:26
bool relhasoids
Definition: pg_class.h:60
signed short int16
Definition: c.h:312
char relreplident
Definition: pg_class.h:68
bool relispopulated
Definition: pg_class.h:67
Oid relnamespace
Definition: pg_class.h:32
uint32 TransactionId
Definition: c.h:474
Oid reltype
Definition: pg_class.h:33
bool relhassubclass
Definition: pg_class.h:63
CATALOG(pg_class, 1259, RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83
bool relhasrules
Definition: pg_class.h:61
int32 relallvisible
Definition: pg_class.h:45
RelationRelation_Rowtype_Id BKI_SCHEMA_MACRO
Definition: pg_class.h:30
unsigned int Oid
Definition: postgres_ext.h:31
int32 relpages
Definition: pg_class.h:43
char relkind
Definition: pg_class.h:51
signed int int32
Definition: c.h:313
Oid relam
Definition: pg_class.h:38
char relpersistence
Definition: pg_class.h:50
bool relisshared
Definition: pg_class.h:49
Oid relfilenode
Definition: pg_class.h:39
Definition: c.h:570
Oid reltablespace
Definition: pg_class.h:42
bool relforcerowsecurity
Definition: pg_class.h:65
bool relispartition
Definition: pg_class.h:69
Oid reltoastrelid
Definition: pg_class.h:47
Oid relrewrite
Definition: pg_class.h:70
bool relrowsecurity
Definition: pg_class.h:64
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition: genbki.h:29
int16 relnatts
Definition: pg_class.h:52
float float4
Definition: c.h:457
int16 relchecks
Definition: pg_class.h:59
Oid reloftype
Definition: pg_class.h:35
TransactionId relminmxid
Definition: pg_class.h:72
bool relhasindex
Definition: pg_class.h:48
bool relhastriggers
Definition: pg_class.h:62
FormData_pg_class
Definition: pg_class.h:81
FormData_pg_class * Form_pg_class
Definition: pg_class.h:92
TransactionId relfrozenxid
Definition: pg_class.h:71
Definition: c.h:516
Oid relowner
Definition: pg_class.h:37
float4 reltuples
Definition: pg_class.h:44