gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.5KB

  1. /*-------------------------------------------------------------------------
  2. * logical.h
  3. * PostgreSQL logical decoding coordination
  4. *
  5. * Copyright (c) 2012-2019, PostgreSQL Global Development Group
  6. *
  7. *-------------------------------------------------------------------------
  8. */
  9. #ifndef LOGICAL_H
  10. #define LOGICAL_H
  11. #include "replication/slot.h"
  12. #include "access/xlog.h"
  13. #include "access/xlogreader.h"
  14. #include "replication/output_plugin.h"
  15. struct LogicalDecodingContext;
  16. typedef void (*LogicalOutputPluginWriterWrite) (struct LogicalDecodingContext *lr,
  17. XLogRecPtr Ptr,
  18. TransactionId xid,
  19. bool last_write
  20. );
  21. typedef LogicalOutputPluginWriterWrite LogicalOutputPluginWriterPrepareWrite;
  22. typedef void (*LogicalOutputPluginWriterUpdateProgress) (struct LogicalDecodingContext *lr,
  23. XLogRecPtr Ptr,
  24. TransactionId xid
  25. );
  26. typedef struct LogicalDecodingContext
  27. {
  28. /* memory context this is all allocated in */
  29. MemoryContext context;
  30. /* The associated replication slot */
  31. ReplicationSlot *slot;
  32. /* infrastructure pieces for decoding */
  33. XLogReaderState *reader;
  34. struct ReorderBuffer *reorder;
  35. struct SnapBuild *snapshot_builder;
  36. /*
  37. * Marks the logical decoding context as fast forward decoding one. Such a
  38. * context does not have plugin loaded so most of the following properties
  39. * are unused.
  40. */
  41. bool fast_forward;
  42. OutputPluginCallbacks callbacks;
  43. OutputPluginOptions options;
  44. /*
  45. * User specified options
  46. */
  47. List *output_plugin_options;
  48. /*
  49. * User-Provided callback for writing/streaming out data.
  50. */
  51. LogicalOutputPluginWriterPrepareWrite prepare_write;
  52. LogicalOutputPluginWriterWrite write;
  53. LogicalOutputPluginWriterUpdateProgress update_progress;
  54. /*
  55. * Output buffer.
  56. */
  57. StringInfo out;
  58. /*
  59. * Private data pointer of the output plugin.
  60. */
  61. void *output_plugin_private;
  62. /*
  63. * Private data pointer for the data writer.
  64. */
  65. void *output_writer_private;
  66. /*
  67. * State for writing output.
  68. */
  69. bool accept_writes;
  70. bool prepared_write;
  71. XLogRecPtr write_location;
  72. TransactionId write_xid;
  73. } LogicalDecodingContext;
  74. extern void CheckLogicalDecodingRequirements(void);
  75. extern LogicalDecodingContext *CreateInitDecodingContext(char *plugin,
  76. List *output_plugin_options,
  77. bool need_full_snapshot,
  78. XLogRecPtr restart_lsn,
  79. XLogPageReadCB read_page,
  80. LogicalOutputPluginWriterPrepareWrite prepare_write,
  81. LogicalOutputPluginWriterWrite do_write,
  82. LogicalOutputPluginWriterUpdateProgress update_progress);
  83. extern LogicalDecodingContext *CreateDecodingContext(XLogRecPtr start_lsn,
  84. List *output_plugin_options,
  85. bool fast_forward,
  86. XLogPageReadCB read_page,
  87. LogicalOutputPluginWriterPrepareWrite prepare_write,
  88. LogicalOutputPluginWriterWrite do_write,
  89. LogicalOutputPluginWriterUpdateProgress update_progress);
  90. extern void DecodingContextFindStartpoint(LogicalDecodingContext *ctx);
  91. extern bool DecodingContextReady(LogicalDecodingContext *ctx);
  92. extern void FreeDecodingContext(LogicalDecodingContext *ctx);
  93. extern void LogicalIncreaseXminForSlot(XLogRecPtr lsn, TransactionId xmin);
  94. extern void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn,
  95. XLogRecPtr restart_lsn);
  96. extern void LogicalConfirmReceivedLocation(XLogRecPtr lsn);
  97. extern bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id);
  98. #endif
上海开阖软件有限公司 沪ICP备12045867号-1