From f64ea6dc5c8ccaec9a3d3d39695ca261febb6883 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Tue, 30 Mar 2021 10:34:43 +0530 Subject: Add a xid argument to the filter_prepare callback for output plugins. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Along with gid, this provides a different way to identify the transaction. The users that use xid in some way to prepare the transactions can use it to filter prepare transactions. The later commands COMMIT PREPARED or ROLLBACK PREPARED carries both identifiers, providing an output plugin the choice of what to use. Author: Markus Wanner Reviewed-by: Vignesh C, Amit Kapila Discussion: https://postgr.es/m/ee280000-7355-c4dc-e47b-2436e7be959c@enterprisedb.com --- doc/src/sgml/logicaldecoding.sgml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml index 80eb96d609a..da23f89ca32 100644 --- a/doc/src/sgml/logicaldecoding.sgml +++ b/doc/src/sgml/logicaldecoding.sgml @@ -794,20 +794,25 @@ typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx, COMMIT PREPARED time. To signal that decoding should be skipped, return true; false otherwise. When the callback is not - defined, false is assumed (i.e. nothing is - filtered). + defined, false is assumed (i.e. no filtering, all + transactions using two-phase commit are decoded in two phases as well). typedef bool (*LogicalDecodeFilterPrepareCB) (struct LogicalDecodingContext *ctx, + TransactionId xid, const char *gid); - The ctx parameter has the same contents as for the - other callbacks. The gid is the identifier that later - identifies this transaction for COMMIT PREPARED or - ROLLBACK PREPARED. + The ctx parameter has the same contents as for + the other callbacks. The parameters xid + and gid provide two different ways to identify + the transaction. The later COMMIT PREPARED or + ROLLBACK PREPARED carries both identifiers, + providing an output plugin the choice of what to use. - The callback has to provide the same static answer for a given - gid every time it is called. + The callback may be invoked multiple times per transaction to decode + and must provide the same static answer for a given pair of + xid and gid every time + it is called. @@ -1219,9 +1224,11 @@ stream_commit_cb(...); <-- commit of the streamed transaction - Optionally the output plugin can specify a name pattern in the - filter_prepare_cb and transactions with gid containing - that name pattern will not be decoded as a two-phase commit transaction. + Optionally the output plugin can define filtering rules via + filter_prepare_cb to decode only specific transaction + in two phases. This can be achieved by pattern matching on the + gid or via lookups using the + xid. -- cgit v1.2.3