All pastes #136363 Raw Edit

Untitled

public sql v1 · immutable
#136363 ·published 2006-08-17 16:53 UTC
rendered paste body
  CREATE TABLE x (id INT) ;  INSERT INTO x VALUES (1);  INSERT INTO x VALUES (2);  INSERT INTO x VALUES (3);  INSERT INTO x VALUES (4);  mm_testsql=# SELECT * FROM x FOR UPDATE LIMIT 1;   id  ----    1  (1 row)Simple enough. Now, in a separate transaction, run the following  mm_testsql=# BEGIN ;  BEGIN   mm_testsql=# DELETE FROM X WHERE id = 1 ;  DELETE 1Select for update will now block  mm_testsql=# SELECT * FROM x FOR UPDATE LIMIT 1;And finally, commit in the  mm_testsql=# COMMIT ;  COMMIT  mm_testsql=#In the original transaction, the following is returned   id  ----  (0 rows)