1/*-------------------------------------------------------------------------
4 * definition of the "attribute" system catalog (pg_attribute)
6 * The initial contents of pg_attribute are generated at compile time by
7 * genbki.pl, so there is no pg_attribute.dat file. Only "bootstrapped"
8 * relations need be included.
11 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
14 * src/include/catalog/pg_attribute.h
17 * The Catalog.pm module reads this file and derives schema
20 *-------------------------------------------------------------------------
26#include "catalog/pg_attribute_d.h" /* IWYU pragma: export */
29 * pg_attribute definition. cpp turns this into
30 * typedef struct FormData_pg_attribute
32 * If you change the following, make sure you change the structs for
33 * system attributes in catalog/heap.c also.
34 * You may need to change catalog/genbki.pl as well.
39 Oid attrelid
BKI_LOOKUP(pg_class);
/* OID of relation containing
44 * atttypid is the OID of the instance in Catalog Class pg_type that
45 * defines the data type of this attribute (e.g. int4). Information in
46 * that instance is redundant with the attlen, attbyval, and attalign
47 * attributes of this instance, so they had better match or Postgres will
48 * fail. In an entry for a dropped column, this field is set to zero
49 * 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 the
56 * attlen is a copy of the typlen field from pg_type for this attribute.
57 * See atttypid comments above.
62 * attnum is the "attribute number" for the attribute: A value that
63 * uniquely identifies this attribute within its class. For user
64 * attributes, Attribute numbers are greater than 0 and not greater than
65 * the number of attributes in the class. I.e. if the Class pg_class says
66 * that Class XYZ has 10 attributes, then the user attribute numbers in
67 * Class pg_attribute must be 1-10.
69 * System attributes have attribute numbers less than 0 that are unique
70 * within the class, but not constrained to any particular range.
72 * Note that (attnum - 1) is often used as the index to an array.
77 * atttypmod records type-specific data supplied at table creation time
78 * (for example, the max length of a varchar field). It is passed to
79 * type-specific input and output functions as the third argument. The
80 * value will generally be -1 for types that do not need typmod.
85 * attndims is the declared number of dimensions, if an array type,
91 * attbyval is a copy of the typbyval field from pg_type for this
92 * attribute. See atttypid comments above.
97 * attalign is a copy of the typalign field from pg_type for this
98 * attribute. See atttypid comments above.
103 * attstorage tells for VARLENA attributes, what the heap access
104 * methods can do to it if a given tuple doesn't fit into a page.
105 * Possible values are as for pg_type.typstorage (see TYPSTORAGE macros).
111 * attcompression sets the current compression method of the attribute.
112 * Typically this is InvalidCompressionMethod ('0円') to specify use of the
113 * current default setting (see default_toast_compression). Otherwise,
114 * 'p' selects pglz compression, while 'l' selects LZ4 compression.
115 * However, this field is ignored whenever attstorage does not allow
121 * Whether a (possibly invalid) not-null constraint exists for the column
125 /* Has DEFAULT value or not */
128 /* Has a missing value or not */
131 /* One of the ATTRIBUTE_IDENTITY_* constants below, or '0円' */
134 /* One of the ATTRIBUTE_GENERATED_* constants below, or '0円' */
137 /* Is dropped (ie, logically invisible) or not */
141 * This flag specifies whether this column has ever had a local
142 * definition. It is set for normal non-inherited columns, but also for
143 * columns that are inherited from parents if also explicitly listed in
144 * CREATE TABLE INHERITS. It is also set when inheritance is removed from
145 * a table with ALTER TABLE NO INHERIT. If the flag is set, the column is
146 * not dropped by a parent's DROP COLUMN even if this causes the column's
147 * attinhcount to become zero.
151 /* Number of times inherited from direct parent relation(s) */
154 /* attribute's collation, if any */
157#ifdef CATALOG_VARLEN /* variable-length/nullable fields start here */
158 /* NOTE: The following fields are not present in tuple descriptors. */
161 * attstattarget is the target number of statistics datapoints to collect
162 * during VACUUM ANALYZE of this column. A zero here indicates that we do
163 * not wish to collect any stats about this column. A null value here
164 * indicates that no value has been explicitly set for this column, so
165 * ANALYZE should use the default setting.
167 * int16 is sufficient for the current max value (MAX_STATISTICS_TARGET).
171 /* Column-level access permissions */
174 /* Column-level options */
177 /* Column-level FDW options */
181 * Missing value for added columns. This is a one element array which lets
182 * us store a value of the attribute type here.
189 * ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout,
190 * guaranteed-not-null part of a pg_attribute row. This is in fact as much
191 * of the row as gets copied into tuple descriptors, so don't expect you
192 * can access the variable-length fields except in a real tuple!
194 #define ATTRIBUTE_FIXED_PART_SIZE \
195 (offsetof(FormData_pg_attribute,attcollation) + sizeof(Oid))
198 * Form_pg_attribute corresponds to a pointer to a tuple with
199 * the format of pg_attribute relation.
205 * FormExtraData_pg_attribute contains (some of) the fields that are not in
206 * FormData_pg_attribute because they are excluded by CATALOG_VARLEN. It is
207 * meant to be used by DDL code so that the combination of
208 * FormData_pg_attribute (often via tuple descriptor) and
209 * FormExtraData_pg_attribute can be used to pass around all the information
210 * about an attribute. Fields can be included here as needed.
224#ifdef EXPOSE_TO_CLIENT_CODE
226#define ATTRIBUTE_IDENTITY_ALWAYS 'a'
227#define ATTRIBUTE_IDENTITY_BY_DEFAULT 'd'
229#define ATTRIBUTE_GENERATED_STORED 's'
230#define ATTRIBUTE_GENERATED_VIRTUAL 'v'
232#endif /* EXPOSE_TO_CLIENT_CODE */
234#endif /* PG_ATTRIBUTE_H */
#define BKI_LOOKUP(catalog)
#define BKI_ROWTYPE_OID(oid, oidmacro)
struct FormExtraData_pg_attribute FormExtraData_pg_attribute
Oid atttypid BKI_LOOKUP_OPT(pg_type)
CATALOG(pg_attribute, 1249, AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, pg_attribute, btree(attrelid oid_ops, attname name_ops))
AttributeRelation_Rowtype_Id BKI_SCHEMA_MACRO
MAKE_SYSCACHE(ATTNAME, pg_attribute_relid_attnam_index, 32)
FormData_pg_attribute * Form_pg_attribute
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, pg_attribute, btree(attrelid oid_ops, attnum int2_ops))
int32 atttypmod BKI_DEFAULT(-1)