PostgreSQL Source Code  git master
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * heap.h
4  * prototypes for functions in backend/catalog/heap.c
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/catalog/heap.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef HEAP_H
15 #define HEAP_H
17 #include "catalog/indexing.h"
18 #include "catalog/objectaddress.h"
19 #include "parser/parse_node.h"
22 /* flag bits for CheckAttributeType/CheckAttributeNamesTypes */
23 #define CHKATYPE_ANYARRAY 0x01 /* allow ANYARRAY */
24 #define CHKATYPE_ANYRECORD 0x02 /* allow RECORD and RECORD[] */
26 typedef struct RawColumnDefault
27 {
28  AttrNumber attnum; /* attribute to attach default to */
29  Node *raw_default; /* default value (untransformed parse tree) */
30  bool missingMode; /* true if part of add column processing */
31  char generated; /* attgenerated setting */
34 typedef struct CookedConstraint
35 {
36  ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
37  Oid conoid; /* constr OID if created, otherwise Invalid */
38  char *name; /* name, or NULL if none */
39  AttrNumber attnum; /* which attr (only for DEFAULT) */
40  Node *expr; /* transformed default or check expr */
41  bool skip_validation; /* skip validation? (only for CHECK) */
42  bool is_local; /* constraint has local (non-inherited) def */
43  int inhcount; /* number of times constraint is inherited */
44  bool is_no_inherit; /* constraint has local def and cannot be
45  * inherited */
48 extern Relation heap_create(const char *relname,
49  Oid relnamespace,
50  Oid reltablespace,
51  Oid relid,
53  Oid accessmtd,
54  TupleDesc tupDesc,
55  char relkind,
56  char relpersistence,
57  bool shared_relation,
58  bool mapped_relation,
59  bool allow_system_table_mods,
63 extern Oid heap_create_with_catalog(const char *relname,
64  Oid relnamespace,
65  Oid reltablespace,
66  Oid relid,
67  Oid reltypeid,
68  Oid reloftypeid,
69  Oid ownerid,
70  Oid accessmtd,
71  TupleDesc tupdesc,
72  List *cooked_constraints,
73  char relkind,
74  char relpersistence,
75  bool shared_relation,
76  bool mapped_relation,
77  OnCommitAction oncommit,
78  Datum reloptions,
79  bool use_user_acl,
80  bool allow_system_table_mods,
81  bool is_internal,
82  Oid relrewrite,
83  ObjectAddress *typaddress);
85 extern void heap_drop_with_catalog(Oid relid);
87 extern void heap_truncate(List *relids);
89 extern void heap_truncate_one_rel(Relation rel);
91 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
93 extern List *heap_truncate_find_FKs(List *relationIds);
95 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
96  Form_pg_attribute new_attribute,
97  CatalogIndexState indstate);
99 extern void InsertPgClassTuple(Relation pg_class_desc,
100  Relation new_rel_desc,
101  Oid new_rel_oid,
102  Datum relacl,
103  Datum reloptions);
106  List *newColDefaults,
107  List *newConstraints,
108  bool allow_merge,
109  bool is_local,
110  bool is_internal,
111  const char *queryString);
113 extern void RelationClearMissing(Relation rel);
114 extern void SetAttrMissing(Oid relid, char *attname, char *value);
117  Node *expr, bool is_internal,
118  bool add_column_mode);
120 extern Node *cookDefault(ParseState *pstate,
121  Node *raw_default,
122  Oid atttypid,
123  int32 atttypmod,
124  const char *attname,
125  char attgenerated);
127 extern void DeleteRelationTuple(Oid relid);
128 extern void DeleteAttributeTuples(Oid relid);
129 extern void DeleteSystemAttributeTuples(Oid relid);
130 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
131 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
132  DropBehavior behavior, bool complain, bool internal);
133 extern void RemoveAttrDefaultById(Oid attrdefId);
134 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
138 extern const FormData_pg_attribute *SystemAttributeByName(const char *attname);
140 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
141  int flags);
143 extern void CheckAttributeType(const char *attname,
145  List *containing_rowtypes,
146  int flags);
148 /* pg_partitioned_table catalog manipulation functions */
149 extern void StorePartitionKey(Relation rel,
150  char strategy,
151  int16 partnatts,
152  AttrNumber *partattrs,
153  List *partexprs,
154  Oid *partopclass,
155  Oid *partcollation);
156 extern void RemovePartitionKeyByRelId(Oid relid);
157 extern void StorePartitionBound(Relation rel, Relation parent,
158  PartitionBoundSpec *bound);
160 #endif /* HEAP_H */
signed short int16
Definition: c.h:346
Definition: parsenodes.h:2095
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:3090
bool is_no_inherit
Definition: heap.h:44
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3569
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1538
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1579
uint32 TransactionId
Definition: c.h:508
AttrNumber attnum
Definition: heap.h:28
void RelationClearMissing(Relation rel)
Definition: heap.c:1997
struct CookedConstraint CookedConstraint
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
Definition: heap.c:578
static struct @145 value
Definition: nodes.h:525
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:47
char relkind
Definition: pg_class.h:81
signed int int32
Definition: c.h:347
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1820
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
Definition: heap.c:2126
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3358
AttrNumber attnum
Definition: heap.h:39
NameData attname
Definition: pg_attribute.h:40
char relpersistence
Definition: pg_class.h:78
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3538
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
Definition: heap.c:2490
Oid relfilenode
Definition: pg_class.h:54
bool missingMode
Definition: heap.h:30
struct RawColumnDefault RawColumnDefault
Oid attcollation
Definition: pg_attribute.h:164
int inhcount
Definition: heap.h:43
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
Definition: heap.c:1692
Oid heap_create_with_catalog(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid reltypeid, Oid reloftypeid, Oid ownerid, Oid accessmtd, TupleDesc tupdesc, List *cooked_constraints, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, OnCommitAction oncommit, Datum reloptions, bool use_user_acl, bool allow_system_table_mods, bool is_internal, Oid relrewrite, ObjectAddress *typaddress)
Definition: heap.c:1065
void SetAttrMissing(Oid relid, char *attname, char *value)
Definition: heap.c:2065
char generated
Definition: heap.h:31
Node * raw_default
Definition: heap.h:29
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3406
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid relfilenode, Oid accessmtd, TupleDesc tupDesc, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, bool allow_system_table_mods, TransactionId *relfrozenxid, MultiXactId *relminmxid)
Definition: heap.c:295
bool skip_validation
Definition: heap.h:41
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
Definition: heap.c:490
void heap_truncate(List *relids)
Definition: heap.c:3178
ConstrType contype
Definition: heap.h:36
Oid atttypid
Definition: pg_attribute.h:49
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1501
void InsertPgAttributeTuple(Relation pg_attribute_rel, Form_pg_attribute new_attribute, CatalogIndexState indstate)
Definition: heap.c:694
Definition: parsenodes.h:1740
uintptr_t Datum
Definition: postgres.h:367
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
Definition: heap.c:2973
Definition: pg_attribute.h:184
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
Definition: heap.c:262
TransactionId relminmxid
Definition: pg_class.h:126
TransactionId MultiXactId
Definition: c.h:518
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
Definition: heap.c:250
void RemoveAttrDefaultById(Oid attrdefId)
Definition: heap.c:1747
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:3263
TransactionId relfrozenxid
Definition: pg_class.h:123
Oid conoid
Definition: heap.h:37
Node * expr
Definition: heap.h:40
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1472
Definition: pg_list.h:50
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
Definition: heap.c:848
int16 AttrNumber
Definition: attnum.h:21
char * name
Definition: heap.h:38
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:3219
bool is_local
Definition: heap.h:42