Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Duncan Sands <duncan(dot)sands(at)deepbluecap(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE
Date: 2025-03-11 17:14:31
Message-ID: 1620306.1741713271@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> Double ugh. I guess we could get preprocess_function_rtes to
> insert the appropriate relid ...

OK, that was less painful than I feared. makeWholeRowVar has
several different special cases for RTE_FUNCTION, but most of them
don't bear on this problem, because we wouldn't have applied inlining
when they did. It seems sufficient to fetch pg_type.typrelid for
the function's nominal return type and store that if it's not 0.

Patches for HEAD and v15 attached. I haven't checked other branches
but I expect the deltas won't be big.

regards, tom lane

Attachment Content-Type Size
v2-generate-correct-vartype-for-whole-row-vars-HEAD.patch text/x-diff 6.6 KB
v2-generate-correct-vartype-for-whole-row-vars-15.patch text/x-diff 6.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andreas Rogge 2025-03-11 17:25:18 Re: BUG #18833: libpq.so doesn't contain declared symbol in rpm --provides
Previous Message BharatDB 2025-03-11 15:02:16 Datatype mismatch warning in logical replication when creating subscription