| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Table AM callback for logical decoding support (REPACK CONCURRENTLY) |
| Date: | 2026-11-19 16:34:27 |
| Message-ID: | 4278ebea-1571-4478-b603-958591649192@dunslane.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
In [1], REPACK (CONCURRENTLY) was restricted to heap because nothing in
TableAmRoutine says whether an AM can be logically decoded, and without
decoding the changes made during the rewrite are silently lost. Masahiko
suggested a callback for HEAD, and Bharath that it wait for a field report.
Here is one: a table AM we are developing has its own resource manager
with rm_decode, and the heap-only check refuses it.
The attached patch adds an optional relation_supports_logical_decoding
callback, last in TableAmRoutine. An AM without it is taken not to support
decoding, so existing AMs are unaffected. heap provides it, and REPACK asks
the AM instead of comparing its routine with heap's.
With the callback set in that AM, REPACK (CONCURRENTLY) with concurrent DML
converges row for row with a heap oracle, and a logical slot attached
during it sees no duplicate changes.
The test module has two AMs that copy heap's routine, one without the
callback. heap_getnext() insists on heap's own routine, so their tables can
have no index or TOAST table; the test shows one refused and the other past
the check.
This is for v20 only. It is the second small TableAmRoutine addition that
out-of-tree AMs need, after the reloptions patch in [2]. The two don't
conflict (this one is last in the struct), and could be reviewed, or
committed, as one series if that's easier. Maybe we only need one new test
module instead of two.
I'd welcome views on the shape: a callback, as suggested, or a plain flag.
[1] https://postgr.es/m/apBkixO4xAGFoiT3@nathan
[2] https://postgr.es/m/ea1c4d33-0780-473c-96dc-1468cf733a04@dunslane.net
("Allow table AMs to define their own reloptions")
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-a-table-AM-callback-for-logical-decoding-support.patch | text/x-patch | 16.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Melanie Plageman | 2026-11-19 16:36:42 | Re: [BUG / PATCH] PG19: VACUUM misestimates reltuples (often 0) after on-access VM setting |
| Previous Message | Alexander Korotkov | 2026-11-19 16:15:13 | Re: test: avoid redundant standby catchup in 049_wait_for_lsn |