2
0

snapbuild.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*-------------------------------------------------------------------------
  2. *
  3. * snapbuild.h
  4. * Exports from replication/logical/snapbuild.c.
  5. *
  6. * Copyright (c) 2012-2022, PostgreSQL Global Development Group
  7. *
  8. * src/include/replication/snapbuild.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef SNAPBUILD_H
  13. #define SNAPBUILD_H
  14. #include "access/xlogdefs.h"
  15. #include "utils/snapmgr.h"
  16. typedef enum
  17. {
  18. /*
  19. * Initial state, we can't do much yet.
  20. */
  21. SNAPBUILD_START = -1,
  22. /*
  23. * Collecting committed transactions, to build the initial catalog
  24. * snapshot.
  25. */
  26. SNAPBUILD_BUILDING_SNAPSHOT = 0,
  27. /*
  28. * We have collected enough information to decode tuples in transactions
  29. * that started after this.
  30. *
  31. * Once we reached this we start to collect changes. We cannot apply them
  32. * yet, because they might be based on transactions that were still
  33. * running when FULL_SNAPSHOT was reached.
  34. */
  35. SNAPBUILD_FULL_SNAPSHOT = 1,
  36. /*
  37. * Found a point after SNAPBUILD_FULL_SNAPSHOT where all transactions that
  38. * were running at that point finished. Till we reach that we hold off
  39. * calling any commit callbacks.
  40. */
  41. SNAPBUILD_CONSISTENT = 2
  42. } SnapBuildState;
  43. /* forward declare so we don't have to expose the struct to the public */
  44. struct SnapBuild;
  45. typedef struct SnapBuild SnapBuild;
  46. /* forward declare so we don't have to include reorderbuffer.h */
  47. struct ReorderBuffer;
  48. /* forward declare so we don't have to include heapam_xlog.h */
  49. struct xl_heap_new_cid;
  50. struct xl_running_xacts;
  51. extern void CheckPointSnapBuild(void);
  52. extern SnapBuild *AllocateSnapshotBuilder(struct ReorderBuffer *cache,
  53. TransactionId xmin_horizon, XLogRecPtr start_lsn,
  54. bool need_full_snapshot,
  55. XLogRecPtr two_phase_at);
  56. extern void FreeSnapshotBuilder(SnapBuild *cache);
  57. extern void SnapBuildSnapDecRefcount(Snapshot snap);
  58. extern Snapshot SnapBuildInitialSnapshot(SnapBuild *builder);
  59. extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
  60. extern void SnapBuildClearExportedSnapshot(void);
  61. extern void SnapBuildResetExportedSnapshotState(void);
  62. extern SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate);
  63. extern Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder,
  64. TransactionId xid);
  65. extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
  66. extern XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder);
  67. extern void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr);
  68. extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
  69. TransactionId xid, int nsubxacts,
  70. TransactionId *subxacts);
  71. extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
  72. XLogRecPtr lsn);
  73. extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
  74. XLogRecPtr lsn, struct xl_heap_new_cid *cid);
  75. extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
  76. struct xl_running_xacts *running);
  77. extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
  78. extern void SnapBuildXidSetCatalogChanges(SnapBuild *builder, TransactionId xid,
  79. int subxcnt, TransactionId *subxacts,
  80. XLogRecPtr lsn);
  81. #endif /* SNAPBUILD_H */