Skip to content

Instantly share code, notes, and snippets.

@jjb
Created March 28, 2014 01:18
Show Gist options
  • Save jjb/9823023 to your computer and use it in GitHub Desktop.
Save jjb/9823023 to your computer and use it in GitHub Desktop.
demonstration of behavior discussed in http://stackoverflow.com/questions/22389882
CREATE TABLE things (
id integer NOT NULL,
my_column varchar
);
insert into things (id) values (1);
insert into things (id) values (2);
-- This can be achieved simply with 2 terminal windows each with
-- a psql session
-- Connection A
BEGIN;
UPDATE "things" SET "my_column" = 'hello' WHERE "things"."id" = 1;
-- Connection B
BEGIN;
UPDATE "things" SET "my_column" = 'hello' WHERE "things"."id" = 2;
UPDATE "things" SET "my_column" = 'hello' WHERE "things"."id" = 1;
-- Connection A
UPDATE "things" SET "my_column" = 'hello' WHERE "things"."id" = 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment