Re: SELECT FOR UPDATE returns zero rows with CTE

2021-09-17 Thread Tom Lane
Alban Hertroys writes: >> On 17 Sep 2021, at 8:32, Roman Guryanov >> wrote: >> Why does SELECT FOR UPDATE return 0 rows in the scenario below? (execution >> in transaction) > Most likely the outer select returns 0 rows because you locked the rows you > expected in cte2 and didn’t perform an

Re: SELECT FOR UPDATE returns zero rows with CTE

2021-09-17 Thread Alban Hertroys
> On 17 Sep 2021, at 8:32, Roman Guryanov wrote: > > Hello, could you check my problem. > Why does SELECT FOR UPDATE return 0 rows in the scenario below? (execution in > transaction) > > If delete 'FOR UPDATE', 1 row returned > > Test case: > DROP TABLE IF EXISTS > t1; > > CREATE TABLE

SELECT FOR UPDATE returns zero rows with CTE

2021-09-17 Thread Roman Guryanov
), cte2 AS ( SELECT * FROM t1 WHERE t1c1 = 123456789 AND t1c2 = (SELECT t1c2 FROM cte1) FOR UPDATE ) SELECT * FROM cte2; https://stackoverflow.com/questions/69217940/select-for-update-returns-zero-rows-with-cte