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-2022, 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  bool create_storage);
64 
65 extern Oid heap_create_with_catalog(const char *relname,
66  Oid relnamespace,
67  Oid reltablespace,
68  Oid relid,
69  Oid reltypeid,
70  Oid reloftypeid,
71  Oid ownerid,
72  Oid accessmtd,
73  TupleDesc tupdesc,
74  List *cooked_constraints,
75  char relkind,
76  char relpersistence,
77  bool shared_relation,
78  bool mapped_relation,
79  OnCommitAction oncommit,
80  Datum reloptions,
81  bool use_user_acl,
82  bool allow_system_table_mods,
83  bool is_internal,
84  Oid relrewrite,
85  ObjectAddress *typaddress);
86 
87 extern void heap_drop_with_catalog(Oid relid);
88 
89 extern void heap_truncate(List *relids);
90 
91 extern void heap_truncate_one_rel(Relation rel);
92 
93 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
94 
95 extern List *heap_truncate_find_FKs(List *relationIds);
96 
97 extern void InsertPgAttributeTuples(Relation pg_attribute_rel,
98  TupleDesc tupdesc,
99  Oid new_rel_oid,
100  Datum *attoptions,
101  CatalogIndexState indstate);
102 
103 extern void InsertPgClassTuple(Relation pg_class_desc,
104  Relation new_rel_desc,
105  Oid new_rel_oid,
106  Datum relacl,
107  Datum reloptions);
108 
110  List *newColDefaults,
111  List *newConstraints,
112  bool allow_merge,
113  bool is_local,
114  bool is_internal,
115  const char *queryString);
116 
117 extern void RelationClearMissing(Relation rel);
118 extern void SetAttrMissing(Oid relid, char *attname, char *value);
119 
121  Node *expr, bool is_internal,
122  bool add_column_mode);
123 
124 extern Node *cookDefault(ParseState *pstate,
125  Node *raw_default,
126  Oid atttypid,
127  int32 atttypmod,
128  const char *attname,
129  char attgenerated);
130 
131 extern void DeleteRelationTuple(Oid relid);
132 extern void DeleteAttributeTuples(Oid relid);
133 extern void DeleteSystemAttributeTuples(Oid relid);
134 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
135 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
136  DropBehavior behavior, bool complain, bool internal);
137 extern void RemoveAttrDefaultById(Oid attrdefId);
138 extern void CopyStatistics(Oid fromrelid, Oid torelid);
139 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
140 
142 
143 extern const FormData_pg_attribute *SystemAttributeByName(const char *attname);
144 
145 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
146  int flags);
147 
148 extern void CheckAttributeType(const char *attname,
149  Oid atttypid, Oid attcollation,
150  List *containing_rowtypes,
151  int flags);
152 
153 /* pg_partitioned_table catalog manipulation functions */
154 extern void StorePartitionKey(Relation rel,
155  char strategy,
156  int16 partnatts,
157  AttrNumber *partattrs,
158  List *partexprs,
159  Oid *partopclass,
160  Oid *partcollation);
161 extern void RemovePartitionKeyByRelId(Oid relid);
162 extern void StorePartitionBound(Relation rel, Relation parent,
163  PartitionBoundSpec *bound);
164 
165 #endif /* HEAP_H */
int16 AttrNumber
Definition: attnum.h:21
signed short int16
Definition: c.h:428
signed int int32
Definition: c.h:429
TransactionId MultiXactId
Definition: c.h:597
uint32 TransactionId
Definition: c.h:587
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1654
void RelationClearMissing(Relation rel)
Definition: heap.c:2072
struct CookedConstraint CookedConstraint
void SetAttrMissing(Oid relid, char *attname, char *value)
Definition: heap.c:2140
void InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, Datum *attoptions, CatalogIndexState indstate)
Definition: heap.c:708
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1613
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3631
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3503
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1547
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1576
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:3228
void RemoveAttrDefaultById(Oid attrdefId)
Definition: heap.c:1822
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:1102
void heap_truncate(List *relids)
Definition: heap.c:3323
struct RawColumnDefault RawColumnDefault
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
Definition: heap.c:558
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
Definition: heap.c:253
void CopyStatistics(Oid fromrelid, Oid torelid)
Definition: heap.c:3183
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
Definition: heap.c:3070
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:3408
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, bool create_storage)
Definition: heap.c:302
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3789
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1895
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
Definition: heap.c:2208
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
Definition: heap.c:893
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
Definition: heap.c:466
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:3364
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3758
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
Definition: heap.c:265
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
Definition: heap.c:1767
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
Definition: heap.c:2576
static struct @142 value
ConstrType
Definition: parsenodes.h:2231
DropBehavior
Definition: parsenodes.h:1860
FormData_pg_attribute
Definition: pg_attribute.h:191
NameData attname
Definition: pg_attribute.h:41
int16 attnum
Definition: pg_attribute.h:83
NameData relname
Definition: pg_class.h:38
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
OnCommitAction
Definition: primnodes.h:48
Oid conoid
Definition: heap.h:38
char * name
Definition: heap.h:39
AttrNumber attnum
Definition: heap.h:40
bool skip_validation
Definition: heap.h:42
bool is_no_inherit
Definition: heap.h:45
int inhcount
Definition: heap.h:44
bool is_local
Definition: heap.h:43
ConstrType contype
Definition: heap.h:37
Node * expr
Definition: heap.h:41
Definition: pg_list.h:51
Definition: nodes.h:540
Node * raw_default
Definition: heap.h:30
AttrNumber attnum
Definition: heap.h:29
char generated
Definition: heap.h:32
bool missingMode
Definition: heap.h:31