1 /*-------------------------------------------------------------------------
4 * prototypes for functions in backend/catalog/heap.c
7 * Portions Copyright (c) 1996-2014, 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,
50 bool allow_system_table_mods);
52 extern Oid heap_create_with_catalog(const char *relname,
60 List *cooked_constraints,
67 OnCommitAction oncommit,
70 bool allow_system_table_mods,
73 extern void heap_create_init_fork(Relation rel);
75 extern void heap_drop_with_catalog(Oid relid);
77 extern void heap_truncate(List *relids);
79 extern void heap_truncate_one_rel(Relation rel);
81 extern void heap_truncate_check_FKs(List *relations, bool tempTables);
83 extern List *heap_truncate_find_FKs(List *relationIds);
85 extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
86 Form_pg_attribute new_attribute,
87 CatalogIndexState indstate);
89 extern void InsertPgClassTuple(Relation pg_class_desc,
90 Relation new_rel_desc,
95 extern List *AddRelationNewConstraints(Relation rel,
102 extern void StoreAttrDefault(Relation rel, AttrNumber attnum,
103 Node *expr, bool is_internal);
105 extern Node *cookDefault(ParseState *pstate,
111 extern void DeleteRelationTuple(Oid relid);
112 extern void DeleteAttributeTuples(Oid relid);
113 extern void DeleteSystemAttributeTuples(Oid relid);
114 extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
115 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
116 DropBehavior behavior, bool complain, bool internal);
117 extern void RemoveAttrDefaultById(Oid attrdefId);
118 extern void RemoveStatistics(Oid relid, AttrNumber attnum);
120 extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
123 extern Form_pg_attribute SystemAttributeByName(const char *attname,
126 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
127 bool allow_system_table_mods);
129 extern void CheckAttributeType(const char *attname,
130 Oid atttypid, Oid attcollation,
131 List *containing_rowtypes,
132 bool allow_system_table_mods);