heap.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*-------------------------------------------------------------------------
  2. *
  3. * heap.h
  4. * prototypes for functions in backend/catalog/heap.c
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, 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. #include "catalog/indexing.h"
  17. #include "catalog/objectaddress.h"
  18. #include "parser/parse_node.h"
  19. typedef struct RawColumnDefault
  20. {
  21. AttrNumber attnum; /* attribute to attach default to */
  22. Node *raw_default; /* default value (untransformed parse tree) */
  23. } RawColumnDefault;
  24. typedef struct CookedConstraint
  25. {
  26. ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
  27. Oid conoid; /* constr OID if created, otherwise Invalid */
  28. char *name; /* name, or NULL if none */
  29. AttrNumber attnum; /* which attr (only for DEFAULT) */
  30. Node *expr; /* transformed default or check expr */
  31. bool skip_validation; /* skip validation? (only for CHECK) */
  32. bool is_local; /* constraint has local (non-inherited) def */
  33. int inhcount; /* number of times constraint is inherited */
  34. bool is_no_inherit; /* constraint has local def and cannot be
  35. * inherited */
  36. } CookedConstraint;
  37. extern Relation heap_create(const char *relname,
  38. Oid relnamespace,
  39. Oid reltablespace,
  40. Oid relid,
  41. Oid relfilenode,
  42. TupleDesc tupDesc,
  43. char relkind,
  44. char relpersistence,
  45. bool shared_relation,
  46. bool mapped_relation,
  47. bool allow_system_table_mods);
  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. bool is_internal,
  68. ObjectAddress *typaddress);
  69. extern void heap_create_init_fork(Relation rel);
  70. extern void heap_drop_with_catalog(Oid relid);
  71. extern void heap_truncate(List *relids);
  72. extern void heap_truncate_one_rel(Relation rel);
  73. extern void heap_truncate_check_FKs(List *relations, bool tempTables);
  74. extern List *heap_truncate_find_FKs(List *relationIds);
  75. extern void InsertPgAttributeTuple(Relation pg_attribute_rel,
  76. Form_pg_attribute new_attribute,
  77. CatalogIndexState indstate);
  78. extern void InsertPgClassTuple(Relation pg_class_desc,
  79. Relation new_rel_desc,
  80. Oid new_rel_oid,
  81. Datum relacl,
  82. Datum reloptions);
  83. extern List *AddRelationNewConstraints(Relation rel,
  84. List *newColDefaults,
  85. List *newConstraints,
  86. bool allow_merge,
  87. bool is_local,
  88. bool is_internal);
  89. extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum,
  90. Node *expr, bool is_internal);
  91. extern Node *cookDefault(ParseState *pstate,
  92. Node *raw_default,
  93. Oid atttypid,
  94. int32 atttypmod,
  95. char *attname);
  96. extern void DeleteRelationTuple(Oid relid);
  97. extern void DeleteAttributeTuples(Oid relid);
  98. extern void DeleteSystemAttributeTuples(Oid relid);
  99. extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
  100. extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
  101. DropBehavior behavior, bool complain, bool internal);
  102. extern void RemoveAttrDefaultById(Oid attrdefId);
  103. extern void RemoveStatistics(Oid relid, AttrNumber attnum);
  104. extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
  105. bool relhasoids);
  106. extern Form_pg_attribute SystemAttributeByName(const char *attname,
  107. bool relhasoids);
  108. extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
  109. bool allow_system_table_mods);
  110. extern void CheckAttributeType(const char *attname,
  111. Oid atttypid, Oid attcollation,
  112. List *containing_rowtypes,
  113. bool allow_system_table_mods);
  114. #endif /* HEAP_H */