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-2017, 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) */
27 
28 typedef struct CookedConstraint
29 {
30  ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
31  Oid conoid; /* constr OID if created, otherwise Invalid */
32  char *name; /* name, or NULL if none */
33  AttrNumber attnum; /* which attr (only for DEFAULT) */
34  Node *expr; /* transformed default or check expr */
35  bool skip_validation; /* skip validation? (only for CHECK) */
36  bool is_local; /* constraint has local (non-inherited) def */
37  int inhcount; /* number of times constraint is inherited */
38  bool is_no_inherit; /* constraint has local def and cannot be
39  * inherited */
41 
42 extern Relation heap_create(const char *relname,
43  Oid relnamespace,
44  Oid reltablespace,
45  Oid relid,
46  Oid relfilenode,
47  TupleDesc tupDesc,
48  char relkind,
49  char relpersistence,
50  bool shared_relation,
51  bool mapped_relation,
52  bool allow_system_table_mods);
53 
54 extern Oid heap_create_with_catalog(const char *relname,
55  Oid relnamespace,
56  Oid reltablespace,
57  Oid relid,
58  Oid reltypeid,
59  Oid reloftypeid,
60  Oid ownerid,
61  TupleDesc tupdesc,
62  List *cooked_constraints,
63  char relkind,
64  char relpersistence,
65  bool shared_relation,
66  bool mapped_relation,
67  bool oidislocal,
68  int oidinhcount,
69  OnCommitAction oncommit,
70  Datum reloptions,
71  bool use_user_acl,
72  bool allow_system_table_mods,
73  bool is_internal,
74  ObjectAddress *typaddress);
75 
76 extern void heap_create_init_fork(Relation rel);
77 
78 extern void heap_drop_with_catalog(Oid relid);
79 
80 extern void heap_truncate(List *relids);
81 
82 extern void heap_truncate_one_rel(Relation rel);
83 
84 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
85 
86 extern List *heap_truncate_find_FKs(List *relationIds);
87 
88 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
89  Form_pg_attribute new_attribute,
90  CatalogIndexState indstate);
91 
92 extern void InsertPgClassTuple(Relation pg_class_desc,
93  Relation new_rel_desc,
94  Oid new_rel_oid,
95  Datum relacl,
96  Datum reloptions);
97 
99  List *newColDefaults,
100  List *newConstraints,
101  bool allow_merge,
102  bool is_local,
103  bool is_internal);
104 
106  Node *expr, bool is_internal);
107 
108 extern Node *cookDefault(ParseState *pstate,
109  Node *raw_default,
110  Oid atttypid,
111  int32 atttypmod,
112  const char *attname);
113 
114 extern void DeleteRelationTuple(Oid relid);
115 extern void DeleteAttributeTuples(Oid relid);
116 extern void DeleteSystemAttributeTuples(Oid relid);
117 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
118 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
119  DropBehavior behavior, bool complain, bool internal);
120 extern void RemoveAttrDefaultById(Oid attrdefId);
121 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
122 
124  bool relhasoids);
125 
126 extern Form_pg_attribute SystemAttributeByName(const char *attname,
127  bool relhasoids);
128 
129 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
130  bool allow_system_table_mods);
131 
132 extern void CheckAttributeType(const char *attname,
133  Oid atttypid, Oid attcollation,
134  List *containing_rowtypes,
135  bool allow_system_table_mods);
136 
137 /* pg_partitioned_table catalog manipulation functions */
138 extern void StorePartitionKey(Relation rel,
139  char strategy,
140  int16 partnatts,
141  AttrNumber *partattrs,
142  List *partexprs,
143  Oid *partopclass,
144  Oid *partcollation);
145 extern void RemovePartitionKeyByRelId(Oid relid);
146 extern void StorePartitionBound(Relation rel, Relation parent,
147  PartitionBoundSpec *bound);
148 
149 #endif /* HEAP_H */
signed short int16
Definition: c.h:293
ConstrType
Definition: parsenodes.h:2059
void RemoveStatistics(Oid relid, AttrNumber attnum)
Definition: heap.c:2772
bool is_no_inherit
Definition: heap.h:38
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
Definition: heap.c:3254
void DeleteSystemAttributeTuples(Oid relid)
Definition: heap.c:1502
void RemoveAttributeById(Oid relid, AttrNumber attnum)
Definition: heap.c:1543
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, ObjectAddress *typaddress)
Definition: heap.c:1021
AttrNumber attnum
Definition: heap.h:24
struct CookedConstraint CookedConstraint
Definition: nodes.h:512
unsigned int Oid
Definition: postgres_ext.h:31
OnCommitAction
Definition: primnodes.h:47
signed int int32
Definition: c.h:294
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, bool allow_system_table_mods)
Definition: heap.c:410
void heap_drop_with_catalog(Oid relid)
Definition: heap.c:1758
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, bool allow_system_table_mods)
Definition: heap.c:490
List * heap_truncate_find_FKs(List *relationIds)
Definition: heap.c:3030
AttrNumber attnum
Definition: heap.h:33
void RemovePartitionKeyByRelId(Oid relid)
Definition: heap.c:3226
Form_pg_attribute SystemAttributeByName(const char *attname, bool relhasoids)
Definition: heap.c:214
struct RawColumnDefault RawColumnDefault
int inhcount
Definition: heap.h:37
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
Definition: heap.c:1631
Node * raw_default
Definition: heap.h:25
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
Definition: heap.c:3114
bool skip_validation
Definition: heap.h:35
void heap_truncate(List *relids)
Definition: heap.c:2860
ConstrType contype
Definition: heap.h:30
void DeleteAttributeTuples(Oid relid)
Definition: heap.c:1465
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal)
Definition: heap.c:2229
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname)
Definition: heap.c:2659
void InsertPgAttributeTuple(Relation pg_attribute_rel, Form_pg_attribute new_attribute, CatalogIndexState indstate)
Definition: heap.c:600
DropBehavior
Definition: parsenodes.h:1686
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:250
uintptr_t Datum
Definition: postgres.h:372
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal)
Definition: heap.c:1929
void RemoveAttrDefaultById(Oid attrdefId)
Definition: heap.c:1685
void heap_truncate_check_FKs(List *relations, bool tempTables)
Definition: heap.c:2938
Oid conoid
Definition: heap.h:31
Node * expr
Definition: heap.h:34
void heap_create_init_fork(Relation rel)
Definition: heap.c:1382
Form_pg_attribute SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
Definition: heap.c:200
void DeleteRelationTuple(Oid relid)
Definition: heap.c:1436
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:766
int16 AttrNumber
Definition: attnum.h:21
char * name
Definition: heap.h:32
void heap_truncate_one_rel(Relation rel)
Definition: heap.c:2901
bool is_local
Definition: heap.h:36