Header And Logo

PostgreSQL
| The world's most advanced open source database.

pg_class.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * pg_class.h
00004  *    definition of the system "relation" relation (pg_class)
00005  *    along with the relation's initial contents.
00006  *
00007  *
00008  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00009  * Portions Copyright (c) 1994, Regents of the University of California
00010  *
00011  * src/include/catalog/pg_class.h
00012  *
00013  * NOTES
00014  *    the genbki.pl script reads this file and generates .bki
00015  *    information from the DATA() statements.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #ifndef PG_CLASS_H
00020 #define PG_CLASS_H
00021 
00022 #include "catalog/genbki.h"
00023 
00024 /* ----------------
00025  *      pg_class definition.  cpp turns this into
00026  *      typedef struct FormData_pg_class
00027  * ----------------
00028  */
00029 #define RelationRelationId  1259
00030 #define RelationRelation_Rowtype_Id  83
00031 
00032 CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
00033 {
00034     NameData    relname;        /* class name */
00035     Oid         relnamespace;   /* OID of namespace containing this class */
00036     Oid         reltype;        /* OID of entry in pg_type for table's
00037                                  * implicit row type */
00038     Oid         reloftype;      /* OID of entry in pg_type for underlying
00039                                  * composite type */
00040     Oid         relowner;       /* class owner */
00041     Oid         relam;          /* index access method; 0 if not an index */
00042     Oid         relfilenode;    /* identifier of physical storage file */
00043 
00044     /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
00045     Oid         reltablespace;  /* identifier of table space for relation */
00046     int32       relpages;       /* # of blocks (not always up-to-date) */
00047     float4      reltuples;      /* # of tuples (not always up-to-date) */
00048     int32       relallvisible;  /* # of all-visible blocks (not always
00049                                  * up-to-date) */
00050     Oid         reltoastrelid;  /* OID of toast table; 0 if none */
00051     Oid         reltoastidxid;  /* if toast table, OID of chunk_id index */
00052     bool        relhasindex;    /* T if has (or has had) any indexes */
00053     bool        relisshared;    /* T if shared across databases */
00054     char        relpersistence; /* see RELPERSISTENCE_xxx constants below */
00055     char        relkind;        /* see RELKIND_xxx constants below */
00056     int16       relnatts;       /* number of user attributes */
00057 
00058     /*
00059      * Class pg_attribute must contain exactly "relnatts" user attributes
00060      * (with attnums ranging from 1 to relnatts) for this class.  It may also
00061      * contain entries with negative attnums for system attributes.
00062      */
00063     int16       relchecks;      /* # of CHECK constraints for class */
00064     bool        relhasoids;     /* T if we generate OIDs for rows of rel */
00065     bool        relhaspkey;     /* has (or has had) PRIMARY KEY index */
00066     bool        relhasrules;    /* has (or has had) any rules */
00067     bool        relhastriggers; /* has (or has had) any TRIGGERs */
00068     bool        relhassubclass; /* has (or has had) derived classes */
00069     TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
00070     TransactionId relminmxid;   /* all multixacts in this rel are >= this.
00071                                  * this is really a MultiXactId */
00072 
00073 #ifdef CATALOG_VARLEN           /* variable-length fields start here */
00074     /* NOTE: These fields are not present in a relcache entry's rd_rel field. */
00075     aclitem     relacl[1];      /* access permissions */
00076     text        reloptions[1];  /* access-method-specific options */
00077 #endif
00078 } FormData_pg_class;
00079 
00080 /* Size of fixed part of pg_class tuples, not counting var-length fields */
00081 #define CLASS_TUPLE_SIZE \
00082      (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId))
00083 
00084 /* ----------------
00085  *      Form_pg_class corresponds to a pointer to a tuple with
00086  *      the format of pg_class relation.
00087  * ----------------
00088  */
00089 typedef FormData_pg_class *Form_pg_class;
00090 
00091 /* ----------------
00092  *      compiler constants for pg_class
00093  * ----------------
00094  */
00095 
00096 #define Natts_pg_class                  28
00097 #define Anum_pg_class_relname           1
00098 #define Anum_pg_class_relnamespace      2
00099 #define Anum_pg_class_reltype           3
00100 #define Anum_pg_class_reloftype         4
00101 #define Anum_pg_class_relowner          5
00102 #define Anum_pg_class_relam             6
00103 #define Anum_pg_class_relfilenode       7
00104 #define Anum_pg_class_reltablespace     8
00105 #define Anum_pg_class_relpages          9
00106 #define Anum_pg_class_reltuples         10
00107 #define Anum_pg_class_relallvisible     11
00108 #define Anum_pg_class_reltoastrelid     12
00109 #define Anum_pg_class_reltoastidxid     13
00110 #define Anum_pg_class_relhasindex       14
00111 #define Anum_pg_class_relisshared       15
00112 #define Anum_pg_class_relpersistence    16
00113 #define Anum_pg_class_relkind           17
00114 #define Anum_pg_class_relnatts          18
00115 #define Anum_pg_class_relchecks         19
00116 #define Anum_pg_class_relhasoids        20
00117 #define Anum_pg_class_relhaspkey        21
00118 #define Anum_pg_class_relhasrules       22
00119 #define Anum_pg_class_relhastriggers    23
00120 #define Anum_pg_class_relhassubclass    24
00121 #define Anum_pg_class_relfrozenxid      25
00122 #define Anum_pg_class_relminmxid        26
00123 #define Anum_pg_class_relacl            27
00124 #define Anum_pg_class_reloptions        28
00125 
00126 /* ----------------
00127  *      initial contents of pg_class
00128  *
00129  * NOTE: only "bootstrapped" relations need to be declared here.  Be sure that
00130  * the OIDs listed here match those given in their CATALOG macros, and that
00131  * the relnatts values are correct.
00132  * ----------------
00133  */
00134 
00135 /*
00136  * Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId;
00137  * similarly, "1" in relminmxid stands for FirstMultiXactId
00138  */
00139 DATA(insert OID = 1247 (  pg_type       PGNSP 71 0 PGUID 0 0 0 0 0 0 0 0 f f p r 30 0 t f f f f 3 1 _null_ _null_ ));
00140 DESCR("");
00141 DATA(insert OID = 1249 (  pg_attribute  PGNSP 75 0 PGUID 0 0 0 0 0 0 0 0 f f p r 21 0 f f f f f 3 1 _null_ _null_ ));
00142 DESCR("");
00143 DATA(insert OID = 1255 (  pg_proc       PGNSP 81 0 PGUID 0 0 0 0 0 0 0 0 f f p r 27 0 t f f f f 3 1 _null_ _null_ ));
00144 DESCR("");
00145 DATA(insert OID = 1259 (  pg_class      PGNSP 83 0 PGUID 0 0 0 0 0 0 0 0 f f p r 28 0 t f f f f 3 1 _null_ _null_ ));
00146 DESCR("");
00147 
00148 
00149 #define       RELKIND_RELATION        'r'       /* ordinary table */
00150 #define       RELKIND_INDEX           'i'       /* secondary index */
00151 #define       RELKIND_SEQUENCE        'S'       /* sequence object */
00152 #define       RELKIND_TOASTVALUE      't'       /* for out-of-line values */
00153 #define       RELKIND_VIEW            'v'       /* view */
00154 #define       RELKIND_COMPOSITE_TYPE  'c'       /* composite type */
00155 #define       RELKIND_FOREIGN_TABLE   'f'       /* foreign table */
00156 #define       RELKIND_MATVIEW         'm'       /* materialized view */
00157 
00158 #define       RELPERSISTENCE_PERMANENT  'p'     /* regular table */
00159 #define       RELPERSISTENCE_UNLOGGED   'u'     /* unlogged permanent table */
00160 #define       RELPERSISTENCE_TEMP       't'     /* temporary table */
00161 
00162 #endif   /* PG_CLASS_H */