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-10 20:08:46
Message-ID: 1213530.1741637326@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> However, that's not quite the end of it -- preprocess_function_rtes()
> / inline_set_returning_function() can turn a function RTE into a
> subquery RTE, leading to a similar problem:

> create table foo (a int, b int);
> insert into foo values (1,2);
> create or replace function f() returns setof foo as
> $$ select * from foo offset 0 $$ language sql stable;
> update foo set b = f.b from f() as f(a,b) where f.a = foo.a returning f;

> ERROR: attribute 3 of type record has wrong type
> DETAIL: Table has type record, but query expects foo.

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

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-03-10 20:20:20 Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE
Previous Message Dean Rasheed 2025-03-10 20:03:15 Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE