@@ -1667,17 +1667,24 @@ ReorderBufferCommitInternal(ReorderBufferTXN *txn,
16671667 PG_END_TRY ();
16681668}
16691669
1670+ /*
1671+ * Ask output plugin whether we want to skip this PREPARE and send
1672+ * this transaction as one-phase later on commit.
1673+ */
16701674bool
16711675ReorderBufferPrepareNeedSkip (ReorderBuffer * rb , TransactionId xid , char * gid )
16721676{
16731677 ReorderBufferTXN * txn ;
16741678
16751679 txn = ReorderBufferTXNByXid (rb , xid , false, NULL , InvalidXLogRecPtr , false);
1676- Assert (txn != NULL );
1677- // ctx->callbacks.filter_prepare_cb
1680+
16781681 return rb -> filter_prepare (rb , txn , gid );
16791682}
16801683
1684+
1685+ /*
1686+ * Commit non-twophase transaction. See comments to ReorderBufferCommitInternal()
1687+ */
16811688void
16821689ReorderBufferCommit (ReorderBuffer * rb , TransactionId xid ,
16831690 XLogRecPtr commit_lsn , XLogRecPtr end_lsn ,
@@ -1693,6 +1700,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
16931700 commit_time , origin_id , origin_lsn );
16941701}
16951702
1703+ /*
1704+ * Prepare twophase transaction. It calls ReorderBufferCommitInternal()
1705+ * since all transaction changes should be decoded on PREPARE.
1706+ */
16961707void
16971708ReorderBufferPrepare (ReorderBuffer * rb , TransactionId xid ,
16981709 XLogRecPtr commit_lsn , XLogRecPtr end_lsn ,
@@ -1712,6 +1723,10 @@ ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid,
17121723 commit_time , origin_id , origin_lsn );
17131724}
17141725
1726+ /*
1727+ * Check whether this transaction was sent as prepared to receiver.
1728+ * Called upon commit/abort prepared.
1729+ */
17151730bool
17161731ReorderBufferTxnIsPrepared (ReorderBuffer * rb , TransactionId xid )
17171732{
@@ -1720,7 +1735,6 @@ ReorderBufferTxnIsPrepared(ReorderBuffer *rb, TransactionId xid)
17201735 txn = ReorderBufferTXNByXid (rb , xid , false, NULL , InvalidXLogRecPtr ,
17211736 false);
17221737
1723- /* TXN not found mean that it was send already, isn't it? */
17241738 return txn == NULL ? true : txn -> prepared ;
17251739}
17261740
0 commit comments