Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "lxndrkrlv(at)gmail(dot)com" <lxndrkrlv(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Date: 2021-10-17 14:15:48
Message-ID: CAKFQuwbnETbhnBYtMA8HNJwf0ipwAETd58=K0JzPs22Of2ZhcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Saturday, October 16, 2021, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 17233
> Logged by: Alexander Korolev
> Email address: lxndrkrlv(at)gmail(dot)com
> PostgreSQL version: 14.0
> Operating system: Windows
> Description:
>
> This SELECT command fails as expected:
> SELECT CTID FROM tmp1 INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR UPDATE;
> -- ERROR: column "ctid" does not exist.
>
> But if I use same SELECT in WHERE clause of DELETE command
> DELETE FROM tmp1 WHERE CTID in (
> SELECT CTID FROM tmp1 INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR
> UPDATE);
> this command is executed without errors.
>

This is not a bug:

https://wiki.postgresql.org/wiki/FAQ#Why_doesn.27t_PostgreSQL_report_a_column_not_found_error_when_using_the_wrong_name_in_a_subquery.3F

The virtual join table doesn’t have a ctid, only physical tables do, and
the ctid of physical tables apparently aren’t propogated when they are
joined.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-10-17 14:34:18 Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Previous Message PG Bug reporting form 2021-10-16 19:41:52 BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause