Re: Add a hook for handling logical decoding messages on subscribers.

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add a hook for handling logical decoding messages on subscribers.
Date: 2026-11-15 17:13:15
Message-ID: 4d9e1d2f-27a2-40ec-92c8-4b5740736cf8@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sat, Nov14, 2026 at 07:35 AM Masahiko Sawada wrote:
>
> Agreed. It's better for callbacks to get both top-level and
> subtransaction's ids.
>
> I've updated the patches (the 0002 patch unchanged).

> - ctx->write_xid = txn != NULL ? txn->xid : InvalidTransactionId;
> + ctx->write_xid = xid;

I think it would be better to keep the original code for consistency, as
all the other callbacks set ctx->write_xid to txn->xid (the top-level
transaction's XID). IIUC, this was changed to make the test pass since
test_decoding does not otherwise output the subxid, but we could instead
use pgoutput to test that and keep passing the top-level XID in
ctx->write_xid. Please see the attached top-up patch for this change.

BTW, since we are changing the callback signature anyway, another wild
idea would be to pass ReorderBufferChange directly instead so that it is
fully consistent with the other change callbacks. That said, it would
require more changes in third-party output plugins, so I don't insist on
it if you disagree — just sharing for reference.

--
Best Regards,
Zhijie Hou

Attachment Content-Type Size
nocfbot-0001-Top-up-for-v8-0001-Fix-streamed-block-XID-in-stream_.patch text/plain 5.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Jeevan Chalke 2026-11-15 16:49:42 Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO