Re: MERGE fails with RETURNING when an excluded inheritance parent has an extra-column child

From: Keyerror Smart <smartkeyerror(at)gmail(dot)com>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Subject: Re: MERGE fails with RETURNING when an excluded inheritance parent has an extra-column child
Date: 2026-11-09 13:18:58
Message-ID: CAD=-kXY2Bz0L1Xg09iRpBs8shq9AZNtQSbvwjnn2sTJM220eDw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tender Wang,

I can reproduce this on master, and the fix looks right to me.

With `missing_ok = true`, a child-only column just gets a 0 in the
map, and if an expression ever referenced it, `map_variable_attnos()`
would raise "unexpected varattno" instead of mis-mapping it.
ExecGetRootToChildMap() also passes missing_ok = true for
non-partition children, for the same reason:

/*
* When this child table is not a partition (!relispartition), it may
* have columns that are not present in the root table, which we ask
* to ignore by passing true for missing_ok.
*/

I also tried whole-row RETURNING (t, t.*, old/new), RLS as a
non-superuser, and a child with a dropped column. All work fine
with the patch.

Zhenglong Li,
Regards

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-11-09 13:28:58 Re: Show 'Rows Removed by Filter' with two fractional digits in EXPLAIN
Previous Message Bruce Momjian 2026-11-09 13:08:19 Re: First draft of PG 19 release notes