2
0

heap.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*-------------------------------------------------------------------------
  2. *
  3. * heap.h
  4. * prototypes for functions in backend/catalog/heap.c
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, 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. /* flag bits for CheckAttributeType/CheckAttributeNamesTypes */
  20. #define CHKATYPE_ANYARRAY 0x01 /* allow ANYARRAY */
  21. #define CHKATYPE_ANYRECORD 0x02 /* allow RECORD and RECORD[] */
  22. #define CHKATYPE_IS_PARTKEY 0x04 /* attname is part key # not column */
  23. typedef struct RawColumnDefault
  24. {
  25. AttrNumber attnum; /* attribute to attach default to */
  26. Node *raw_default; /* default value (untransformed parse tree) */
  27. bool missingMode; /* true if part of add column processing */
  28. char generated; /* attgenerated setting */
  29. } RawColumnDefault;
  30. typedef struct CookedConstraint
  31. {
  32. ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */
  33. Oid conoid; /* constr OID if created, otherwise Invalid */
  34. char *name; /* name, or NULL if none */
  35. AttrNumber attnum; /* which attr (only for DEFAULT) */
  36. Node *expr; /* transformed default or check expr */
  37. bool skip_validation; /* skip validation? (only for CHECK) */
  38. bool is_local; /* constraint has local (non-inherited) def */
  39. int inhcount; /* number of times constraint is inherited */
  40. bool is_no_inherit; /* constraint has local def and cannot be
  41. * inherited */
  42. } CookedConstraint;
  43. extern Relation heap_create(const char *relname,
  44. Oid relnamespace,
  45. Oid reltablespace,
  46. Oid relid,
  47. Oid relfilenode,
  48. Oid accessmtd,
  49. TupleDesc tupDesc,
  50. char relkind,
  51. char relpersistence,
  52. bool shared_relation,
  53. bool mapped_relation,
  54. bool allow_system_table_mods,
  55. TransactionId *relfrozenxid,
  56. MultiXactId *relminmxid,
  57. bool create_storage);
  58. extern Oid heap_create_with_catalog(const char *relname,
  59. Oid relnamespace,
  60. Oid reltablespace,
  61. Oid relid,
  62. Oid reltypeid,
  63. Oid reloftypeid,
  64. Oid ownerid,
  65. Oid accessmtd,
  66. TupleDesc tupdesc,
  67. List *cooked_constraints,
  68. char relkind,
  69. char relpersistence,
  70. bool shared_relation,
  71. bool mapped_relation,
  72. OnCommitAction oncommit,
  73. Datum reloptions,
  74. bool use_user_acl,
  75. bool allow_system_table_mods,
  76. bool is_internal,
  77. Oid relrewrite,
  78. ObjectAddress *typaddress);
  79. extern void heap_drop_with_catalog(Oid relid);
  80. extern void heap_truncate(List *relids);
  81. extern void heap_truncate_one_rel(Relation rel);
  82. extern void heap_truncate_check_FKs(List *relations, bool tempTables);
  83. extern List *heap_truncate_find_FKs(List *relationIds);
  84. extern void InsertPgAttributeTuples(Relation pg_attribute_rel,
  85. TupleDesc tupdesc,
  86. Oid new_rel_oid,
  87. Datum *attoptions,
  88. CatalogIndexState indstate);
  89. extern void InsertPgClassTuple(Relation pg_class_desc,
  90. Relation new_rel_desc,
  91. Oid new_rel_oid,
  92. Datum relacl,
  93. Datum reloptions);
  94. extern List *AddRelationNewConstraints(Relation rel,
  95. List *newColDefaults,
  96. List *newConstraints,
  97. bool allow_merge,
  98. bool is_local,
  99. bool is_internal,
  100. const char *queryString);
  101. extern void RelationClearMissing(Relation rel);
  102. extern void SetAttrMissing(Oid relid, char *attname, char *value);
  103. extern Node *cookDefault(ParseState *pstate,
  104. Node *raw_default,
  105. Oid atttypid,
  106. int32 atttypmod,
  107. const char *attname,
  108. char attgenerated);
  109. extern void DeleteRelationTuple(Oid relid);
  110. extern void DeleteAttributeTuples(Oid relid);
  111. extern void DeleteSystemAttributeTuples(Oid relid);
  112. extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
  113. extern void CopyStatistics(Oid fromrelid, Oid torelid);
  114. extern void RemoveStatistics(Oid relid, AttrNumber attnum);
  115. extern const FormData_pg_attribute *SystemAttributeDefinition(AttrNumber attno);
  116. extern const FormData_pg_attribute *SystemAttributeByName(const char *attname);
  117. extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
  118. int flags);
  119. extern void CheckAttributeType(const char *attname,
  120. Oid atttypid, Oid attcollation,
  121. List *containing_rowtypes,
  122. int flags);
  123. /* pg_partitioned_table catalog manipulation functions */
  124. extern void StorePartitionKey(Relation rel,
  125. char strategy,
  126. int16 partnatts,
  127. AttrNumber *partattrs,
  128. List *partexprs,
  129. Oid *partopclass,
  130. Oid *partcollation);
  131. extern void RemovePartitionKeyByRelId(Oid relid);
  132. extern void StorePartitionBound(Relation rel, Relation parent,
  133. PartitionBoundSpec *bound);
  134. #endif /* HEAP_H */