OSDN Git Service

Refactor broken CREATE TABLE IF NOT EXISTS support.
[pg-rex/syncrep.git] / src / include / catalog / heap.h
1 /*-------------------------------------------------------------------------
2  *
3  * heap.h
4  *        prototypes for functions in backend/catalog/heap.c
5  *
6  *
7  * Portions Copyright (c) 1996-2011, 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 "parser/parse_node.h"
18 #include "catalog/indexing.h"
19
20
21 typedef struct RawColumnDefault
22 {
23         AttrNumber      attnum;                 /* attribute to attach default to */
24         Node       *raw_default;        /* default value (untransformed parse tree) */
25 } RawColumnDefault;
26
27 typedef struct CookedConstraint
28 {
29         ConstrType      contype;                /* CONSTR_DEFAULT or CONSTR_CHECK */
30         char       *name;                       /* name, or NULL if none */
31         AttrNumber      attnum;                 /* which attr (only for DEFAULT) */
32         Node       *expr;                       /* transformed default or check expr */
33         bool            is_local;               /* constraint has local (non-inherited) def */
34         int                     inhcount;               /* number of times constraint is inherited */
35 } CookedConstraint;
36
37 extern Relation heap_create(const char *relname,
38                         Oid relnamespace,
39                         Oid reltablespace,
40                         Oid relid,
41                         TupleDesc tupDesc,
42                         char relkind,
43                         char relpersistence,
44                         bool shared_relation,
45                         bool mapped_relation,
46                         bool allow_system_table_mods);
47
48 extern Oid heap_create_with_catalog(const char *relname,
49                                                  Oid relnamespace,
50                                                  Oid reltablespace,
51                                                  Oid relid,
52                                                  Oid reltypeid,
53                                                  Oid reloftypeid,
54                                                  Oid ownerid,
55                                                  TupleDesc tupdesc,
56                                                  List *cooked_constraints,
57                                                  char relkind,
58                                                  char relpersistence,
59                                                  bool shared_relation,
60                                                  bool mapped_relation,
61                                                  bool oidislocal,
62                                                  int oidinhcount,
63                                                  OnCommitAction oncommit,
64                                                  Datum reloptions,
65                                                  bool use_user_acl,
66                                                  bool allow_system_table_mods);
67
68 extern void heap_drop_with_catalog(Oid relid);
69
70 extern void heap_truncate(List *relids);
71
72 extern void heap_truncate_one_rel(Relation rel);
73
74 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
75
76 extern List *heap_truncate_find_FKs(List *relationIds);
77
78 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
79                                            Form_pg_attribute new_attribute,
80                                            CatalogIndexState indstate);
81
82 extern void InsertPgClassTuple(Relation pg_class_desc,
83                                    Relation new_rel_desc,
84                                    Oid new_rel_oid,
85                                    Datum relacl,
86                                    Datum reloptions);
87
88 extern List *AddRelationNewConstraints(Relation rel,
89                                                   List *newColDefaults,
90                                                   List *newConstraints,
91                                                   bool allow_merge,
92                                                   bool is_local);
93
94 extern void StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr);
95
96 extern Node *cookDefault(ParseState *pstate,
97                         Node *raw_default,
98                         Oid atttypid,
99                         int32 atttypmod,
100                         char *attname);
101
102 extern void DeleteRelationTuple(Oid relid);
103 extern void DeleteAttributeTuples(Oid relid);
104 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
105 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
106                                   DropBehavior behavior, bool complain);
107 extern void RemoveAttrDefaultById(Oid attrdefId);
108 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
109
110 extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
111                                                   bool relhasoids);
112
113 extern Form_pg_attribute SystemAttributeByName(const char *attname,
114                                           bool relhasoids);
115
116 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
117                                                  bool allow_system_table_mods);
118
119 extern void CheckAttributeType(const char *attname,
120                                    Oid atttypid, Oid attcollation,
121                                    List *containing_rowtypes,
122                                    bool allow_system_table_mods);
123
124 #endif   /* HEAP_H */