Created
June 6, 2017 01:31
-
-
Save EvanCarroll/cab18a61b000c3b18f3c4b71a20e1d2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session 1 | |
==== | |
Will sleep for 5 seconds giving you time to launch TXN2. | |
DROP TABLE foo; | |
CREATE TABLE foo(x) AS | |
VALUES (1),(2),(3); | |
CREATE OR REPLACE FUNCTION test_foo_has_null() | |
RETURNS bool | |
AS | |
$BODY$ | |
BEGIN | |
IF (SELECT count(*) = 0 FROM foo WHERE x IS NULL) THEN | |
PERFORM pg_sleep(5); | |
RETURN false; | |
ELSE | |
RETURN true; | |
END IF; | |
END; | |
$BODY$ | |
LANGUAGE 'plpgsql'; | |
BEGIN; | |
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; | |
SELECT test_foo_has_null(); | |
END; | |
Session 2 | |
==== | |
BEGIN; | |
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; | |
INSERT INTO foo(x) VALUES (null); | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment