]> granicus.if.org Git - postgresql/blob - src/include/catalog/heap.h
When converting a table to a view, remove its system columns.
[postgresql] / 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-2012, 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            skip_validation;        /* skip validation? (only for CHECK) */
34         bool            is_local;               /* constraint has local (non-inherited) def */
35         int                     inhcount;               /* number of times constraint is inherited */
36         bool            is_no_inherit;  /* constraint has local def and cannot be
37                                                                  * inherited */
38 } CookedConstraint;
39
40 extern Relation heap_create(const char *relname,
41                         Oid relnamespace,
42                         Oid reltablespace,
43                         Oid relid,
44                         Oid relfilenode,
45                         TupleDesc tupDesc,
46                         char relkind,
47                         char relpersistence,
48                         bool shared_relation,
49                         bool mapped_relation);
50
51 extern Oid heap_create_with_catalog(const char *relname,
52                                                  Oid relnamespace,
53                                                  Oid reltablespace,
54                                                  Oid relid,
55                                                  Oid reltypeid,
56                                                  Oid reloftypeid,
57                                                  Oid ownerid,
58                                                  TupleDesc tupdesc,
59                                                  List *cooked_constraints,
60                                                  char relkind,
61                                                  char relpersistence,
62                                                  bool shared_relation,
63                                                  bool mapped_relation,
64                                                  bool oidislocal,
65                                                  int oidinhcount,
66                                                  OnCommitAction oncommit,
67                                                  Datum reloptions,
68                                                  bool use_user_acl,
69                                                  bool allow_system_table_mods,
70                                                  bool is_internal);
71
72 extern void heap_create_init_fork(Relation rel);
73
74 extern void heap_drop_with_catalog(Oid relid);
75
76 extern void heap_truncate(List *relids);
77
78 extern void heap_truncate_one_rel(Relation rel);
79
80 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
81
82 extern List *heap_truncate_find_FKs(List *relationIds);
83
84 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
85                                            Form_pg_attribute new_attribute,
86                                            CatalogIndexState indstate);
87
88 extern void InsertPgClassTuple(Relation pg_class_desc,
89                                    Relation new_rel_desc,
90                                    Oid new_rel_oid,
91                                    Datum relacl,
92                                    Datum reloptions);
93
94 extern List *AddRelationNewConstraints(Relation rel,
95                                                   List *newColDefaults,
96                                                   List *newConstraints,
97                                                   bool allow_merge,
98                                                   bool is_local);
99
100 extern void StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr);
101
102 extern Node *cookDefault(ParseState *pstate,
103                         Node *raw_default,
104                         Oid atttypid,
105                         int32 atttypmod,
106                         char *attname);
107
108 extern void DeleteRelationTuple(Oid relid);
109 extern void DeleteAttributeTuples(Oid relid);
110 extern void DeleteSystemAttributeTuples(Oid relid);
111 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
112 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
113                                   DropBehavior behavior, bool complain, bool internal);
114 extern void RemoveAttrDefaultById(Oid attrdefId);
115 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
116
117 extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
118                                                   bool relhasoids);
119
120 extern Form_pg_attribute SystemAttributeByName(const char *attname,
121                                           bool relhasoids);
122
123 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
124                                                  bool allow_system_table_mods);
125
126 extern void CheckAttributeType(const char *attname,
127                                    Oid atttypid, Oid attcollation,
128                                    List *containing_rowtypes,
129                                    bool allow_system_table_mods);
130
131 #endif   /* HEAP_H */