pg_class.h 5.68 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * pg_class.h
4 5
 *	  definition of the system "relation" relation (pg_class)
 *	  along with the relation's initial contents.
6 7
 *
 *
8
 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
Bruce Momjian's avatar
Add:  
Bruce Momjian committed
9
 * Portions Copyright (c) 1994, Regents of the University of California
10
 *
11
 * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.95 2006/07/10 16:20:51 alvherre Exp $
12 13
 *
 * NOTES
14 15
 *	  the genbki.sh script reads this file and generates .bki
 *	  information from the DATA() statements.
16 17 18
 *
 *-------------------------------------------------------------------------
 */
19 20
#ifndef PG_CLASS_H
#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 31
 *		pg_class definition.  cpp turns this into
 *		typedef struct FormData_pg_class
32 33
 * ----------------
 */
34
#define RelationRelationId	1259
35 36

CATALOG(pg_class,1259) BKI_BOOTSTRAP
37
{
38
	NameData	relname;		/* class name */
39
	Oid			relnamespace;	/* OID of namespace containing this class */
40
	Oid			reltype;		/* OID of associated entry in pg_type */
41
	Oid			relowner;		/* class owner */
42 43
	Oid			relam;			/* index access method; 0 if not an index */
	Oid			relfilenode;	/* identifier of physical storage file */
44
	Oid			reltablespace;	/* identifier of table space for relation */
45 46 47 48 49 50 51 52
	int4		relpages;		/* # of blocks (not always up-to-date) */
	float4		reltuples;		/* # of tuples (not always up-to-date) */
	Oid			reltoastrelid;	/* OID of toast table; 0 if none */
	Oid			reltoastidxid;	/* if toast table, OID of chunk_id index */
	bool		relhasindex;	/* T if has (or has had) any indexes */
	bool		relisshared;	/* T if shared across databases */
	char		relkind;		/* see RELKIND_xxx constants below */
	int2		relnatts;		/* number of user attributes */
53

54
	/*
55
	 * Class pg_attribute must contain exactly "relnatts" user attributes
56 57
	 * (with attnums ranging from 1 to relnatts) for this class.  It may also
	 * contain entries with negative attnums for system attributes.
58
	 */
59
	int2		relchecks;		/* # of CHECK constraints for class */
60
	int2		reltriggers;	/* # of TRIGGERs */
Bruce Momjian's avatar
Bruce Momjian committed
61 62 63
	int2		relukeys;		/* # of Unique keys (not used) */
	int2		relfkeys;		/* # of FOREIGN KEYs (not used) */
	int2		relrefs;		/* # of references to this rel (not used) */
64 65
	bool		relhasoids;		/* T if we generate OIDs for rows of rel */
	bool		relhaspkey;		/* has PRIMARY KEY index */
66
	bool		relhasrules;	/* has associated rules */
67
	bool		relhassubclass; /* has derived classes */
68 69
	TransactionId relminxid;	/* minimum Xid present in table */
	TransactionId relvacuumxid;	/* Xid used as last vacuum OldestXmin */
70

71 72 73 74 75 76 77 78
	/*
	 * VARIABLE LENGTH FIELDS start here.  These fields may be NULL, too.
	 *
	 * NOTE: these fields are not present in a relcache entry's rd_rel field.
	 */

	aclitem		relacl[1];		/* access permissions */
	text		reloptions[1];	/* access-method-specific options */
79 80
} FormData_pg_class;

81
/* Size of fixed part of pg_class tuples, not counting var-length fields */
82
#define CLASS_TUPLE_SIZE \
83
	 (offsetof(FormData_pg_class,relvacuumxid) + sizeof(TransactionId))
84 85

/* ----------------
86 87
 *		Form_pg_class corresponds to a pointer to a tuple with
 *		the format of pg_class relation.
88 89
 * ----------------
 */
90
typedef FormData_pg_class *Form_pg_class;
91 92

/* ----------------
93
 *		compiler constants for pg_class
94 95 96
 * ----------------
 */

97
#define Natts_pg_class					28
98
#define Anum_pg_class_relname			1
99 100 101 102 103
#define Anum_pg_class_relnamespace		2
#define Anum_pg_class_reltype			3
#define Anum_pg_class_relowner			4
#define Anum_pg_class_relam				5
#define Anum_pg_class_relfilenode		6
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#define Anum_pg_class_reltablespace		7
#define Anum_pg_class_relpages			8
#define Anum_pg_class_reltuples			9
#define Anum_pg_class_reltoastrelid		10
#define Anum_pg_class_reltoastidxid		11
#define Anum_pg_class_relhasindex		12
#define Anum_pg_class_relisshared		13
#define Anum_pg_class_relkind			14
#define Anum_pg_class_relnatts			15
#define Anum_pg_class_relchecks			16
#define Anum_pg_class_reltriggers		17
#define Anum_pg_class_relukeys			18
#define Anum_pg_class_relfkeys			19
#define Anum_pg_class_relrefs			20
#define Anum_pg_class_relhasoids		21
#define Anum_pg_class_relhaspkey		22
#define Anum_pg_class_relhasrules		23
#define Anum_pg_class_relhassubclass	24
122 123 124 125
#define Anum_pg_class_relminxid			25
#define Anum_pg_class_relvacuumxid		26
#define Anum_pg_class_relacl			27
#define Anum_pg_class_reloptions		28
126 127

/* ----------------
128
 *		initial contents of pg_class
129
 *
130 131
 * NOTE: only "bootstrapped" relations need to be declared here.  Be sure that
 * the OIDs listed here match those given in their CATALOG macros.
132 133 134
 * ----------------
 */

135 136
/* Note: the "3" here stands for FirstNormalTransactionId */
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 3 3 _null_ _null_ ));
137
DESCR("");
138
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 3 3 _null_ _null_ ));
139
DESCR("");
140
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 3 3 _null_ _null_ ));
141
DESCR("");
142
DATA(insert OID = 1259 (  pg_class		PGNSP 83 PGUID 0 1259 0 0 0 0 0 f f r 28 0 0 0 0 0 t f f f 3 3 _null_ _null_ ));
143
DESCR("");
Vadim B. Mikheev's avatar
Vadim B. Mikheev committed
144

145
#define		  RELKIND_INDEX			  'i'		/* secondary index */
146
#define		  RELKIND_RELATION		  'r'		/* ordinary cataloged heap */
147 148
#define		  RELKIND_SEQUENCE		  'S'		/* SEQUENCE relation */
#define		  RELKIND_UNCATALOGED	  'u'		/* temporary heap */
Jan Wieck's avatar
TOAST  
Jan Wieck committed
149
#define		  RELKIND_TOASTVALUE	  't'		/* moved off huge values */
Bruce Momjian's avatar
Bruce Momjian committed
150
#define		  RELKIND_VIEW			  'v'		/* view */
Bruce Momjian's avatar
Bruce Momjian committed
151
#define		  RELKIND_COMPOSITE_TYPE  'c'		/* composite type */
152

153
#endif   /* PG_CLASS_H */