1 /*-------------------------------------------------------------------------
4 * definition of the system "relation" relation (pg_class)
5 * along with the relation's initial contents.
8 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Id: pg_class.h,v 1.58 2002/02/18 23:11:34 petere Exp $
14 * the genbki.sh script reads this file and generates .bki
15 * information from the DATA() statements.
17 *-------------------------------------------------------------------------
23 * postgres.h contains the system type definintions and the
24 * CATALOG(), BOOTSTRAP and DATA() sugar words so this file
25 * can be read by both genbki.sh and the C compiler.
30 * pg_class definition. cpp turns this into
31 * typedef struct FormData_pg_class
36 * This structure is actually variable-length (the last attribute is
37 * a POSTGRES array). Hence, sizeof(FormData_pg_class) does not
38 * necessarily match the actual length of the structure. Furthermore
39 * relacl may be a NULL field. Hence, you MUST use heap_getattr()
40 * to get the relacl field ... and don't forget to check isNull.
43 CATALOG(pg_class) BOOTSTRAP
45 NameData relname; /* class name */
46 Oid reltype; /* OID of associated entry in pg_type */
47 int4 relowner; /* class owner */
48 Oid relam; /* index access method; 0 if not an index */
49 Oid relfilenode; /* identifier of physical storage file */
50 int4 relpages; /* # of blocks (not always up-to-date) */
51 float4 reltuples; /* # of tuples (not always up-to-date) */
52 Oid reltoastrelid; /* OID of toast table; 0 if none */
53 Oid reltoastidxid; /* if toast table, OID of chunk_id index */
54 bool relhasindex; /* T if has (or has had) any indexes */
55 bool relisshared; /* T if shared across databases */
56 char relkind; /* see RELKIND_xxx constants below */
57 int2 relnatts; /* number of user attributes */
60 * Class pg_attribute must contain exactly "relnatts" user attributes
61 * (with attnums ranging from 1 to relnatts) for this class. It may
62 * also contain entries with negative attnums for system attributes.
64 int2 relchecks; /* # of CHECK constraints for class */
65 int2 reltriggers; /* # of TRIGGERs */
66 int2 relukeys; /* # of Unique keys (not used) */
67 int2 relfkeys; /* # of FOREIGN KEYs (not used) */
68 int2 relrefs; /* # of references to this rel (not used) */
69 bool relhasoids; /* T if we generate OIDs for rows of rel */
70 bool relhaspkey; /* has PRIMARY KEY index */
71 bool relhasrules; /* has associated rules */
72 bool relhassubclass; /* has derived classes */
75 * relacl may or may not be present, see note above!
77 aclitem relacl[1]; /* we declare this just for the catalog */
80 /* Size of fixed part of pg_class tuples, not counting relacl or padding */
81 #define CLASS_TUPLE_SIZE \
82 (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool))
85 * Form_pg_class corresponds to a pointer to a tuple with
86 * the format of pg_class relation.
89 typedef FormData_pg_class *Form_pg_class;
92 * compiler constants for pg_class
97 * Natts_pg_class_fixed is used to tell routines that insert new
98 * pg_class tuples (as opposed to replacing old ones) that there's no
99 * relacl field. This is a kluge.
102 #define Natts_pg_class_fixed 22
103 #define Natts_pg_class 23
104 #define Anum_pg_class_relname 1
105 #define Anum_pg_class_reltype 2
106 #define Anum_pg_class_relowner 3
107 #define Anum_pg_class_relam 4
108 #define Anum_pg_class_relfilenode 5
109 #define Anum_pg_class_relpages 6
110 #define Anum_pg_class_reltuples 7
111 #define Anum_pg_class_reltoastrelid 8
112 #define Anum_pg_class_reltoastidxid 9
113 #define Anum_pg_class_relhasindex 10
114 #define Anum_pg_class_relisshared 11
115 #define Anum_pg_class_relkind 12
116 #define Anum_pg_class_relnatts 13
117 #define Anum_pg_class_relchecks 14
118 #define Anum_pg_class_reltriggers 15
119 #define Anum_pg_class_relukeys 16
120 #define Anum_pg_class_relfkeys 17
121 #define Anum_pg_class_relrefs 18
122 #define Anum_pg_class_relhasoids 19
123 #define Anum_pg_class_relhaspkey 20
124 #define Anum_pg_class_relhasrules 21
125 #define Anum_pg_class_relhassubclass 22
126 #define Anum_pg_class_relacl 23
129 * initial contents of pg_class
131 * NOTE: only "bootstrapped" relations need to be declared here.
135 DATA(insert OID = 1247 ( pg_type 71 PGUID 0 1247 0 0 0 0 f f r 17 0 0 0 0 0 t f f f _null_ ));
137 DATA(insert OID = 1249 ( pg_attribute 75 PGUID 0 1249 0 0 0 0 f f r 15 0 0 0 0 0 f f f f _null_ ));
139 DATA(insert OID = 1255 ( pg_proc 81 PGUID 0 1255 0 0 0 0 f f r 18 0 0 0 0 0 t f f f _null_ ));
141 DATA(insert OID = 1259 ( pg_class 83 PGUID 0 1259 0 0 0 0 f f r 23 0 0 0 0 0 t f f f _null_ ));
143 DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 1260 0 0 0 0 f t r 8 0 0 0 0 0 f f f f _null_ ));
145 DATA(insert OID = 1261 ( pg_group 87 PGUID 0 1261 0 0 0 0 f t r 3 0 0 0 0 0 f f f f _null_ ));
147 DATA(insert OID = 1262 ( pg_database 88 PGUID 0 1262 0 0 0 0 f t r 9 0 0 0 0 0 t f f f _null_ ));
149 DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 0 0 0 f t s 1 0 0 0 0 0 f f f f _null_ ));
152 #define RelOid_pg_type 1247
153 #define RelOid_pg_attribute 1249
154 #define RelOid_pg_proc 1255
155 #define RelOid_pg_class 1259
156 #define RelOid_pg_shadow 1260
157 #define RelOid_pg_group 1261
158 #define RelOid_pg_database 1262
160 /* Xact lock pseudo-table */
161 #define XactLockTableId 376
163 #define RELKIND_INDEX 'i' /* secondary index */
164 #define RELKIND_RELATION 'r' /* ordinary cataloged heap */
165 #define RELKIND_SPECIAL 's' /* special (non-heap) */
166 #define RELKIND_SEQUENCE 'S' /* SEQUENCE relation */
167 #define RELKIND_UNCATALOGED 'u' /* temporary heap */
168 #define RELKIND_TOASTVALUE 't' /* moved off huge values */
169 #define RELKIND_VIEW 'v' /* view */
171 #endif /* PG_CLASS_H */