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

Поиск
Список
Период
Сортировка
От Александр Королев
Тема Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause
Дата
Msg-id CANWr0s029ET54ZwgxHr88utD8+9EaaQQPvdbvPprcVx4NGKL4A@mail.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>)
Список pgsql-bugs
This is not a bug:


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.

Possibly this is not a bug, but this behavior is strange.
Also, this subquery has different behavior in SELECT and DELETE:

--------------------------------------------------------------------------------------------------
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'), (3, 'ccc');
INSERT INTO tmp2 (id, name) VALUES (1, 'aaa');

-- select outputs all rows from tmp1
SELECT * FROM tmp1
WHERE CTID in (
    SELECT CTID
    FROM tmp1
    INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR UPDATE
);

--delete affects only first row from tmp1
DELETE FROM tmp1
WHERE CTID in (
    SELECT CTID
    FROM tmp1
    INNER JOIN tmp2 ON tmp1.id = tmp2.id FOR UPDATE
) RETURNING *;
--------------------------------------------------------------------------------------------------

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Noah Misch
Дата:
Сообщение: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17233: Incorrect behavior of DELETE command with bad subquery in WHERE clause