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-2018, 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 typedef struct RawColumnDefault
23 {
24  AttrNumber attnum; /* attribute to attach default to */
25  Node *raw_default; /* default value (untransformed parse tree) */
26  bool missingMode; /* true if part of add column processing */
28 
29 typedef struct CookedConstraint
30 {
31  ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
32  Oid conoid; /* constr OID if created, otherwise Invalid */
33  char *name; /* name, or NULL if none */
34  AttrNumber attnum; /* which attr (only for DEFAULT) */
35  Node *expr; /* transformed default or check expr */
36  bool skip_validation; /* skip validation? (only for CHECK) */
37  bool is_local; /* constraint has local (non-inherited) def */
38  int inhcount; /* number of times constraint is inherited */
39  bool is_no_inherit; /* constraint has local def and cannot be
40  * inherited */
42 
43 extern Relation heap_create(const char *relname,
46  Oid relid,
48  TupleDesc tupDesc,
49  char relkind,
50  char relpersistence,
51  bool shared_relation,
52  bool mapped_relation,
53  bool allow_system_table_mods);
54 
55 extern Oid heap_create_with_catalog(const char *relname,
58  Oid relid,
59  Oid reltypeid,
60  Oid reloftypeid,
61  Oid ownerid,
62  TupleDesc tupdesc,
63  List *cooked_constraints,
64  char relkind,
65  char relpersistence,
66  bool shared_relation,
67  bool mapped_relation,
68  bool oidislocal,
69  int oidinhcount,
70  OnCommitAction oncommit,
71  Datum reloptions,
72  bool use_user_acl,
73  bool allow_system_table_mods,
74  bool is_internal,
76  ObjectAddress *typaddress);
77 
78 extern void heap_create_init_fork(Relation rel);
79 
80 extern void heap_drop_with_catalog(Oid relid);
81 
82 extern void heap_truncate(List *relids);
83 
84 extern void heap_truncate_one_rel(Relation rel);
85 
86 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
87 
88 extern List *heap_truncate_find_FKs(List *relationIds);
89 
90 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
91  Form_pg_attribute new_attribute,
92  CatalogIndexState indstate);
93 
94 extern void InsertPgClassTuple(Relation pg_class_desc,
95  Relation new_rel_desc,
96  Oid new_rel_oid,
97  Datum relacl,
98  Datum reloptions);
99 
101  List *newColDefaults,
102  List *newConstraints,
103  bool allow_merge,
104  bool is_local,
105  bool is_internal);
106 
107 extern void RelationClearMissing(Relation rel);
108 
110  Node *expr, bool is_internal,
111  bool add_column_mode);
112 
113 extern Node *cookDefault(ParseState *pstate,
114  Node *raw_default,
115  Oid atttypid,
116  int32 atttypmod,
117  const char *attname);
118 
119 extern void DeleteRelationTuple(Oid relid);
120 extern void DeleteAttributeTuples(Oid relid);
121 extern void DeleteSystemAttributeTuples(Oid relid);
122 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
123 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
124  DropBehavior behavior, bool complain, bool internal);
125 extern void RemoveAttrDefaultById(Oid attrdefId);
126 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
127 
129  bool relhasoids);
130 
132  bool relhasoids);
133 
134 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
135  bool allow_system_table_mods);
136 
137 extern void CheckAttributeType(const char *attname,
139  List *containing_rowtypes,
140  bool allow_system_table_mods);
141 
142 /* pg_partitioned_table catalog manipulation functions */
143 extern void StorePartitionKey(Relation rel,
144  char strategy,
145  int16 partnatts,
146  AttrNumber *partattrs,
147  List *partexprs,
148  Oid *partopclass,
149  Oid *partcollation);
150 extern void RemovePartitionKeyByRelId(Oid relid);
151 extern void StorePartitionBound(Relation rel, Relation parent,
152  PartitionBoundSpec *bound);
153 
154 #endif /* HEAP_H */
bool relhasoids
Definition: pg_class.h:60
signed short int16
Definition: c.h:312
ConstrType
Definition: parsenodes.h:2059
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:2928
Oid relnamespace
Definition: pg_class.h:32
bool is_no_inherit
Definition: heap.h:39
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3413
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1511
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1552
AttrNumber attnum
Definition: heap.h:24
void RelationClearMissing(Relation rel)
Definition: heap.c:1944
struct CookedConstraint CookedConstraint
Definition: nodes.h:517
unsigned int Oid
Definition: postgres_ext.h:31
OnCommitAction
Definition: primnodes.h:48
char relkind
Definition: pg_class.h:51
signed int int32
Definition: c.h:313
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, bool allow_system_table_mods)
Definition: heap.c:414
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1767
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, bool allow_system_table_mods)
Definition: heap.c:494
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
Definition: heap.c:2016
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3186
AttrNumber attnum
Definition: heap.h:34
NameData attname
Definition: pg_attribute.h:40
char relpersistence
Definition: pg_class.h:50
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3382
Form_pg_attribute SystemAttributeByName(const char *attname, bool relhasoids)
Definition: heap.c:217
Oid relfilenode
Definition: pg_class.h:39
bool missingMode
Definition: heap.h:26
struct RawColumnDefault RawColumnDefault
Oid attcollation
Definition: pg_attribute.h:161
int inhcount
Definition: heap.h:38
Oid reltablespace
Definition: pg_class.h:42
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
Definition: heap.c:1640
Node * raw_default
Definition: heap.h:25
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:197
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3270
bool skip_validation
Definition: heap.h:36
void heap_truncate(List *relids)
Definition: heap.c:3016
ConstrType contype
Definition: heap.h:31
Oid relrewrite
Definition: pg_class.h:70
Oid atttypid
Definition: pg_attribute.h:49
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1474
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal)
Definition: heap.c:2379
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname)
Definition: heap.c:2815
void InsertPgAttributeTuple(Relation pg_attribute_rel, Form_pg_attribute new_attribute, CatalogIndexState indstate)
Definition: heap.c:604
DropBehavior
Definition: parsenodes.h:1705
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid relfilenode, TupleDesc tupDesc, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, bool allow_system_table_mods)
Definition: heap.c:253
uintptr_t Datum
Definition: postgres.h:365
void RemoveAttrDefaultById(Oid attrdefId)
Definition: heap.c:1694
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:3094
Oid conoid
Definition: heap.h:32
Node * expr
Definition: heap.h:35
void heap_create_init_fork(Relation rel)
Definition: heap.c:1391
Form_pg_attribute SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
Definition: heap.c:203
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1445
Definition: pg_list.h:45
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
Definition: heap.c:772
int16 AttrNumber
Definition: attnum.h:21
char * name
Definition: heap.h:33
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:3057
bool is_local
Definition: heap.h:37
Oid heap_create_with_catalog(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid reltypeid, Oid reloftypeid, Oid ownerid, TupleDesc tupdesc, List *cooked_constraints, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, bool oidislocal, int oidinhcount, OnCommitAction oncommit, Datum reloptions, bool use_user_acl, bool allow_system_table_mods, bool is_internal, Oid relrewrite, ObjectAddress *typaddress)
Definition: heap.c:1027