1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* pg_attribute.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* definition of the system "attribute" relation (pg_attribute)
|
|
|
|
* along with the relation's initial contents.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2014-01-07 22:05:30 +01:00
|
|
|
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/catalog/pg_attribute.h
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
2010-01-05 02:06:57 +01:00
|
|
|
* the genbki.pl script reads this file and generates .bki
|
1997-09-07 07:04:48 +02:00
|
|
|
* information from the DATA() statements.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef PG_ATTRIBUTE_H
|
|
|
|
#define PG_ATTRIBUTE_H
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2008-03-27 04:57:34 +01:00
|
|
|
#include "catalog/genbki.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* pg_attribute definition. cpp turns this into
|
|
|
|
* typedef struct FormData_pg_attribute
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* If you change the following, make sure you change the structs for
|
2001-05-07 02:43:27 +02:00
|
|
|
* system attributes in catalog/heap.c also.
|
2010-01-05 02:06:57 +01:00
|
|
|
* You may need to change catalog/genbki.pl as well.
|
1996-08-28 03:59:28 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
2005-04-14 03:38:22 +02:00
|
|
|
#define AttributeRelationId 1249
|
2009-09-27 00:42:03 +02:00
|
|
|
#define AttributeRelation_Rowtype_Id 75
|
2005-04-14 03:38:22 +02:00
|
|
|
|
2010-01-05 02:06:57 +01:00
|
|
|
CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BKI_SCHEMA_MACRO
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
Oid attrelid; /* OID of relation containing this attribute */
|
2001-05-07 02:43:27 +02:00
|
|
|
NameData attname; /* name of attribute */
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* atttypid is the OID of the instance in Catalog Class pg_type that
|
2005-10-15 04:49:52 +02:00
|
|
|
* defines the data type of this attribute (e.g. int4). Information in
|
|
|
|
* that instance is redundant with the attlen, attbyval, and attalign
|
|
|
|
* attributes of this instance, so they had better match or Postgres will
|
|
|
|
* fail.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2001-05-07 02:43:27 +02:00
|
|
|
Oid atttypid;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1999-07-31 21:07:25 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* attstattarget is the target number of statistics datapoints to collect
|
|
|
|
* during VACUUM ANALYZE of this column. A zero here indicates that we do
|
|
|
|
* not wish to collect any stats about this column. A "-1" here indicates
|
|
|
|
* that no value has been explicitly set for this column, so ANALYZE
|
|
|
|
* should use the default setting.
|
1999-07-31 21:07:25 +02:00
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 attstattarget;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* attlen is a copy of the typlen field from pg_type for this attribute.
|
|
|
|
* See atttypid comments above.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int16 attlen;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* attnum is the "attribute number" for the attribute: A value that
|
|
|
|
* uniquely identifies this attribute within its class. For user
|
2005-10-15 04:49:52 +02:00
|
|
|
* attributes, Attribute numbers are greater than 0 and not greater than
|
|
|
|
* the number of attributes in the class. I.e. if the Class pg_class says
|
|
|
|
* that Class XYZ has 10 attributes, then the user attribute numbers in
|
|
|
|
* Class pg_attribute must be 1-10.
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
|
|
|
* System attributes have attribute numbers less than 0 that are unique
|
|
|
|
* within the class, but not constrained to any particular range.
|
|
|
|
*
|
|
|
|
* Note that (attnum - 1) is often used as the index to an array.
|
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int16 attnum;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-05-07 02:43:27 +02:00
|
|
|
/*
|
|
|
|
* attndims is the declared number of dimensions, if an array type,
|
|
|
|
* otherwise zero.
|
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 attndims;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* fastgetattr() uses attcacheoff to cache byte offsets of attributes in
|
|
|
|
* heap tuples. The value actually stored in pg_attribute (-1) indicates
|
|
|
|
* no cached value. But when we copy these tuples into a tuple
|
|
|
|
* descriptor, we may then update attcacheoff in the copies. This speeds
|
|
|
|
* up the attribute walking process.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 attcacheoff;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1998-01-17 00:21:07 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* atttypmod records type-specific data supplied at table creation time
|
|
|
|
* (for example, the max length of a varchar field). It is passed to
|
|
|
|
* type-specific input and output functions as the third argument. The
|
|
|
|
* value will generally be -1 for types that do not need typmod.
|
1998-01-17 00:21:07 +01:00
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 atttypmod;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* attbyval is a copy of the typbyval field from pg_type for this
|
2001-05-07 02:43:27 +02:00
|
|
|
* attribute. See atttypid comments above.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2001-05-07 02:43:27 +02:00
|
|
|
bool attbyval;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-08-01 00:39:17 +02:00
|
|
|
/*----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* attstorage tells for VARLENA attributes, what the heap access
|
|
|
|
* methods can do to it if a given tuple doesn't fit into a page.
|
2000-08-01 00:39:17 +02:00
|
|
|
* Possible values are
|
|
|
|
* 'p': Value must be stored plain always
|
|
|
|
* 'e': Value can be stored in "secondary" relation (if relation
|
2000-08-06 06:40:08 +02:00
|
|
|
* has one, see pg_class.reltoastrelid)
|
2000-08-01 00:39:17 +02:00
|
|
|
* 'm': Value can be stored compressed inline
|
|
|
|
* 'x': Value can be stored compressed inline or in "secondary"
|
2000-08-06 06:40:08 +02:00
|
|
|
* Note that 'm' fields can also be moved out to secondary storage,
|
|
|
|
* but only as a last resort ('e' and 'x' fields are moved first).
|
2000-08-01 00:39:17 +02:00
|
|
|
*----------
|
1999-12-20 11:40:43 +01:00
|
|
|
*/
|
2001-05-07 02:43:27 +02:00
|
|
|
char attstorage;
|
1999-12-20 11:40:43 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* attalign is a copy of the typalign field from pg_type for this
|
2001-05-07 02:43:27 +02:00
|
|
|
* attribute. See atttypid comments above.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2001-05-07 02:43:27 +02:00
|
|
|
char attalign;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* This flag represents the "NOT NULL" constraint */
|
2001-05-07 02:43:27 +02:00
|
|
|
bool attnotnull;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* Has DEFAULT value or not */
|
2001-05-07 02:43:27 +02:00
|
|
|
bool atthasdef;
|
2002-08-02 20:15:10 +02:00
|
|
|
|
|
|
|
/* Is dropped (ie, logically invisible) or not */
|
|
|
|
bool attisdropped;
|
2002-08-30 21:23:20 +02:00
|
|
|
|
2014-08-30 01:01:04 +02:00
|
|
|
/*
|
|
|
|
* Has a local definition (hence, do not drop when attinhcount is 0)
|
|
|
|
* This is set and remains set if the column was _ever_
|
|
|
|
* local/not-inherited, e.g. this can be set by ALTER TABLE NO INHERIT.
|
|
|
|
*/
|
2002-09-22 21:42:52 +02:00
|
|
|
bool attislocal;
|
|
|
|
|
|
|
|
/* Number of times inherited from direct parent relation(s) */
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 attinhcount;
|
2009-01-22 21:16:10 +01:00
|
|
|
|
2011-02-08 22:04:18 +01:00
|
|
|
/* attribute's collation */
|
|
|
|
Oid attcollation;
|
|
|
|
|
2012-01-27 19:16:17 +01:00
|
|
|
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
|
|
|
/* NOTE: The following fields are not present in tuple descriptors. */
|
2009-01-22 21:16:10 +01:00
|
|
|
|
|
|
|
/* Column-level access permissions */
|
|
|
|
aclitem attacl[1];
|
2010-01-22 17:40:19 +01:00
|
|
|
|
|
|
|
/* Column-level options */
|
|
|
|
text attoptions[1];
|
2011-08-05 19:24:03 +02:00
|
|
|
|
|
|
|
/* Column-level FDW options */
|
|
|
|
text attfdwoptions[1];
|
2012-01-27 19:16:17 +01:00
|
|
|
#endif
|
1996-08-28 03:59:28 +02:00
|
|
|
} FormData_pg_attribute;
|
|
|
|
|
|
|
|
/*
|
2009-01-22 21:16:10 +01:00
|
|
|
* ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout,
|
2014-05-06 18:12:18 +02:00
|
|
|
* guaranteed-not-null part of a pg_attribute row. This is in fact as much
|
2009-01-22 21:16:10 +01:00
|
|
|
* of the row as gets copied into tuple descriptors, so don't expect you
|
2011-02-08 22:04:18 +01:00
|
|
|
* can access fields beyond attcollation except in a real tuple!
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
2009-01-22 21:16:10 +01:00
|
|
|
#define ATTRIBUTE_FIXED_PART_SIZE \
|
2011-02-08 22:04:18 +01:00
|
|
|
(offsetof(FormData_pg_attribute,attcollation) + sizeof(Oid))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* Form_pg_attribute corresponds to a pointer to a tuple with
|
|
|
|
* the format of pg_attribute relation.
|
1996-08-28 03:59:28 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-09-01 05:29:17 +02:00
|
|
|
typedef FormData_pg_attribute *Form_pg_attribute;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* compiler constants for pg_attribute
|
1996-08-28 03:59:28 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
2011-08-05 19:24:03 +02:00
|
|
|
#define Natts_pg_attribute 21
|
1997-09-07 07:04:48 +02:00
|
|
|
#define Anum_pg_attribute_attrelid 1
|
|
|
|
#define Anum_pg_attribute_attname 2
|
|
|
|
#define Anum_pg_attribute_atttypid 3
|
2001-05-07 02:43:27 +02:00
|
|
|
#define Anum_pg_attribute_attstattarget 4
|
2010-01-22 17:40:19 +01:00
|
|
|
#define Anum_pg_attribute_attlen 5
|
|
|
|
#define Anum_pg_attribute_attnum 6
|
|
|
|
#define Anum_pg_attribute_attndims 7
|
|
|
|
#define Anum_pg_attribute_attcacheoff 8
|
|
|
|
#define Anum_pg_attribute_atttypmod 9
|
|
|
|
#define Anum_pg_attribute_attbyval 10
|
|
|
|
#define Anum_pg_attribute_attstorage 11
|
|
|
|
#define Anum_pg_attribute_attalign 12
|
|
|
|
#define Anum_pg_attribute_attnotnull 13
|
|
|
|
#define Anum_pg_attribute_atthasdef 14
|
|
|
|
#define Anum_pg_attribute_attisdropped 15
|
|
|
|
#define Anum_pg_attribute_attislocal 16
|
|
|
|
#define Anum_pg_attribute_attinhcount 17
|
2011-02-08 22:04:18 +01:00
|
|
|
#define Anum_pg_attribute_attcollation 18
|
|
|
|
#define Anum_pg_attribute_attacl 19
|
|
|
|
#define Anum_pg_attribute_attoptions 20
|
2012-06-10 21:20:04 +02:00
|
|
|
#define Anum_pg_attribute_attfdwoptions 21
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* initial contents of pg_attribute
|
2001-06-12 07:55:50 +02:00
|
|
|
*
|
2010-01-05 02:06:57 +01:00
|
|
|
* The initial contents of pg_attribute are generated at compile time by
|
|
|
|
* genbki.pl. Only "bootstrapped" relations need be included.
|
2005-03-29 02:17:27 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* PG_ATTRIBUTE_H */
|