pg_attribute.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_attribute.h
  4. * definition of the system "attribute" relation (pg_attribute)
  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_attribute.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_ATTRIBUTE_H
  20. #define PG_ATTRIBUTE_H
  21. #include "catalog/genbki.h"
  22. /* ----------------
  23. * pg_attribute definition. cpp turns this into
  24. * typedef struct FormData_pg_attribute
  25. *
  26. * If you change the following, make sure you change the structs for
  27. * system attributes in catalog/heap.c also.
  28. * You may need to change catalog/genbki.pl as well.
  29. * ----------------
  30. */
  31. #define AttributeRelationId 1249
  32. #define AttributeRelation_Rowtype_Id 75
  33. CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BKI_SCHEMA_MACRO
  34. {
  35. Oid attrelid; /* OID of relation containing this attribute */
  36. NameData attname; /* name of attribute */
  37. /*
  38. * atttypid is the OID of the instance in Catalog Class pg_type that
  39. * defines the data type of this attribute (e.g. int4). Information in
  40. * that instance is redundant with the attlen, attbyval, and attalign
  41. * attributes of this instance, so they had better match or Postgres will
  42. * fail.
  43. */
  44. Oid atttypid;
  45. /*
  46. * attstattarget is the target number of statistics datapoints to collect
  47. * during VACUUM ANALYZE of this column. A zero here indicates that we do
  48. * not wish to collect any stats about this column. A "-1" here indicates
  49. * that no value has been explicitly set for this column, so ANALYZE
  50. * should use the default setting.
  51. */
  52. int32 attstattarget;
  53. /*
  54. * attlen is a copy of the typlen field from pg_type for this attribute.
  55. * See atttypid comments above.
  56. */
  57. int16 attlen;
  58. /*
  59. * attnum is the "attribute number" for the attribute: A value that
  60. * uniquely identifies this attribute within its class. For user
  61. * attributes, Attribute numbers are greater than 0 and not greater than
  62. * the number of attributes in the class. I.e. if the Class pg_class says
  63. * that Class XYZ has 10 attributes, then the user attribute numbers in
  64. * Class pg_attribute must be 1-10.
  65. *
  66. * System attributes have attribute numbers less than 0 that are unique
  67. * within the class, but not constrained to any particular range.
  68. *
  69. * Note that (attnum - 1) is often used as the index to an array.
  70. */
  71. int16 attnum;
  72. /*
  73. * attndims is the declared number of dimensions, if an array type,
  74. * otherwise zero.
  75. */
  76. int32 attndims;
  77. /*
  78. * fastgetattr() uses attcacheoff to cache byte offsets of attributes in
  79. * heap tuples. The value actually stored in pg_attribute (-1) indicates
  80. * no cached value. But when we copy these tuples into a tuple
  81. * descriptor, we may then update attcacheoff in the copies. This speeds
  82. * up the attribute walking process.
  83. */
  84. int32 attcacheoff;
  85. /*
  86. * atttypmod records type-specific data supplied at table creation time
  87. * (for example, the max length of a varchar field). It is passed to
  88. * type-specific input and output functions as the third argument. The
  89. * value will generally be -1 for types that do not need typmod.
  90. */
  91. int32 atttypmod;
  92. /*
  93. * attbyval is a copy of the typbyval field from pg_type for this
  94. * attribute. See atttypid comments above.
  95. */
  96. bool attbyval;
  97. /*----------
  98. * attstorage tells for VARLENA attributes, what the heap access
  99. * methods can do to it if a given tuple doesn't fit into a page.
  100. * Possible values are
  101. * 'p': Value must be stored plain always
  102. * 'e': Value can be stored in "secondary" relation (if relation
  103. * has one, see pg_class.reltoastrelid)
  104. * 'm': Value can be stored compressed inline
  105. * 'x': Value can be stored compressed inline or in "secondary"
  106. * Note that 'm' fields can also be moved out to secondary storage,
  107. * but only as a last resort ('e' and 'x' fields are moved first).
  108. *----------
  109. */
  110. char attstorage;
  111. /*
  112. * attalign is a copy of the typalign field from pg_type for this
  113. * attribute. See atttypid comments above.
  114. */
  115. char attalign;
  116. /* This flag represents the "NOT NULL" constraint */
  117. bool attnotnull;
  118. /* Has DEFAULT value or not */
  119. bool atthasdef;
  120. /* Is dropped (ie, logically invisible) or not */
  121. bool attisdropped;
  122. /*
  123. * This flag specifies whether this column has ever had a local
  124. * definition. It is set for normal non-inherited columns, but also for
  125. * columns that are inherited from parents if also explicitly listed in
  126. * CREATE TABLE INHERITS. It is also set when inheritance is removed from
  127. * a table with ALTER TABLE NO INHERIT. If the flag is set, the column is
  128. * not dropped by a parent's DROP COLUMN even if this causes the column's
  129. * attinhcount to become zero.
  130. */
  131. bool attislocal;
  132. /* Number of times inherited from direct parent relation(s) */
  133. int32 attinhcount;
  134. /* attribute's collation */
  135. Oid attcollation;
  136. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  137. /* NOTE: The following fields are not present in tuple descriptors. */
  138. /* Column-level access permissions */
  139. aclitem attacl[1];
  140. /* Column-level options */
  141. text attoptions[1];
  142. /* Column-level FDW options */
  143. text attfdwoptions[1];
  144. #endif
  145. } FormData_pg_attribute;
  146. /*
  147. * ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout,
  148. * guaranteed-not-null part of a pg_attribute row. This is in fact as much
  149. * of the row as gets copied into tuple descriptors, so don't expect you
  150. * can access fields beyond attcollation except in a real tuple!
  151. */
  152. #define ATTRIBUTE_FIXED_PART_SIZE \
  153. (offsetof(FormData_pg_attribute,attcollation) + sizeof(Oid))
  154. /* ----------------
  155. * Form_pg_attribute corresponds to a pointer to a tuple with
  156. * the format of pg_attribute relation.
  157. * ----------------
  158. */
  159. typedef FormData_pg_attribute *Form_pg_attribute;
  160. /* ----------------
  161. * compiler constants for pg_attribute
  162. * ----------------
  163. */
  164. #define Natts_pg_attribute 21
  165. #define Anum_pg_attribute_attrelid 1
  166. #define Anum_pg_attribute_attname 2
  167. #define Anum_pg_attribute_atttypid 3
  168. #define Anum_pg_attribute_attstattarget 4
  169. #define Anum_pg_attribute_attlen 5
  170. #define Anum_pg_attribute_attnum 6
  171. #define Anum_pg_attribute_attndims 7
  172. #define Anum_pg_attribute_attcacheoff 8
  173. #define Anum_pg_attribute_atttypmod 9
  174. #define Anum_pg_attribute_attbyval 10
  175. #define Anum_pg_attribute_attstorage 11
  176. #define Anum_pg_attribute_attalign 12
  177. #define Anum_pg_attribute_attnotnull 13
  178. #define Anum_pg_attribute_atthasdef 14
  179. #define Anum_pg_attribute_attisdropped 15
  180. #define Anum_pg_attribute_attislocal 16
  181. #define Anum_pg_attribute_attinhcount 17
  182. #define Anum_pg_attribute_attcollation 18
  183. #define Anum_pg_attribute_attacl 19
  184. #define Anum_pg_attribute_attoptions 20
  185. #define Anum_pg_attribute_attfdwoptions 21
  186. /* ----------------
  187. * initial contents of pg_attribute
  188. *
  189. * The initial contents of pg_attribute are generated at compile time by
  190. * genbki.pl. Only "bootstrapped" relations need be included.
  191. * ----------------
  192. */
  193. #endif /* PG_ATTRIBUTE_H */