00001 /*------------------------------------------------------------------------- 00002 * 00003 * pg_attribute.h 00004 * definition of the system "attribute" relation (pg_attribute) 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_attribute.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_ATTRIBUTE_H 00020 #define PG_ATTRIBUTE_H 00021 00022 #include "catalog/genbki.h" 00023 00024 /* ---------------- 00025 * pg_attribute definition. cpp turns this into 00026 * typedef struct FormData_pg_attribute 00027 * 00028 * If you change the following, make sure you change the structs for 00029 * system attributes in catalog/heap.c also. 00030 * You may need to change catalog/genbki.pl as well. 00031 * ---------------- 00032 */ 00033 #define AttributeRelationId 1249 00034 #define AttributeRelation_Rowtype_Id 75 00035 00036 CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BKI_SCHEMA_MACRO 00037 { 00038 Oid attrelid; /* OID of relation containing this attribute */ 00039 NameData attname; /* name of attribute */ 00040 00041 /* 00042 * atttypid is the OID of the instance in Catalog Class pg_type that 00043 * defines the data type of this attribute (e.g. int4). Information in 00044 * that instance is redundant with the attlen, attbyval, and attalign 00045 * attributes of this instance, so they had better match or Postgres will 00046 * fail. 00047 */ 00048 Oid atttypid; 00049 00050 /* 00051 * attstattarget is the target number of statistics datapoints to collect 00052 * during VACUUM ANALYZE of this column. A zero here indicates that we do 00053 * not wish to collect any stats about this column. A "-1" here indicates 00054 * that no value has been explicitly set for this column, so ANALYZE 00055 * should use the default setting. 00056 */ 00057 int32 attstattarget; 00058 00059 /* 00060 * attlen is a copy of the typlen field from pg_type for this attribute. 00061 * See atttypid comments above. 00062 */ 00063 int16 attlen; 00064 00065 /* 00066 * attnum is the "attribute number" for the attribute: A value that 00067 * uniquely identifies this attribute within its class. For user 00068 * attributes, Attribute numbers are greater than 0 and not greater than 00069 * the number of attributes in the class. I.e. if the Class pg_class says 00070 * that Class XYZ has 10 attributes, then the user attribute numbers in 00071 * Class pg_attribute must be 1-10. 00072 * 00073 * System attributes have attribute numbers less than 0 that are unique 00074 * within the class, but not constrained to any particular range. 00075 * 00076 * Note that (attnum - 1) is often used as the index to an array. 00077 */ 00078 int16 attnum; 00079 00080 /* 00081 * attndims is the declared number of dimensions, if an array type, 00082 * otherwise zero. 00083 */ 00084 int32 attndims; 00085 00086 /* 00087 * fastgetattr() uses attcacheoff to cache byte offsets of attributes in 00088 * heap tuples. The value actually stored in pg_attribute (-1) indicates 00089 * no cached value. But when we copy these tuples into a tuple 00090 * descriptor, we may then update attcacheoff in the copies. This speeds 00091 * up the attribute walking process. 00092 */ 00093 int32 attcacheoff; 00094 00095 /* 00096 * atttypmod records type-specific data supplied at table creation time 00097 * (for example, the max length of a varchar field). It is passed to 00098 * type-specific input and output functions as the third argument. The 00099 * value will generally be -1 for types that do not need typmod. 00100 */ 00101 int32 atttypmod; 00102 00103 /* 00104 * attbyval is a copy of the typbyval field from pg_type for this 00105 * attribute. See atttypid comments above. 00106 */ 00107 bool attbyval; 00108 00109 /*---------- 00110 * attstorage tells for VARLENA attributes, what the heap access 00111 * methods can do to it if a given tuple doesn't fit into a page. 00112 * Possible values are 00113 * 'p': Value must be stored plain always 00114 * 'e': Value can be stored in "secondary" relation (if relation 00115 * has one, see pg_class.reltoastrelid) 00116 * 'm': Value can be stored compressed inline 00117 * 'x': Value can be stored compressed inline or in "secondary" 00118 * Note that 'm' fields can also be moved out to secondary storage, 00119 * but only as a last resort ('e' and 'x' fields are moved first). 00120 *---------- 00121 */ 00122 char attstorage; 00123 00124 /* 00125 * attalign is a copy of the typalign field from pg_type for this 00126 * attribute. See atttypid comments above. 00127 */ 00128 char attalign; 00129 00130 /* This flag represents the "NOT NULL" constraint */ 00131 bool attnotnull; 00132 00133 /* Has DEFAULT value or not */ 00134 bool atthasdef; 00135 00136 /* Is dropped (ie, logically invisible) or not */ 00137 bool attisdropped; 00138 00139 /* Has a local definition (hence, do not drop when attinhcount is 0) */ 00140 bool attislocal; 00141 00142 /* Number of times inherited from direct parent relation(s) */ 00143 int32 attinhcount; 00144 00145 /* attribute's collation */ 00146 Oid attcollation; 00147 00148 #ifdef CATALOG_VARLEN /* variable-length fields start here */ 00149 /* NOTE: The following fields are not present in tuple descriptors. */ 00150 00151 /* Column-level access permissions */ 00152 aclitem attacl[1]; 00153 00154 /* Column-level options */ 00155 text attoptions[1]; 00156 00157 /* Column-level FDW options */ 00158 text attfdwoptions[1]; 00159 #endif 00160 } FormData_pg_attribute; 00161 00162 /* 00163 * ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout, 00164 * guaranteed-not-null part of a pg_attribute row. This is in fact as much 00165 * of the row as gets copied into tuple descriptors, so don't expect you 00166 * can access fields beyond attcollation except in a real tuple! 00167 */ 00168 #define ATTRIBUTE_FIXED_PART_SIZE \ 00169 (offsetof(FormData_pg_attribute,attcollation) + sizeof(Oid)) 00170 00171 /* ---------------- 00172 * Form_pg_attribute corresponds to a pointer to a tuple with 00173 * the format of pg_attribute relation. 00174 * ---------------- 00175 */ 00176 typedef FormData_pg_attribute *Form_pg_attribute; 00177 00178 /* ---------------- 00179 * compiler constants for pg_attribute 00180 * ---------------- 00181 */ 00182 00183 #define Natts_pg_attribute 21 00184 #define Anum_pg_attribute_attrelid 1 00185 #define Anum_pg_attribute_attname 2 00186 #define Anum_pg_attribute_atttypid 3 00187 #define Anum_pg_attribute_attstattarget 4 00188 #define Anum_pg_attribute_attlen 5 00189 #define Anum_pg_attribute_attnum 6 00190 #define Anum_pg_attribute_attndims 7 00191 #define Anum_pg_attribute_attcacheoff 8 00192 #define Anum_pg_attribute_atttypmod 9 00193 #define Anum_pg_attribute_attbyval 10 00194 #define Anum_pg_attribute_attstorage 11 00195 #define Anum_pg_attribute_attalign 12 00196 #define Anum_pg_attribute_attnotnull 13 00197 #define Anum_pg_attribute_atthasdef 14 00198 #define Anum_pg_attribute_attisdropped 15 00199 #define Anum_pg_attribute_attislocal 16 00200 #define Anum_pg_attribute_attinhcount 17 00201 #define Anum_pg_attribute_attcollation 18 00202 #define Anum_pg_attribute_attacl 19 00203 #define Anum_pg_attribute_attoptions 20 00204 #define Anum_pg_attribute_attfdwoptions 21 00205 00206 00207 /* ---------------- 00208 * initial contents of pg_attribute 00209 * 00210 * The initial contents of pg_attribute are generated at compile time by 00211 * genbki.pl. Only "bootstrapped" relations need be included. 00212 * ---------------- 00213 */ 00214 00215 #endif /* PG_ATTRIBUTE_H */