1 /*-------------------------------------------------------------------------
4 * prototypes for functions in backend/catalog/heap.c
7 * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/catalog/heap.h
12 *-------------------------------------------------------------------------
17 #include "parser/parse_node.h"
18 #include "catalog/indexing.h"
21 typedef struct RawColumnDefault
23 AttrNumber attnum; /* attribute to attach default to */
24 Node *raw_default; /* default value (untransformed parse tree) */
27 typedef struct CookedConstraint
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
40 extern Relation heap_create(const char *relname,
49 bool mapped_relation);
51 extern Oid heap_create_with_catalog(const char *relname,
59 List *cooked_constraints,
66 OnCommitAction oncommit,
69 bool allow_system_table_mods,
72 extern void heap_create_init_fork(Relation rel);
74 extern void heap_drop_with_catalog(Oid relid);
76 extern void heap_truncate(List *relids);
78 extern void heap_truncate_one_rel(Relation rel);
80 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
82 extern List *heap_truncate_find_FKs(List *relationIds);
84 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
85 Form_pg_attribute new_attribute,
86 CatalogIndexState indstate);
88 extern void InsertPgClassTuple(Relation pg_class_desc,
89 Relation new_rel_desc,
94 extern List *AddRelationNewConstraints(Relation rel,
100 extern void StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr);
102 extern Node *cookDefault(ParseState *pstate,
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);
117 extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
120 extern Form_pg_attribute SystemAttributeByName(const char *attname,
123 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
124 bool allow_system_table_mods);
126 extern void CheckAttributeType(const char *attname,
127 Oid atttypid, Oid attcollation,
128 List *containing_rowtypes,
129 bool allow_system_table_mods);