]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_class.h
Restructure LOCKTAG as per discussions of a couple months ago.
[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-2005, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.88 2005/04/29 22:28:24 tgl Exp $
12  *
13  * NOTES
14  *        the genbki.sh 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 /* ----------------
23  *              postgres.h contains the system type definitions and the
24  *              CATALOG(), BKI_BOOTSTRAP and DATA() sugar words so this file
25  *              can be read by both genbki.sh and the C compiler.
26  * ----------------
27  */
28
29 /* ----------------
30  *              pg_class definition.  cpp turns this into
31  *              typedef struct FormData_pg_class
32  * ----------------
33  */
34
35 /* ----------------
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.
41  * ----------------
42  */
43 #define RelationRelationId  1259
44
45 CATALOG(pg_class,1259) BKI_BOOTSTRAP
46 {
47         NameData        relname;                /* class name */
48         Oid                     relnamespace;   /* OID of namespace containing this class */
49         Oid                     reltype;                /* OID of associated entry in pg_type */
50         int4            relowner;               /* class owner */
51         Oid                     relam;                  /* index access method; 0 if not an index */
52         Oid                     relfilenode;    /* identifier of physical storage file */
53         Oid                     reltablespace;  /* identifier of table space for relation */
54         int4            relpages;               /* # of blocks (not always up-to-date) */
55         float4          reltuples;              /* # of tuples (not always up-to-date) */
56         Oid                     reltoastrelid;  /* OID of toast table; 0 if none */
57         Oid                     reltoastidxid;  /* if toast table, OID of chunk_id index */
58         bool            relhasindex;    /* T if has (or has had) any indexes */
59         bool            relisshared;    /* T if shared across databases */
60         char            relkind;                /* see RELKIND_xxx constants below */
61         int2            relnatts;               /* number of user attributes */
62
63         /*
64          * Class pg_attribute must contain exactly "relnatts" user attributes
65          * (with attnums ranging from 1 to relnatts) for this class.  It may
66          * also contain entries with negative attnums for system attributes.
67          */
68         int2            relchecks;              /* # of CHECK constraints for class */
69         int2            reltriggers;    /* # of TRIGGERs */
70         int2            relukeys;               /* # of Unique keys (not used) */
71         int2            relfkeys;               /* # of FOREIGN KEYs (not used) */
72         int2            relrefs;                /* # of references to this rel (not used) */
73         bool            relhasoids;             /* T if we generate OIDs for rows of rel */
74         bool            relhaspkey;             /* has PRIMARY KEY index */
75         bool            relhasrules;    /* has associated rules */
76         bool            relhassubclass; /* has derived classes */
77
78         /*
79          * relacl may or may not be present, see note above!
80          */
81         aclitem         relacl[1];              /* we declare this just for the catalog */
82 } FormData_pg_class;
83
84 /* Size of fixed part of pg_class tuples, not counting relacl or padding */
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.  This is a kluge.
104  * ----------------
105  */
106 #define Natts_pg_class_fixed                    24
107 #define Natts_pg_class                                  25
108 #define Anum_pg_class_relname                   1
109 #define Anum_pg_class_relnamespace              2
110 #define Anum_pg_class_reltype                   3
111 #define Anum_pg_class_relowner                  4
112 #define Anum_pg_class_relam                             5
113 #define Anum_pg_class_relfilenode               6
114 #define Anum_pg_class_reltablespace             7
115 #define Anum_pg_class_relpages                  8
116 #define Anum_pg_class_reltuples                 9
117 #define Anum_pg_class_reltoastrelid             10
118 #define Anum_pg_class_reltoastidxid             11
119 #define Anum_pg_class_relhasindex               12
120 #define Anum_pg_class_relisshared               13
121 #define Anum_pg_class_relkind                   14
122 #define Anum_pg_class_relnatts                  15
123 #define Anum_pg_class_relchecks                 16
124 #define Anum_pg_class_reltriggers               17
125 #define Anum_pg_class_relukeys                  18
126 #define Anum_pg_class_relfkeys                  19
127 #define Anum_pg_class_relrefs                   20
128 #define Anum_pg_class_relhasoids                21
129 #define Anum_pg_class_relhaspkey                22
130 #define Anum_pg_class_relhasrules               23
131 #define Anum_pg_class_relhassubclass    24
132 #define Anum_pg_class_relacl                    25
133
134 /* ----------------
135  *              initial contents of pg_class
136  *
137  * NOTE: only "bootstrapped" relations need to be declared here.  Be sure that
138  * the OIDs listed here match those given in their CATALOG macros.
139  * ----------------
140  */
141
142 DATA(insert OID = 1247 (  pg_type               PGNSP 71 PGUID 0 1247 0 0 0 0 0 f f r 23 0 0 0 0 0 t f f f _null_ ));
143 DESCR("");
144 DATA(insert OID = 1249 (  pg_attribute  PGNSP 75 PGUID 0 1249 0 0 0 0 0 f f r 17 0 0 0 0 0 f f f f _null_ ));
145 DESCR("");
146 DATA(insert OID = 1255 (  pg_proc               PGNSP 81 PGUID 0 1255 0 0 0 0 0 f f r 18 0 0 0 0 0 t f f f _null_ ));
147 DESCR("");
148 DATA(insert OID = 1259 (  pg_class              PGNSP 83 PGUID 0 1259 0 0 0 0 0 f f r 25 0 0 0 0 0 t f f f _null_ ));
149 DESCR("");
150
151 #define           RELKIND_INDEX                   'i'           /* secondary index */
152 #define           RELKIND_RELATION                'r'           /* ordinary cataloged heap */
153 #define           RELKIND_SPECIAL                 's'           /* special (non-heap) */
154 #define           RELKIND_SEQUENCE                'S'           /* SEQUENCE relation */
155 #define           RELKIND_UNCATALOGED     'u'           /* temporary heap */
156 #define           RELKIND_TOASTVALUE      't'           /* moved off huge values */
157 #define           RELKIND_VIEW                    'v'           /* view */
158 #define           RELKIND_COMPOSITE_TYPE  'c'           /* composite type */
159
160 #endif   /* PG_CLASS_H */