src/backend/replication/logical/reorderbuffer.c
void
ReorderBufferCommitChild(ReorderBuffer *rb, TransactionId xid,
						 TransactionId subxid, XLogRecPtr commit_lsn,
						 XLogRecPtr end_lsn)
{
	ReorderBufferTXN *txn;
	ReorderBufferTXN *subtxn;

	subtxn = ReorderBufferTXNByXid(rb, subxid, false, NULL,
								   InvalidXLogRecPtr, false);

	/*
	 * No need to do anything if that subtxn didn't contain any changes
	 */
	if (!subtxn)
		return;

	txn = ReorderBufferTXNByXid(rb, xid, false, NULL, commit_lsn, true);

	if (txn == NULL)
		elog(ERROR, "subxact logged without previous toplevel record");

	/*
	 * Pass our base snapshot to the parent transaction if it doesn't have
	 * one, or ours is older. That can happen if there are no changes in the
	 * toplevel transaction but in one of the child transactions. This allows
	 * the parent to simply use its base snapshot initially.
	 */
	if (subtxn->base_snapshot != NULL &&
		(txn->base_snapshot == NULL ||
		 txn->base_snapshot_lsn > subtxn->base_snapshot_lsn))
	{
		txn->base_snapshot = subtxn->base_snapshot;
		txn->base_snapshot_lsn = subtxn->base_snapshot_lsn;
		subtxn->base_snapshot = NULL;
		subtxn->base_snapshot_lsn = InvalidXLogRecPtr;
	}

	subtxn->final_lsn = commit_lsn;
	subtxn->end_lsn = end_lsn;

	if (!subtxn->is_known_as_subxact)
	{
		subtxn->is_known_as_subxact = true;
		Assert(subtxn->nsubtxns == 0);

		/* remove from lsn order list of top-level transactions */
		dlist_delete(&subtxn->node);

		/* add to subtransaction list */
		dlist_push_tail(&txn->subtxns, &subtxn->node);
		txn->nsubtxns++;
	}
}
/*
 * Associate a subtransaction with its toplevel transaction at commit
 * time. There may be no further changes added after this.
 */
Associate a subtransaction with its toplevel transaction at commit
time. There may be no further changes added after this.
Associate a subtransaction with its toplevel transaction at commit time . There may be no further changes added after this .
void
ReorderBufferCommitChild(ReorderBuffer *rb, TransactionId xid,
						 TransactionId subxid, XLogRecPtr commit_lsn,
						 XLogRecPtr end_lsn)
{
	ReorderBufferTXN *txn;
	ReorderBufferTXN *subtxn;
	subtxn = ReorderBufferTXNByXid(rb, subxid, false, NULL,
								   InvalidXLogRecPtr, false);
	if (!subtxn)
		return;
	txn = ReorderBufferTXNByXid(rb, xid, false, NULL, commit_lsn, true);
	if (txn == NULL)
		elog(ERROR, "subxact logged without previous toplevel record");
	if (subtxn->base_snapshot != NULL &&
		(txn->base_snapshot == NULL ||
		 txn->base_snapshot_lsn > subtxn->base_snapshot_lsn))
	{
		txn->base_snapshot = subtxn->base_snapshot;
		txn->base_snapshot_lsn = subtxn->base_snapshot_lsn;
		subtxn->base_snapshot = NULL;
		subtxn->base_snapshot_lsn = InvalidXLogRecPtr;
	}
	subtxn->final_lsn = commit_lsn;
	subtxn->end_lsn = end_lsn;
	if (!subtxn->is_known_as_subxact)
	{
		subtxn->is_known_as_subxact = true;
		Assert(subtxn->nsubtxns == 0);
		dlist_delete(&subtxn->node);
		dlist_push_tail(&txn->subtxns, &subtxn->node);
		txn->nsubtxns++;
	}
}
void ReorderBufferCommitChild ( ReorderBuffer * rb , TransactionId xid , TransactionId subxid , XLogRecPtr commit_lsn , XLogRecPtr end_lsn ) { ReorderBufferTXN * txn ; ReorderBufferTXN * subtxn ; subtxn = ReorderBufferTXNByXid ( rb , subxid , false , NULL , InvalidXLogRecPtr , false ) ; if ( ! subtxn ) return ; txn = ReorderBufferTXNByXid ( rb , xid , false , NULL , commit_lsn , true ) ; if ( txn == NULL ) elog ( ERROR , " " ) ; if ( subtxn -> base_snapshot != NULL && ( txn -> base_snapshot == NULL || txn -> base_snapshot_lsn > subtxn -> base_snapshot_lsn ) ) { txn -> base_snapshot = subtxn -> base_snapshot ; txn -> base_snapshot_lsn = subtxn -> base_snapshot_lsn ; subtxn -> base_snapshot = NULL ; subtxn -> base_snapshot_lsn = InvalidXLogRecPtr ; } subtxn -> final_lsn = commit_lsn ; subtxn -> end_lsn = end_lsn ; if ( ! subtxn -> is_known_as_subxact ) { subtxn -> is_known_as_subxact = true ; Assert ( subtxn -> nsubtxns == 0 ) ; dlist_delete ( & subtxn -> node ) ; dlist_push_tail ( & txn -> subtxns , & subtxn -> node ) ; txn -> nsubtxns ++ ; } }
Associate a subtransaction with its toplevel transaction at commit
 time.
Associate a subtransaction with its toplevel transaction at commit time .
/*
	 * No need to do anything if that subtxn didn't contain any changes
	 */ /*
	 * Pass our base snapshot to the parent transaction if it doesn't have
	 * one, or ours is older. That can happen if there are no changes in the
	 * toplevel transaction but in one of the child transactions. This allows
	 * the parent to simply use its base snapshot initially.
	 */ /* remove from lsn order list of top-level transactions */ /* add to subtransaction list */