pg_class.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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-2016, PostgreSQL Global Development Group
  9. * Portions Copyright (c) 1994, Regents of the University of California
  10. *
  11. * src/include/catalog/pg_class.h
  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. #include "catalog/genbki.h"
  22. /* ----------------
  23. * pg_class definition. cpp turns this into
  24. * typedef struct FormData_pg_class
  25. * ----------------
  26. */
  27. #define RelationRelationId 1259
  28. #define RelationRelation_Rowtype_Id 83
  29. CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
  30. {
  31. NameData relname; /* class name */
  32. Oid relnamespace; /* OID of namespace containing this class */
  33. Oid reltype; /* OID of entry in pg_type for table's
  34. * implicit row type */
  35. Oid reloftype; /* OID of entry in pg_type for underlying
  36. * composite type */
  37. Oid relowner; /* class owner */
  38. Oid relam; /* index access method; 0 if not an index */
  39. Oid relfilenode; /* identifier of physical storage file */
  40. /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
  41. Oid reltablespace; /* identifier of table space for relation */
  42. int32 relpages; /* # of blocks (not always up-to-date) */
  43. float4 reltuples; /* # of tuples (not always up-to-date) */
  44. int32 relallvisible; /* # of all-visible blocks (not always
  45. * up-to-date) */
  46. Oid reltoastrelid; /* OID of toast table; 0 if none */
  47. bool relhasindex; /* T if has (or has had) any indexes */
  48. bool relisshared; /* T if shared across databases */
  49. char relpersistence; /* see RELPERSISTENCE_xxx constants below */
  50. char relkind; /* see RELKIND_xxx constants below */
  51. int16 relnatts; /* number of user attributes */
  52. /*
  53. * Class pg_attribute must contain exactly "relnatts" user attributes
  54. * (with attnums ranging from 1 to relnatts) for this class. It may also
  55. * contain entries with negative attnums for system attributes.
  56. */
  57. int16 relchecks; /* # of CHECK constraints for class */
  58. bool relhasoids; /* T if we generate OIDs for rows of rel */
  59. bool relhaspkey; /* has (or has had) PRIMARY KEY index */
  60. bool relhasrules; /* has (or has had) any rules */
  61. bool relhastriggers; /* has (or has had) any TRIGGERs */
  62. bool relhassubclass; /* has (or has had) derived classes */
  63. bool relrowsecurity; /* row security is enabled or not */
  64. bool relforcerowsecurity; /* row security forced for owners or
  65. * not */
  66. bool relispopulated; /* matview currently holds query results */
  67. char relreplident; /* see REPLICA_IDENTITY_xxx constants */
  68. TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
  69. TransactionId relminmxid; /* all multixacts in this rel are >= this.
  70. * this is really a MultiXactId */
  71. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  72. /* NOTE: These fields are not present in a relcache entry's rd_rel field. */
  73. aclitem relacl[1]; /* access permissions */
  74. text reloptions[1]; /* access-method-specific options */
  75. #endif
  76. } FormData_pg_class;
  77. /* Size of fixed part of pg_class tuples, not counting var-length fields */
  78. #define CLASS_TUPLE_SIZE \
  79. (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId))
  80. /* ----------------
  81. * Form_pg_class corresponds to a pointer to a tuple with
  82. * the format of pg_class relation.
  83. * ----------------
  84. */
  85. typedef FormData_pg_class *Form_pg_class;
  86. /* ----------------
  87. * compiler constants for pg_class
  88. * ----------------
  89. */
  90. #define Natts_pg_class 31
  91. #define Anum_pg_class_relname 1
  92. #define Anum_pg_class_relnamespace 2
  93. #define Anum_pg_class_reltype 3
  94. #define Anum_pg_class_reloftype 4
  95. #define Anum_pg_class_relowner 5
  96. #define Anum_pg_class_relam 6
  97. #define Anum_pg_class_relfilenode 7
  98. #define Anum_pg_class_reltablespace 8
  99. #define Anum_pg_class_relpages 9
  100. #define Anum_pg_class_reltuples 10
  101. #define Anum_pg_class_relallvisible 11
  102. #define Anum_pg_class_reltoastrelid 12
  103. #define Anum_pg_class_relhasindex 13
  104. #define Anum_pg_class_relisshared 14
  105. #define Anum_pg_class_relpersistence 15
  106. #define Anum_pg_class_relkind 16
  107. #define Anum_pg_class_relnatts 17
  108. #define Anum_pg_class_relchecks 18
  109. #define Anum_pg_class_relhasoids 19
  110. #define Anum_pg_class_relhaspkey 20
  111. #define Anum_pg_class_relhasrules 21
  112. #define Anum_pg_class_relhastriggers 22
  113. #define Anum_pg_class_relhassubclass 23
  114. #define Anum_pg_class_relrowsecurity 24
  115. #define Anum_pg_class_relforcerowsecurity 25
  116. #define Anum_pg_class_relispopulated 26
  117. #define Anum_pg_class_relreplident 27
  118. #define Anum_pg_class_relfrozenxid 28
  119. #define Anum_pg_class_relminmxid 29
  120. #define Anum_pg_class_relacl 30
  121. #define Anum_pg_class_reloptions 31
  122. /* ----------------
  123. * initial contents of pg_class
  124. *
  125. * NOTE: only "bootstrapped" relations need to be declared here. Be sure that
  126. * the OIDs listed here match those given in their CATALOG macros, and that
  127. * the relnatts values are correct.
  128. * ----------------
  129. */
  130. /*
  131. * Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId;
  132. * similarly, "1" in relminmxid stands for FirstMultiXactId
  133. */
  134. DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f f t n 3 1 _null_ _null_ ));
  135. DESCR("");
  136. DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f f f f t n 3 1 _null_ _null_ ));
  137. DESCR("");
  138. DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f f f f t n 3 1 _null_ _null_ ));
  139. DESCR("");
  140. DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 31 0 t f f f f f f t n 3 1 _null_ _null_ ));
  141. DESCR("");
  142. #define RELKIND_RELATION 'r' /* ordinary table */
  143. #define RELKIND_INDEX 'i' /* secondary index */
  144. #define RELKIND_SEQUENCE 'S' /* sequence object */
  145. #define RELKIND_TOASTVALUE 't' /* for out-of-line values */
  146. #define RELKIND_VIEW 'v' /* view */
  147. #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
  148. #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
  149. #define RELKIND_MATVIEW 'm' /* materialized view */
  150. #define RELPERSISTENCE_PERMANENT 'p' /* regular table */
  151. #define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */
  152. #define RELPERSISTENCE_TEMP 't' /* temporary table */
  153. /* default selection for replica identity (primary key or nothing) */
  154. #define REPLICA_IDENTITY_DEFAULT 'd'
  155. /* no replica identity is logged for this relation */
  156. #define REPLICA_IDENTITY_NOTHING 'n'
  157. /* all columns are logged as replica identity */
  158. #define REPLICA_IDENTITY_FULL 'f'
  159. /*
  160. * an explicitly chosen candidate key's columns are used as identity;
  161. * will still be set if the index has been dropped, in that case it
  162. * has the same meaning as 'd'
  163. */
  164. #define REPLICA_IDENTITY_INDEX 'i'
  165. #endif /* PG_CLASS_H */