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

Поиск
Список
Период
Сортировка
Искать
От
PG Bug reporting form
Тема
BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Дата
Msg-id
17233-afb9d806aaa64b17@postgresql.org
Список
Дерево обсуждения
BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause PG Bug reporting form <noreply@postgresql.org>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause "David G. Johnston" <david.g.johnston@gmail.com>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause "David G. Johnston" <david.g.johnston@gmail.com>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Александр Королев <lxndrkrlv@gmail.com>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause "David G. Johnston" <david.g.johnston@gmail.com>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Bruce Momjian <bruce@momjian.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Bruce Momjian <bruce@momjian.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Bruce Momjian <bruce@momjian.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Alvaro Herrera <alvherre@alvh.no-ip.org>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause Bruce Momjian <bruce@momjian.us>
The following bug has been logged on the website:

Bug reference:      17233
Logged by:          Alexander Korolev
Email address:      lxndrkrlv@gmail.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.

Repro
--------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS pg_temp.tmp1;
DROP TABLE IF EXISTS pg_temp.tmp2;

CREATE TEMPORARY TABLE tmp1 (id int NOT NULL, name text);
CREATE TEMPORARY TABLE tmp2 (id int NOT NULL, name text);

INSERT INTO tmp1 (id, name) VALUES (1, 'aaa'), (2, 'bbb');
INSERT INTO tmp2 (id, name) VALUES (1, 'aaa'), (2, 'bbb'), (3, 'eee');

SELECT ctid, * from tmp1;
SELECT ctid, * from tmp2;

/* Works as expected: ERROR: column "ctid" does not exist
SELECT CTID
FROM tmp1
INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR UPDATE;
*/

// Executed without errors !!!
DELETE FROM tmp1
WHERE CTID in (
    SELECT CTID
    FROM tmp1
    INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR UPDATE
);

SELECT * FROM tmp1;
SELECT * FROM tmp2;
--------------------------------------------------------------------------------------------

* in some cases, if tables is big, server process is hang. I can't make
small reproducible example.

В списке pgsql-bugs по дате отправления
От: Alvaro Herrera
Дата:
От: David G. Johnston
Дата:
FAQ