Re: Bug: Whole-row var in indexes corrupts indexes after DDL

From: Matthias van de Meent <boekewurm(at)gmail(dot)com>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Clemenza Zhang <zxlmgsps2(at)gmail(dot)com>
Subject: Re: Bug: Whole-row var in indexes corrupts indexes after DDL
Date: 2026-09-08 19:08:08
Message-ID: CAEze2WhuqrHBhUkt_QNYTq1YajV_unu3NVJKnOvsjizaLDo=MA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 4 Sept 2026 at 20:16, Andrey Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>
> Hi Matthias,
>
> I found one remaining issue in the object-address changes in v2/v3.
> pg_identify_object_as_address() does not produce a value that can be
> passed back to pg_get_object_address():
>
> WITH a AS (
> SELECT *
> FROM pg_identify_object_as_address(
> 'pg_class'::regclass, 'wr_multi'::regclass, -32768)
> )
> SELECT pg_get_object_address(type, object_names, object_args)
> FROM a;
>
> ERROR: unrecognized object type "table whole row"
>
> The documentation describes these functions as inverses.

I'm not convinced they are that. pg_identify_object_as_address() will
happily produce "<relkind> column" output, and with several relkinds
these don't survive a round trip (specifically known failing cases:
indexes, views; for specifics check objectaddress.c's ObjectTypeMap).

But regardless, I've added support for decoding "table whole row" and
"foreign table whole row", which were the only objects that also
supported "<relkind> column", so that the hole isn't any smaller than
that of direct attribute references.

> I think we
> either need to make "table whole row" an addressable object type, or use
> another representation that pg_get_object_address() already understands.
> This case would also make a useful addition to the object_address test.

I've added a OBJECT_WHOLE_ROW type, treated like OBJECT_ATTRIBUTE but
slightly differently, and wired it into some relevant places.

> RememberWholeRowDependentForRebuilding() is a void function, but:
>
> + return RememberAllDependentForRebuilding(tab, subtype, rel,
>
> I think you can just call RememberAllDependentForRebuilding() without a
> return.

Adjusted.

----------------------------------------

Attached is v4, which I believe addresses the feedback received so
far. It does not fix the pre-existing ATPostAlterTypeCleanup issue.

Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)

Attachment Content-Type Size
v4-0001-Track-whole-row-Var-dependencies-in-pg_depend.patch application/octet-stream 29.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-08 19:08:33 Re: REPACK (CONCURRENTLY) fails when table owner lacks CONNECT
Previous Message Fabrizio Mello 2026-09-08 19:03:43 Fix failing assert in deferred constraint trigger