snapbuild.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*-------------------------------------------------------------------------
  2. *
  3. * snapbuild.h
  4. * Exports from replication/logical/snapbuild.c.
  5. *
  6. * Copyright (c) 2012-2016, 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 running
  33. * 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. extern void FreeSnapshotBuilder(SnapBuild *cache);
  56. extern void SnapBuildSnapDecRefcount(Snapshot snap);
  57. extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
  58. extern void SnapBuildClearExportedSnapshot(void);
  59. extern SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate);
  60. extern Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder,
  61. TransactionId xid);
  62. extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
  63. extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
  64. TransactionId xid, int nsubxacts,
  65. TransactionId *subxacts);
  66. extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
  67. XLogRecPtr lsn);
  68. extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
  69. XLogRecPtr lsn, struct xl_heap_new_cid *cid);
  70. extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
  71. struct xl_running_xacts *running);
  72. extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
  73. #endif /* SNAPBUILD_H */