PostgreSQL Source Code  git master
heap.h
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-2020, 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
16 
17 #include "catalog/indexing.h"
18 #include "catalog/objectaddress.h"
19 #include "parser/parse_node.h"
20 
21 
22 /* flag bits for CheckAttributeType/CheckAttributeNamesTypes */
23 #define CHKATYPE_ANYARRAY 0x01 /* allow ANYARRAY */
24 #define CHKATYPE_ANYRECORD 0x02 /* allow RECORD and RECORD[] */
25 #define CHKATYPE_IS_PARTKEY 0x04 /* attname is part key # not column */
26 
27 typedef struct RawColumnDefault
28 {
29  AttrNumber attnum; /* attribute to attach default to */
30  Node *raw_default; /* default value (untransformed parse tree) */
31  bool missingMode; /* true if part of add column processing */
32  char generated; /* attgenerated setting */
34 
35 typedef struct CookedConstraint
36 {
37  ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
38  Oid conoid; /* constr OID if created, otherwise Invalid */
39  char *name; /* name, or NULL if none */
40  AttrNumber attnum; /* which attr (only for DEFAULT) */
41  Node *expr; /* transformed default or check expr */
42  bool skip_validation; /* skip validation? (only for CHECK) */
43  bool is_local; /* constraint has local (non-inherited) def */
44  int inhcount; /* number of times constraint is inherited */
45  bool is_no_inherit; /* constraint has local def and cannot be
46  * inherited */
48 
49 extern Relation heap_create(const char *relname,
50  Oid relnamespace,
51  Oid reltablespace,
52  Oid relid,
53  Oid relfilenode,
54  Oid accessmtd,
55  TupleDesc tupDesc,
56  char relkind,
57  char relpersistence,
58  bool shared_relation,
59  bool mapped_relation,
60  bool allow_system_table_mods,
61  TransactionId *relfrozenxid,
62  MultiXactId *relminmxid);
63 
64 extern Oid heap_create_with_catalog(const char *relname,
65  Oid relnamespace,
66  Oid reltablespace,
67  Oid relid,
68  Oid reltypeid,
69  Oid reloftypeid,
70  Oid ownerid,
71  Oid accessmtd,
72  TupleDesc tupdesc,
73  List *cooked_constraints,
74  char relkind,
75  char relpersistence,
76  bool shared_relation,
77  bool mapped_relation,
78  OnCommitAction oncommit,
79  Datum reloptions,
80  bool use_user_acl,
81  bool allow_system_table_mods,
82  bool is_internal,
83  Oid relrewrite,
84  ObjectAddress *typaddress);
85 
86 extern void heap_drop_with_catalog(Oid relid);
87 
88 extern void heap_truncate(List *relids);
89 
90 extern void heap_truncate_one_rel(Relation rel);
91 
92 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
93 
94 extern List *heap_truncate_find_FKs(List *relationIds);
95 
96 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
97  Form_pg_attribute new_attribute,
98  Datum attoptions,
99  CatalogIndexState indstate);
100 
101 extern void InsertPgClassTuple(Relation pg_class_desc,
102  Relation new_rel_desc,
103  Oid new_rel_oid,
104  Datum relacl,
105  Datum reloptions);
106 
108  List *newColDefaults,
109  List *newConstraints,
110  bool allow_merge,
111  bool is_local,
112  bool is_internal,
113  const char *queryString);
114 
115 extern void RelationClearMissing(Relation rel);
116 extern void SetAttrMissing(Oid relid, char *attname, char *value);
117 
119  Node *expr, bool is_internal,
120  bool add_column_mode);
121 
122 extern Node *cookDefault(ParseState *pstate,
123  Node *raw_default,
124  Oid atttypid,
125  int32 atttypmod,
126  const char *attname,
127  char attgenerated);
128 
129 extern void DeleteRelationTuple(Oid relid);
130 extern void DeleteAttributeTuples(Oid relid);
131 extern void DeleteSystemAttributeTuples(Oid relid);
132 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
133 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
134  DropBehavior behavior, bool complain, bool internal);
135 extern void RemoveAttrDefaultById(Oid attrdefId);
136 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
137 
139 
140 extern const FormData_pg_attribute *SystemAttributeByName(const char *attname);
141 
142 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
143  int flags);
144 
145 extern void CheckAttributeType(const char *attname,
147  List *containing_rowtypes,
148  int flags);
149 
150 /* pg_partitioned_table catalog manipulation functions */
151 extern void StorePartitionKey(Relation rel,
152  char strategy,
153  int16 partnatts,
154  AttrNumber *partattrs,
155  List *partexprs,
156  Oid *partopclass,
157  Oid *partcollation);
158 extern void RemovePartitionKeyByRelId(Oid relid);
159 extern void StorePartitionBound(Relation rel, Relation parent,
160  PartitionBoundSpec *bound);
161 
162 #endif /* HEAP_H */
signed short int16
Definition: c.h:354
ConstrType
Definition: parsenodes.h:2118
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:3123
bool is_no_inherit
Definition: heap.h:45
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3689
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1572
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1613
uint32 TransactionId
Definition: c.h:513
AttrNumber attnum
Definition: heap.h:29
void RelationClearMissing(Relation rel)
Definition: heap.c:2031
struct CookedConstraint CookedConstraint
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
Definition: heap.c:581
Definition: nodes.h:529
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
OnCommitAction
Definition: primnodes.h:47
signed int int32
Definition: c.h:355
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1854
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
Definition: heap.c:2160
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3398
AttrNumber attnum
Definition: heap.h:40
NameData attname
Definition: pg_attribute.h:40
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3658
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
Definition: heap.c:2523
bool missingMode
Definition: heap.h:31
struct RawColumnDefault RawColumnDefault
Oid attcollation
Definition: pg_attribute.h:157
int inhcount
Definition: heap.h:44
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
Definition: heap.c:1726
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:1099
void SetAttrMissing(Oid relid, char *attname, char *value)
Definition: heap.c:2099
char generated
Definition: heap.h:32
Node * raw_default
Definition: heap.h:30
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3526
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:294
bool skip_validation
Definition: heap.h:42
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
Definition: heap.c:489
void heap_truncate(List *relids)
Definition: heap.c:3218
ConstrType contype
Definition: heap.h:37
void InsertPgAttributeTuple(Relation pg_attribute_rel, Form_pg_attribute new_attribute, Datum attoptions, CatalogIndexState indstate)
Definition: heap.c:726
Oid atttypid
Definition: pg_attribute.h:49
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1535
DropBehavior
Definition: parsenodes.h:1764
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:3006
FormData_pg_attribute
Definition: pg_attribute.h:177
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
Definition: heap.c:261
static struct @143 value
TransactionId MultiXactId
Definition: c.h:523
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
Definition: heap.c:249
void RemoveAttrDefaultById(Oid attrdefId)
Definition: heap.c:1781
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:3303
Oid conoid
Definition: heap.h:38
Node * expr
Definition: heap.h:41
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1506
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:882
int16 AttrNumber
Definition: attnum.h:21
char * name
Definition: heap.h:39
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:3259
bool is_local
Definition: heap.h:43