Andrew Dunstan <[email protected]> wrote:

> On 2026-11-20 Fr 2:54 AM, Antonin Houska wrote:
> > Andrew Dunstan <[email protected]> wrote:
> >
> >> 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.
> > Have you considered adding a callback / field that provides the AM's RmgrId 
> > ?
> > The AM needs to know it anyway, at least when inserting WAL records (Well, 
> > the
> > heap AM actually uses two ids, RM_HEAP_ID and RM_HEAP2_ID ...). With this
> > knowledge, REPACK (CONCURRENTLY) could check whether the rm_decode() 
> > callback
> > exists.
> 
> 
> I did think about exposing the RmgrId, and it's appealing because
> the AM has to know it anyway.  I ended up not going that way, for two
> reasons.

> First, an AM doesn't have a single rmgr.  Heap uses two, RM_HEAP_ID and
> RM_HEAP2_ID, as you say, so we'd need the AM to hand back a list, or
> REPACK would have to know which of them matters.  That's more API than a
> yes/no question warrants.

ok

> Second, a non-NULL rm_decode tells us the rmgr decodes some of its records.
> It doesn't tell us that the AM's changes reach the reorder buffer in a form
> REPACK can apply, or that every record type the AM writes during a rewrite
> is covered.  The AM is the only one in a position to say that, and the
> callback lets it.

I supposed that the AM author is familiar with the RMGR, and that in the
typical case both AM and RMGR are included in the same extension.

> Do you see a case where the callback alone isn't enough?

(I suppose you mean the table AM callback you propose rather than rm_decode())

No, I don't. I was just thinking whether the new AM callback can be more
generic and thus useful for more purposes. Exactly as you say, the RmgrId
approach is appealing :-)

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com


Reply via email to