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.

123 line
3.6KB

  1. /*-------------------------------------------------------------------------
  2. * output_plugin.h
  3. * PostgreSQL Logical Decode Plugin Interface
  4. *
  5. * Copyright (c) 2012-2019, PostgreSQL Global Development Group
  6. *
  7. *-------------------------------------------------------------------------
  8. */
  9. #ifndef OUTPUT_PLUGIN_H
  10. #define OUTPUT_PLUGIN_H
  11. #include "replication/reorderbuffer.h"
  12. struct LogicalDecodingContext;
  13. struct OutputPluginCallbacks;
  14. typedef enum OutputPluginOutputType
  15. {
  16. OUTPUT_PLUGIN_BINARY_OUTPUT,
  17. OUTPUT_PLUGIN_TEXTUAL_OUTPUT
  18. } OutputPluginOutputType;
  19. /*
  20. * Options set by the output plugin, in the startup callback.
  21. */
  22. typedef struct OutputPluginOptions
  23. {
  24. OutputPluginOutputType output_type;
  25. bool receive_rewrites;
  26. } OutputPluginOptions;
  27. /*
  28. * Type of the shared library symbol _PG_output_plugin_init that is looked up
  29. * when loading an output plugin shared library.
  30. */
  31. typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
  32. /*
  33. * Callback that gets called in a user-defined plugin. ctx->private_data can
  34. * be set to some private data.
  35. *
  36. * "is_init" will be set to "true" if the decoding slot just got defined. When
  37. * the same slot is used from there one, it will be "false".
  38. */
  39. typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
  40. OutputPluginOptions *options,
  41. bool is_init);
  42. /*
  43. * Callback called for every (explicit or implicit) BEGIN of a successful
  44. * transaction.
  45. */
  46. typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
  47. ReorderBufferTXN *txn);
  48. /*
  49. * Callback for every individual change in a successful transaction.
  50. */
  51. typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
  52. ReorderBufferTXN *txn,
  53. Relation relation,
  54. ReorderBufferChange *change);
  55. /*
  56. * Callback for every TRUNCATE in a successful transaction.
  57. */
  58. typedef void (*LogicalDecodeTruncateCB) (struct LogicalDecodingContext *ctx,
  59. ReorderBufferTXN *txn,
  60. int nrelations,
  61. Relation relations[],
  62. ReorderBufferChange *change);
  63. /*
  64. * Called for every (explicit or implicit) COMMIT of a successful transaction.
  65. */
  66. typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
  67. ReorderBufferTXN *txn,
  68. XLogRecPtr commit_lsn);
  69. /*
  70. * Called for the generic logical decoding messages.
  71. */
  72. typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx,
  73. ReorderBufferTXN *txn,
  74. XLogRecPtr message_lsn,
  75. bool transactional,
  76. const char *prefix,
  77. Size message_size,
  78. const char *message);
  79. /*
  80. * Filter changes by origin.
  81. */
  82. typedef bool (*LogicalDecodeFilterByOriginCB) (struct LogicalDecodingContext *ctx,
  83. RepOriginId origin_id);
  84. /*
  85. * Called to shutdown an output plugin.
  86. */
  87. typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
  88. /*
  89. * Output plugin callbacks
  90. */
  91. typedef struct OutputPluginCallbacks
  92. {
  93. LogicalDecodeStartupCB startup_cb;
  94. LogicalDecodeBeginCB begin_cb;
  95. LogicalDecodeChangeCB change_cb;
  96. LogicalDecodeTruncateCB truncate_cb;
  97. LogicalDecodeCommitCB commit_cb;
  98. LogicalDecodeMessageCB message_cb;
  99. LogicalDecodeFilterByOriginCB filter_by_origin_cb;
  100. LogicalDecodeShutdownCB shutdown_cb;
  101. } OutputPluginCallbacks;
  102. /* Functions in replication/logical/logical.c */
  103. extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
  104. extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
  105. extern void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx);
  106. #endif /* OUTPUT_PLUGIN_H */
上海开阖软件有限公司 沪ICP备12045867号-1