]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_class.h
pgindent run for 9.0
[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-2010, 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.122 2010/02/26 02:01:21 momjian Exp $
12  *
13  * NOTES
14  *        the genbki.pl 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 #include "catalog/genbki.h"
23
24 /* ----------------
25  *              pg_class definition.  cpp turns this into
26  *              typedef struct FormData_pg_class
27  * ----------------
28  */
29 #define RelationRelationId      1259
30 #define RelationRelation_Rowtype_Id  83
31
32 CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
33 {
34         NameData        relname;                /* class name */
35         Oid                     relnamespace;   /* OID of namespace containing this class */
36         Oid                     reltype;                /* OID of entry in pg_type for table's
37                                                                  * implicit row type */
38         Oid                     reloftype;              /* OID of entry in pg_type for underlying
39                                                                  * composite type */
40         Oid                     relowner;               /* class owner */
41         Oid                     relam;                  /* index access method; 0 if not an index */
42         Oid                     relfilenode;    /* identifier of physical storage file */
43
44         /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
45         Oid                     reltablespace;  /* identifier of table space for relation */
46         int4            relpages;               /* # of blocks (not always up-to-date) */
47         float4          reltuples;              /* # of tuples (not always up-to-date) */
48         Oid                     reltoastrelid;  /* OID of toast table; 0 if none */
49         Oid                     reltoastidxid;  /* if toast table, OID of chunk_id index */
50         bool            relhasindex;    /* T if has (or has had) any indexes */
51         bool            relisshared;    /* T if shared across databases */
52         bool            relistemp;              /* T if temporary relation */
53         char            relkind;                /* see RELKIND_xxx constants below */
54         int2            relnatts;               /* number of user attributes */
55
56         /*
57          * Class pg_attribute must contain exactly "relnatts" user attributes
58          * (with attnums ranging from 1 to relnatts) for this class.  It may also
59          * contain entries with negative attnums for system attributes.
60          */
61         int2            relchecks;              /* # of CHECK constraints for class */
62         bool            relhasoids;             /* T if we generate OIDs for rows of rel */
63         bool            relhaspkey;             /* has (or has had) PRIMARY KEY index */
64         bool            relhasexclusion;        /* has (or has had) exclusion constraint */
65         bool            relhasrules;    /* has (or has had) any rules */
66         bool            relhastriggers; /* has (or has had) any TRIGGERs */
67         bool            relhassubclass; /* has (or has had) derived classes */
68         TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
69
70         /*
71          * VARIABLE LENGTH FIELDS start here.  These fields may be NULL, too.
72          *
73          * NOTE: these fields are not present in a relcache entry's rd_rel field.
74          */
75
76         aclitem         relacl[1];              /* access permissions */
77         text            reloptions[1];  /* access-method-specific options */
78 } FormData_pg_class;
79
80 /* Size of fixed part of pg_class tuples, not counting var-length fields */
81 #define CLASS_TUPLE_SIZE \
82          (offsetof(FormData_pg_class,relfrozenxid) + sizeof(TransactionId))
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 #define Natts_pg_class                                  27
97 #define Anum_pg_class_relname                   1
98 #define Anum_pg_class_relnamespace              2
99 #define Anum_pg_class_reltype                   3
100 #define Anum_pg_class_reloftype                 4
101 #define Anum_pg_class_relowner                  5
102 #define Anum_pg_class_relam                             6
103 #define Anum_pg_class_relfilenode               7
104 #define Anum_pg_class_reltablespace             8
105 #define Anum_pg_class_relpages                  9
106 #define Anum_pg_class_reltuples                 10
107 #define Anum_pg_class_reltoastrelid             11
108 #define Anum_pg_class_reltoastidxid             12
109 #define Anum_pg_class_relhasindex               13
110 #define Anum_pg_class_relisshared               14
111 #define Anum_pg_class_relistemp                 15
112 #define Anum_pg_class_relkind                   16
113 #define Anum_pg_class_relnatts                  17
114 #define Anum_pg_class_relchecks                 18
115 #define Anum_pg_class_relhasoids                19
116 #define Anum_pg_class_relhaspkey                20
117 #define Anum_pg_class_relhasexclusion   21
118 #define Anum_pg_class_relhasrules               22
119 #define Anum_pg_class_relhastriggers    23
120 #define Anum_pg_class_relhassubclass    24
121 #define Anum_pg_class_relfrozenxid              25
122 #define Anum_pg_class_relacl                    26
123 #define Anum_pg_class_reloptions                27
124
125 /* ----------------
126  *              initial contents of pg_class
127  *
128  * NOTE: only "bootstrapped" relations need to be declared here.  Be sure that
129  * the OIDs listed here match those given in their CATALOG macros, and that
130  * the relnatts values are correct.
131  * ----------------
132  */
133
134 /* Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId */
135 DATA(insert OID = 1247 (  pg_type               PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f f r 28 0 t f f f f f 3 _null_ _null_ ));
136 DESCR("");
137 DATA(insert OID = 1249 (  pg_attribute  PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f f r 19 0 f f f f f f 3 _null_ _null_ ));
138 DESCR("");
139 DATA(insert OID = 1255 (  pg_proc               PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f f r 25 0 t f f f f f 3 _null_ _null_ ));
140 DESCR("");
141 DATA(insert OID = 1259 (  pg_class              PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f f r 27 0 t f f f f f 3 _null_ _null_ ));
142 DESCR("");
143
144 #define           RELKIND_INDEX                   'i'           /* secondary index */
145 #define           RELKIND_RELATION                'r'           /* ordinary cataloged heap */
146 #define           RELKIND_SEQUENCE                'S'           /* SEQUENCE relation */
147 #define           RELKIND_UNCATALOGED     'u'           /* temporary heap */
148 #define           RELKIND_TOASTVALUE      't'           /* moved off huge values */
149 #define           RELKIND_VIEW                    'v'           /* view */
150 #define           RELKIND_COMPOSITE_TYPE  'c'           /* composite type */
151
152 #endif   /* PG_CLASS_H */