PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2024, 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, CONSTR_CHECK,
38  * CONSTR_NOTNULL */
39  Oid conoid; /* constr OID if created, otherwise Invalid */
40  char *name; /* name, or NULL if none */
41  AttrNumber attnum; /* which attr (only for NOTNULL, DEFAULT) */
42  Node *expr; /* transformed default or check expr */
43  bool skip_validation; /* skip validation? (only for CHECK) */
44  bool is_local; /* constraint has local (non-inherited) def */
45  int16 inhcount; /* number of times constraint is inherited */
46  bool is_no_inherit; /* constraint has local def and cannot be
47  * inherited */
49 
50 extern Relation heap_create(const char *relname,
51  Oid relnamespace,
52  Oid reltablespace,
53  Oid relid,
54  RelFileNumber relfilenumber,
55  Oid accessmtd,
56  TupleDesc tupDesc,
57  char relkind,
58  char relpersistence,
59  bool shared_relation,
60  bool mapped_relation,
61  bool allow_system_table_mods,
62  TransactionId *relfrozenxid,
63  MultiXactId *relminmxid,
64  bool create_storage);
65 
66 extern Oid heap_create_with_catalog(const char *relname,
67  Oid relnamespace,
68  Oid reltablespace,
69  Oid relid,
70  Oid reltypeid,
71  Oid reloftypeid,
72  Oid ownerid,
73  Oid accessmtd,
74  TupleDesc tupdesc,
75  List *cooked_constraints,
76  char relkind,
77  char relpersistence,
78  bool shared_relation,
79  bool mapped_relation,
80  OnCommitAction oncommit,
81  Datum reloptions,
82  bool use_user_acl,
83  bool allow_system_table_mods,
84  bool is_internal,
85  Oid relrewrite,
86  ObjectAddress *typaddress);
87 
88 extern void heap_drop_with_catalog(Oid relid);
89 
90 extern void heap_truncate(List *relids);
91 
92 extern void heap_truncate_one_rel(Relation rel);
93 
94 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
95 
96 extern List *heap_truncate_find_FKs(List *relationIds);
97 
98 extern void InsertPgAttributeTuples(Relation pg_attribute_rel,
99  TupleDesc tupdesc,
100  Oid new_rel_oid,
101  const FormExtraData_pg_attribute tupdesc_extra[],
102  CatalogIndexState indstate);
103 
104 extern void InsertPgClassTuple(Relation pg_class_desc,
105  Relation new_rel_desc,
106  Oid new_rel_oid,
107  Datum relacl,
108  Datum reloptions);
109 
111  List *newColDefaults,
112  List *newConstraints,
113  bool allow_merge,
114  bool is_local,
115  bool is_internal,
116  const char *queryString);
118  List *constraints,
119  List *old_notnulls);
120 
121 extern void RelationClearMissing(Relation rel);
122 extern void SetAttrMissing(Oid relid, char *attname, char *value);
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 
136 extern void CopyStatistics(Oid fromrelid, Oid torelid);
137 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
138 
140 
141 extern const FormData_pg_attribute *SystemAttributeByName(const char *attname);
142 
143 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
144  int flags);
145 
146 extern void CheckAttributeType(const char *attname,
147  Oid atttypid, Oid attcollation,
148  List *containing_rowtypes,
149  int flags);
150 
151 /* pg_partitioned_table catalog manipulation functions */
152 extern void StorePartitionKey(Relation rel,
153  char strategy,
154  int16 partnatts,
155  AttrNumber *partattrs,
156  List *partexprs,
157  Oid *partopclass,
158  Oid *partcollation);
159 extern void RemovePartitionKeyByRelId(Oid relid);
160 extern void StorePartitionBound(Relation rel, Relation parent,
161  PartitionBoundSpec *bound);
162 
163 #endif /* HEAP_H */
int16 AttrNumber
Definition: attnum.h:21
signed short int16
Definition: c.h:481
signed int int32
Definition: c.h:482
TransactionId MultiXactId
Definition: c.h:641
uint32 TransactionId
Definition: c.h:631
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1666
void RelationClearMissing(Relation rel)
Definition: heap.c:1947
struct CookedConstraint CookedConstraint
void SetAttrMissing(Oid relid, char *attname, char *value)
Definition: heap.c:2015
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1625
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3713
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3586
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1559
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1588
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:3311
List * AddRelationNotNullConstraints(Relation rel, List *constraints, List *old_notnulls)
Definition: heap.c:2797
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:1105
void heap_truncate(List *relids)
Definition: heap.c:3406
struct RawColumnDefault RawColumnDefault
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
Definition: heap.c:548
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
Definition: heap.c:240
void CopyStatistics(Oid fromrelid, Oid torelid)
Definition: heap.c:3258
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
Definition: heap.c:3143
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:3491
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3869
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1767
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
Definition: heap.c:896
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
Definition: heap.c:456
void InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, const FormExtraData_pg_attribute tupdesc_extra[], CatalogIndexState indstate)
Definition: heap.c:702
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:3447
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3838
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
Definition: heap.c:252
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, RelFileNumber relfilenumber, 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:289
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
Definition: heap.c:2319
static struct @160 value
ConstrType
Definition: parsenodes.h:2723
FormData_pg_attribute
Definition: pg_attribute.h:193
NameData attname
Definition: pg_attribute.h:41
int16 attnum
Definition: pg_attribute.h:74
NameData relname
Definition: pg_class.h:38
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
OnCommitAction
Definition: primnodes.h:56
Oid RelFileNumber
Definition: relpath.h:25
Oid conoid
Definition: heap.h:39
char * name
Definition: heap.h:40
AttrNumber attnum
Definition: heap.h:41
bool skip_validation
Definition: heap.h:43
bool is_no_inherit
Definition: heap.h:46
int16 inhcount
Definition: heap.h:45
bool is_local
Definition: heap.h:44
ConstrType contype
Definition: heap.h:37
Node * expr
Definition: heap.h:42
Definition: pg_list.h:54
Definition: nodes.h:129
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