Re: Removing unneeded self joins

From: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, Michał Kłeczek <michal(at)kleczek(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: Removing unneeded self joins
Date: 2023-12-29 09:58:11
Message-ID: 0c5f461f-e26f-4fd9-9700-91b0e9c38fd6@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29/12/2023 12:00, Alexander Lakhin wrote:
> Hi Alexander,
>
> 23.10.2023 14:29, Alexander Korotkov wrote:
>> Fixed all of the above. Thank you for catching this!
>
> I've discovered that starting from d3d55ce57 the following query:
> CREATE TABLE t(a int PRIMARY KEY);
>
> WITH tt AS (SELECT * FROM t)
> UPDATE t SET a = tt.a + 1 FROM tt
> WHERE tt.a = t.a RETURNING t.a;
>
> triggers an error "variable not found in subplan target lists".
> (Commits 8a8ed916f and b5fb6736e don't fix this, unfortunately.)

Thanks for the report!
The problem is with the resultRelation field. We forget to replace the
relid here.
Could you check your issue with the patch in the attachment? Does it
resolve this case?

--
regards,
Andrei Lepikhov
Postgres Professional

Attachment Content-Type Size
quickfix.diff text/plain 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey M. Borodin 2023-12-29 10:00:12 Re: Transaction timeout
Previous Message David Rowley 2023-12-29 09:22:33 Re: Revise the Asserts added to bimapset manipulation functions