]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_class.h
Privileges on functions and procedural languages
[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-2001, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $Id: pg_class.h,v 1.58 2002/02/18 23:11:34 petere 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 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.
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 CATALOG(pg_class) BOOTSTRAP
44 {
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 */
58
59         /*
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.
63          */
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 */
73
74         /*
75          * relacl may or may not be present, see note above!
76          */
77         aclitem         relacl[1];              /* we declare this just for the catalog */
78 } FormData_pg_class;
79
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))
83
84 /* ----------------
85  *              Form_pg_class corresponds to a pointer to a tuple with
86  *              the format of pg_class relation.
87  * ----------------
88  */
89 typedef FormData_pg_class *Form_pg_class;
90
91 /* ----------------
92  *              compiler constants for pg_class
93  * ----------------
94  */
95
96 /* ----------------
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.
100  * ----------------
101  */
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
127
128 /* ----------------
129  *              initial contents of pg_class
130  *
131  * NOTE: only "bootstrapped" relations need to be declared here.
132  * ----------------
133  */
134
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_ ));
136 DESCR("");
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_ ));
138 DESCR("");
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_ ));
140 DESCR("");
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_ ));
142 DESCR("");
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_ ));
144 DESCR("");
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_ ));
146 DESCR("");
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_ ));
148 DESCR("");
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_ ));
150 DESCR("");
151
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
159
160 /* Xact lock pseudo-table */
161 #define XactLockTableId                 376
162
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 */
170
171 #endif   /* PG_CLASS_H */