I have stumbled upon this, for keeping the problem easy to explain i have put a sample code below
Table:
CREATE TABLE "MyTab"
(
"Id" integer NOT NULL DEFAULT nextval('"Anukram"."MyTab_Id_seq"'::regclass),
"Text1" text COLLATE pg_catalog."default" NOT NULL,
"Text2" text COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT "MyTab_pkey" PRIMARY KEY ("Id")
)
Data Fill:
INSERT INTO "Anukram"."MyTab" ("Text1","Text2") values
('L','R'),('A','B'),('C','D'), ('L','R1'),('A','B1'),('C','D1')
Statement in Question:
WITH "Temp" AS (
UPDATE "MyTab"
SET "Text2"="Text2" || "Text2"
WHERE "Text1"='L'
RETURNING *
)
DELETE
FROM "MyTab"
USING "Temp"-- <--This is used in some more conditions in where clause not shown here
WHERE "MyTab"."Text1"='L'
RETURNING "MyTab".*
Expectation:
It should delete 2 rows with 'L' in "Text1" col
Actual:
It deletes just one row(looking at RETURNING statement)
Observation:
If i remove Using clause everything behaves as expected
So what am i missing here? or is this a bug in snapshots used by PG?