]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_class.h
Inheritance overhaul by Chris Bitmead <chris@bitmead.com>
[postgresql] / src / include / catalog / pg_class.h
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-2000, PostgreSQL, Inc
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $Id: pg_class.h,v 1.35 2000/06/09 01:44:23 momjian Exp $
12  *
13  * NOTES
14  *        ``pg_relation'' is being replaced by ``pg_class''.  currently
15  *        we are only changing the name in the catalogs but someday the
16  *        code will be changed too. -cim 2/26/90
17  *        [it finally happens.  -ay 11/5/94]
18  *
19  *        the genbki.sh script reads this file and generates .bki
20  *        information from the DATA() statements.
21  *
22  *-------------------------------------------------------------------------
23  */
24 #ifndef PG_RELATION_H
25 #define PG_RELATION_H
26
27 /* ----------------
28  *              postgres.h contains the system type definintions and the
29  *              CATALOG(), BOOTSTRAP and DATA() sugar words so this file
30  *              can be read by both genbki.sh and the C compiler.
31  * ----------------
32  */
33
34 /* ----------------
35  *              pg_class definition.  cpp turns this into
36  *              typedef struct FormData_pg_class
37  *
38  *              Note: the #if 0, #endif around the BKI_BEGIN.. END block
39  *                        below keeps cpp from seeing what is meant for the
40  *                        genbki script: pg_relation is now called pg_class, but
41  *                        only in the catalogs -cim 2/26/90
42  * ----------------
43  */
44
45 /* ----------------
46  *              This structure is actually variable-length (the last attribute is
47  *              a POSTGRES array).      Hence, sizeof(FormData_pg_class) does not
48  *              describe the fixed-length or actual size of the structure.
49  *              FormData_pg_class.relacl may not be correctly aligned, either,
50  *              if aclitem and struct varlena don't align together.  Hence,
51  *              you MUST use heap_getattr() to get the relacl field.
52  * ----------------
53  */
54 CATALOG(pg_class) BOOTSTRAP
55 {
56         NameData        relname;
57         Oid                     reltype;
58         int4            relowner;
59         Oid                     relam;
60         int4            relpages;
61         int4            reltuples;
62         Oid                     rellongrelid;
63         bool            relhasindex;
64         bool            relisshared;
65         char            relkind;
66         int2            relnatts;
67
68         /*
69          * relnatts is the number of user attributes this class has.  There
70          * must be exactly this many instances in Class pg_attribute for this
71          * class which have attnum > 0 (= user attribute).
72          */
73         int2            relchecks;              /* # of CHECK constraints, not stored in
74                                                                  * db? */
75         int2            reltriggers;    /* # of TRIGGERs */
76         int2            relukeys;               /* # of Unique keys */
77         int2            relfkeys;               /* # of FOREIGN KEYs */
78         int2            relrefs;                /* # of references to this relation */
79         bool            relhaspkey;             /* has PRIMARY KEY */
80         bool            relhasrules;
81         bool            relhassubclass;
82         aclitem         relacl[1];              /* this is here for the catalog */
83 } FormData_pg_class;
84
85 #define CLASS_TUPLE_SIZE \
86          (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool))
87
88 /* ----------------
89  *              Form_pg_class corresponds to a pointer to a tuple with
90  *              the format of pg_class relation.
91  * ----------------
92  */
93 typedef FormData_pg_class *Form_pg_class;
94
95 /* ----------------
96  *              compiler constants for pg_class
97  * ----------------
98  */
99
100 /* ----------------
101  *              Natts_pg_class_fixed is used to tell routines that insert new
102  *              pg_class tuples (as opposed to replacing old ones) that there's no
103  *              relacl field.
104  * ----------------
105  */
106 #define Natts_pg_class_fixed                    19
107 #define Natts_pg_class                                  20
108 #define Anum_pg_class_relname                   1
109 #define Anum_pg_class_reltype                   2
110 #define Anum_pg_class_relowner                  3
111 #define Anum_pg_class_relam                             4
112 #define Anum_pg_class_relpages                  5
113 #define Anum_pg_class_reltuples                 6
114 #define Anum_pg_class_rellongrelid              7
115 #define Anum_pg_class_relhasindex               8
116 #define Anum_pg_class_relisshared               9
117 #define Anum_pg_class_relkind                   10
118 #define Anum_pg_class_relnatts                  11
119 #define Anum_pg_class_relchecks                 12
120 #define Anum_pg_class_reltriggers               13
121 #define Anum_pg_class_relukeys                  14
122 #define Anum_pg_class_relfkeys                  15
123 #define Anum_pg_class_relrefs                   16
124 #define Anum_pg_class_relhaspkey                17
125 #define Anum_pg_class_relhasrules               18
126 #define Anum_pg_class_relhassubclass            19
127 #define Anum_pg_class_relacl                    20
128
129 /* ----------------
130  *              initial contents of pg_class
131  * ----------------
132  */
133
134 DATA(insert OID = 1247 (  pg_type 71              PGUID 0 0 0 0 f f r 16 0 0 0 0 0 f f f _null_ ));
135 DESCR("");
136 DATA(insert OID = 1249 (  pg_attribute 75         PGUID 0 0 0 0 f f r 15 0 0 0 0 0 f f f _null_ ));
137 DESCR("");
138 DATA(insert OID = 1255 (  pg_proc 81              PGUID 0 0 0 0 f f r 17 0 0 0 0 0 f f f _null_ ));
139 DESCR("");
140 DATA(insert OID = 1259 (  pg_class 83             PGUID 0 0 0 0 f f r 20 0 0 0 0 0 f f f _null_ ));
141 DESCR("");
142 DATA(insert OID = 1260 (  pg_shadow 86            PGUID 0 0 0 0 f t r 8  0 0 0 0 0 f f f _null_ ));
143 DESCR("");
144 DATA(insert OID = 1261 (  pg_group 87             PGUID 0 0 0 0 f t r 3  0 0 0 0 0 f f f _null_ ));
145 DESCR("");
146 DATA(insert OID = 1262 (  pg_database 88          PGUID 0 0 0 0 f t r 4  0 0 0 0 0 f f f _null_ ));
147 DESCR("");
148 DATA(insert OID = 1264 (  pg_variable 90          PGUID 0 0 0 0 f t s 1  0 0 0 0 0 f f f _null_ ));
149 DESCR("");
150 DATA(insert OID = 1269 (  pg_log  99              PGUID 0 0 0 0 f t s 1  0 0 0 0 0 f f f _null_ ));
151 DESCR("");
152 DATA(insert OID = 376  (  pg_xactlock  0          PGUID 0 0 0 0 f t s 1  0 0 0 0 0 f f f _null_ ));
153 DESCR("");
154 DATA(insert OID = 1215 (  pg_attrdef 109          PGUID 0 0 0 0 t t r 4  0 0 0 0 0 f f f _null_ ));
155 DESCR("");
156 DATA(insert OID = 1216 (  pg_relcheck 110         PGUID 0 0 0 0 t t r 4  0 0 0 0 0 f f f _null_ ));
157 DESCR("");
158 DATA(insert OID = 1219 (  pg_trigger 111          PGUID 0 0 0 0 t t r 13  0 0 0 0 0 f f f _null_ ));
159 DESCR("");
160
161 #define RelOid_pg_type                  1247
162 #define RelOid_pg_attribute             1249
163 #define RelOid_pg_proc                  1255
164 #define RelOid_pg_class                 1259
165 #define RelOid_pg_shadow                1260
166 #define RelOid_pg_group                 1261
167 #define RelOid_pg_database              1262
168 #define RelOid_pg_variable              1264
169 #define RelOid_pg_log                   1269
170 #define RelOid_pg_attrdef               1215
171 #define RelOid_pg_relcheck              1216
172 #define RelOid_pg_trigger               1219
173
174 /* Xact lock pseudo-table */
175 #define XactLockTableId                 376
176
177 #define           RELKIND_INDEX                   'i'           /* secondary index */
178 #define           RELKIND_LOBJECT                 'l'           /* large objects */
179 #define           RELKIND_RELATION                'r'           /* cataloged heap */
180 #define           RELKIND_SPECIAL                 's'           /* special (non-heap) */
181 #define           RELKIND_SEQUENCE                'S'           /* SEQUENCE relation */
182 #define           RELKIND_UNCATALOGED     'u'           /* temporary heap */
183 #define           RELKIND_LONGVALUE               'v'           /* moved off huge values */
184
185 #endif   /* PG_RELATION_H */