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