1 /*------------------------------------------------------------------------- 2 * 3 * heap.h 4 * prototypes for functions in backend/catalog/heap.c 5 * 6 * 7 * Portions Copyright (c) 1996-2018, 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) */ 26 bool missingMode; /* true if part of add column processing */ 27 } RawColumnDefault; 28 29 typedef struct CookedConstraint 30 { 31 ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */ 32 Oid conoid; /* constr OID if created, otherwise Invalid */ 33 char *name; /* name, or NULL if none */ 34 AttrNumber attnum; /* which attr (only for DEFAULT) */ 35 Node *expr; /* transformed default or check expr */ 36 bool skip_validation; /* skip validation? (only for CHECK) */ 37 bool is_local; /* constraint has local (non-inherited) def */ 38 int inhcount; /* number of times constraint is inherited */ 39 bool is_no_inherit; /* constraint has local def and cannot be 40 * inherited */ 41 } CookedConstraint; 42 43 extern Relation heap_create(const char *relname, 44 Oid relnamespace, 45 Oid reltablespace, 46 Oid relid, 47 Oid relfilenode, 48 TupleDesc tupDesc, 49 char relkind, 50 char relpersistence, 51 bool shared_relation, 52 bool mapped_relation, 53 bool allow_system_table_mods); 54 55 extern Oid heap_create_with_catalog(const char *relname, 56 Oid relnamespace, 57 Oid reltablespace, 58 Oid relid, 59 Oid reltypeid, 60 Oid reloftypeid, 61 Oid ownerid, 62 TupleDesc tupdesc, 63 List *cooked_constraints, 64 char relkind, 65 char relpersistence, 66 bool shared_relation, 67 bool mapped_relation, 68 bool oidislocal, 69 int oidinhcount, 70 OnCommitAction oncommit, 71 Datum reloptions, 72 bool use_user_acl, 73 bool allow_system_table_mods, 74 bool is_internal, 75 Oid relrewrite, 76 ObjectAddress *typaddress); 77 78 extern void heap_create_init_fork(Relation rel); 79 80 extern void heap_drop_with_catalog(Oid relid); 81 82 extern void heap_truncate(List *relids); 83 84 extern void heap_truncate_one_rel(Relation rel); 85 86 extern void heap_truncate_check_FKs(List *relations, bool tempTables); 87 88 extern List *heap_truncate_find_FKs(List *relationIds); 89 90 extern void InsertPgAttributeTuple(Relation pg_attribute_rel, 91 Form_pg_attribute new_attribute, 92 CatalogIndexState indstate); 93 94 extern void InsertPgClassTuple(Relation pg_class_desc, 95 Relation new_rel_desc, 96 Oid new_rel_oid, 97 Datum relacl, 98 Datum reloptions); 99 100 extern List *AddRelationNewConstraints(Relation rel, 101 List *newColDefaults, 102 List *newConstraints, 103 bool allow_merge, 104 bool is_local, 105 bool is_internal); 106 107 extern void RelationClearMissing(Relation rel); 108 extern void SetAttrMissing(Oid relid, char *attname, char *value); 109 110 extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum, 111 Node *expr, bool is_internal, 112 bool add_column_mode); 113 114 extern Node *cookDefault(ParseState *pstate, 115 Node *raw_default, 116 Oid atttypid, 117 int32 atttypmod, 118 const char *attname); 119 120 extern void DeleteRelationTuple(Oid relid); 121 extern void DeleteAttributeTuples(Oid relid); 122 extern void DeleteSystemAttributeTuples(Oid relid); 123 extern void RemoveAttributeById(Oid relid, AttrNumber attnum); 124 extern void RemoveAttrDefault(Oid relid, AttrNumber attnum, 125 DropBehavior behavior, bool complain, bool internal); 126 extern void RemoveAttrDefaultById(Oid attrdefId); 127 extern void RemoveStatistics(Oid relid, AttrNumber attnum); 128 129 extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno, 130 bool relhasoids); 131 132 extern Form_pg_attribute SystemAttributeByName(const char *attname, 133 bool relhasoids); 134 135 extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, 136 bool allow_system_table_mods); 137 138 extern void CheckAttributeType(const char *attname, 139 Oid atttypid, Oid attcollation, 140 List *containing_rowtypes, 141 bool allow_system_table_mods); 142 143 /* pg_partitioned_table catalog manipulation functions */ 144 extern void StorePartitionKey(Relation rel, 145 char strategy, 146 int16 partnatts, 147 AttrNumber *partattrs, 148 List *partexprs, 149 Oid *partopclass, 150 Oid *partcollation); 151 extern void RemovePartitionKeyByRelId(Oid relid); 152 extern void StorePartitionBound(Relation rel, Relation parent, 153 PartitionBoundSpec *bound); 154 155 #endif /* HEAP_H */ 156