codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * pg_attribute.h4 * definition of the "attribute" system catalog (pg_attribute)5 *6 * The initial contents of pg_attribute are generated at compile time by7 * genbki.pl, so there is no pg_attribute.dat file. Only "bootstrapped"8 * relations need be included.9 *10 *11 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group12 * Portions Copyright (c) 1994, Regents of the University of California13 *14 * src/include/catalog/pg_attribute.h15 *16 * NOTES17 * The Catalog.pm module reads this file and derives schema18 * information.19 *20 *-------------------------------------------------------------------------21 */22#ifndef PG_ATTRIBUTE_H23#define PG_ATTRIBUTE_H24 25#include "catalog/genbki.h"26#include "catalog/pg_attribute_d.h"27 28/* ----------------29 * pg_attribute definition. cpp turns this into30 * typedef struct FormData_pg_attribute31 *32 * If you change the following, make sure you change the structs for33 * system attributes in catalog/heap.c also.34 * You may need to change catalog/genbki.pl as well.35 * ----------------36 */37CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,AttributeRelation_Rowtype_Id) BKI_SCHEMA_MACRO38{39 Oid attrelid BKI_LOOKUP(pg_class); /* OID of relation containing40 * this attribute */41 NameData attname; /* name of attribute */42 43 /*44 * atttypid is the OID of the instance in Catalog Class pg_type that45 * defines the data type of this attribute (e.g. int4). Information in46 * that instance is redundant with the attlen, attbyval, and attalign47 * attributes of this instance, so they had better match or Postgres will48 * fail. In an entry for a dropped column, this field is set to zero49 * since the pg_type entry may no longer exist; but we rely on attlen,50 * attbyval, and attalign to still tell us how large the values in the51 * table are.52 */53 Oid atttypid BKI_LOOKUP_OPT(pg_type);54 55 /*56 * attlen is a copy of the typlen field from pg_type for this attribute.57 * See atttypid comments above.58 */59 int16 attlen;60 61 /*62 * attnum is the "attribute number" for the attribute: A value that63 * uniquely identifies this attribute within its class. For user64 * attributes, Attribute numbers are greater than 0 and not greater than65 * the number of attributes in the class. I.e. if the Class pg_class says66 * that Class XYZ has 10 attributes, then the user attribute numbers in67 * Class pg_attribute must be 1-10.68 *69 * System attributes have attribute numbers less than 0 that are unique70 * within the class, but not constrained to any particular range.71 *72 * Note that (attnum - 1) is often used as the index to an array.73 */74 int16 attnum;75 76 /*77 * fastgetattr() uses attcacheoff to cache byte offsets of attributes in78 * heap tuples. The value actually stored in pg_attribute (-1) indicates79 * no cached value. But when we copy these tuples into a tuple80 * descriptor, we may then update attcacheoff in the copies. This speeds81 * up the attribute walking process.82 */83 int32 attcacheoff BKI_DEFAULT(-1);84 85 /*86 * atttypmod records type-specific data supplied at table creation time87 * (for example, the max length of a varchar field). It is passed to88 * type-specific input and output functions as the third argument. The89 * value will generally be -1 for types that do not need typmod.90 */91 int32 atttypmod BKI_DEFAULT(-1);92 93 /*94 * attndims is the declared number of dimensions, if an array type,95 * otherwise zero.96 */97 int16 attndims;98 99 /*100 * attbyval is a copy of the typbyval field from pg_type for this101 * attribute. See atttypid comments above.102 */103 bool attbyval;104 105 /*106 * attalign is a copy of the typalign field from pg_type for this107 * attribute. See atttypid comments above.108 */109 char attalign;110 111 /*----------112 * attstorage tells for VARLENA attributes, what the heap access113 * methods can do to it if a given tuple doesn't fit into a page.114 * Possible values are as for pg_type.typstorage (see TYPSTORAGE macros).115 *----------116 */117 char attstorage;118 119 /*120 * attcompression sets the current compression method of the attribute.121 * Typically this is InvalidCompressionMethod ('\0') to specify use of the122 * current default setting (see default_toast_compression). Otherwise,123 * 'p' selects pglz compression, while 'l' selects LZ4 compression.124 * However, this field is ignored whenever attstorage does not allow125 * compression.126 */127 char attcompression BKI_DEFAULT('\0');128 129 /* This flag represents the "NOT NULL" constraint */130 bool attnotnull;131 132 /* Has DEFAULT value or not */133 bool atthasdef BKI_DEFAULT(f);134 135 /* Has a missing value or not */136 bool atthasmissing BKI_DEFAULT(f);137 138 /* One of the ATTRIBUTE_IDENTITY_* constants below, or '\0' */139 char attidentity BKI_DEFAULT('\0');140 141 /* One of the ATTRIBUTE_GENERATED_* constants below, or '\0' */142 char attgenerated BKI_DEFAULT('\0');143 144 /* Is dropped (ie, logically invisible) or not */145 bool attisdropped BKI_DEFAULT(f);146 147 /*148 * This flag specifies whether this column has ever had a local149 * definition. It is set for normal non-inherited columns, but also for150 * columns that are inherited from parents if also explicitly listed in151 * CREATE TABLE INHERITS. It is also set when inheritance is removed from152 * a table with ALTER TABLE NO INHERIT. If the flag is set, the column is153 * not dropped by a parent's DROP COLUMN even if this causes the column's154 * attinhcount to become zero.155 */156 bool attislocal BKI_DEFAULT(t);157 158 /* Number of times inherited from direct parent relation(s) */159 int16 attinhcount BKI_DEFAULT(0);160 161 /*162 * attstattarget is the target number of statistics datapoints to collect163 * during VACUUM ANALYZE of this column. A zero here indicates that we do164 * not wish to collect any stats about this column. A "-1" here indicates165 * that no value has been explicitly set for this column, so ANALYZE166 * should use the default setting.167 *168 * int16 is sufficient because the max value is currently 10000.169 */170 int16 attstattarget BKI_DEFAULT(-1);171 172 /* attribute's collation, if any */173 Oid attcollation BKI_LOOKUP_OPT(pg_collation);174 175#ifdef CATALOG_VARLEN /* variable-length fields start here */176 /* NOTE: The following fields are not present in tuple descriptors. */177 178 /* Column-level access permissions */179 aclitem attacl[1] BKI_DEFAULT(_null_);180 181 /* Column-level options */182 text attoptions[1] BKI_DEFAULT(_null_);183 184 /* Column-level FDW options */185 text attfdwoptions[1] BKI_DEFAULT(_null_);186 187 /*188 * Missing value for added columns. This is a one element array which lets189 * us store a value of the attribute type here.190 */191 anyarray attmissingval BKI_DEFAULT(_null_);192#endif193} FormData_pg_attribute;194 195/*196 * ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout,197 * guaranteed-not-null part of a pg_attribute row. This is in fact as much198 * of the row as gets copied into tuple descriptors, so don't expect you199 * can access the variable-length fields except in a real tuple!200 */201#define ATTRIBUTE_FIXED_PART_SIZE \202 (offsetof(FormData_pg_attribute,attcollation) + sizeof(Oid))203 204/* ----------------205 * Form_pg_attribute corresponds to a pointer to a tuple with206 * the format of pg_attribute relation.207 * ----------------208 */209typedef FormData_pg_attribute *Form_pg_attribute;210 211DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));212DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));213 214#ifdef EXPOSE_TO_CLIENT_CODE215 216#define ATTRIBUTE_IDENTITY_ALWAYS 'a'217#define ATTRIBUTE_IDENTITY_BY_DEFAULT 'd'218 219#define ATTRIBUTE_GENERATED_STORED 's'220 221#endif /* EXPOSE_TO_CLIENT_CODE */222 223#endif /* PG_ATTRIBUTE_H */224 