| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | Antonin Houska <ah(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY) |
| Date: | 2026-11-20 22:53:15 |
| Message-ID: | cbf3b293-5d1e-4c24-90ca-ccd58c6645da@dunslane.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-11-20 Fr 3:04 PM, Álvaro Herrera wrote:
> I suppose as we get more and more external table AMs and functionality
> we're going to want more and more booleans to say that an AM supports
> this or that. Why not do it just once and invent and interface that
> says
>
> uint32 (*relation_supports_feature) (uint32)
>
> so that the code can pass a bunch of TABLEAM_SUPPORTS_FOOBAR flags, and
> the routine can fill in the return word with 1 for the features it
> supports and 0 for the ones it doesn't? Then the calling code can ask
> for just one or more than one, without spending time on determining
> whether it supports bits it wasn't asked about, in case some of them are
> expensive to determine.
>
> Maybe add more arguments to the callback in case we deem they necessary,
> say the Relation itself or whatever.
>
> This would save us in the future having to add more and more callbacks
> to add for specific individual bits. tableam.h just defines
> TABLEAM_SUPPORTS_LOGICAL_DECODING and so forth, heapam knows to set that
> to 1.
That seems reasonable. v3 attached.
The callback is now
uint32 (*relation_supports_features) (Relation rel, uint32 features);
TABLEAM_SUPPORTS_LOGICAL_DECODING is the only flag so far. It is passed
the flags the caller is asking about and returns the ones the relation
supports. An AM without the callback supports none, and so does one that
predates a flag, so existing AMs are unaffected and a new flag cannot change
what an old AM claims. The callback isn't expected to work out bits that
weren't asked for, as you suggested; table_relation_supports_features()
also masks the result with the request, so an AM that over-reports can't
confuse a caller. There is a single-flag wrapper,
table_relation_supports_feature(), which is what REPACK calls.
I've kept the scope to capabilities of the AM. The "is this relation
empty" callback Chao is working on asks about the data, not about what the
AM can do, so I don't think it belongs in the feature word.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Add-a-table-AM-callback-to-report-supported-featu.patch | text/x-patch | 22.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-11-20 23:17:39 | Re: Stop masking visibility information during WAL consistency checking |
| Previous Message | Michael Paquier | 2026-11-20 22:50:26 | Re: pg_waldump: WAL in pg_wal.old/ inside a tar archive is read as WAL |