Skip to content

Instantly share code, notes, and snippets.

@begriffs
Created February 8, 2016 18:14
Show Gist options
  • Select an option

  • Save begriffs/5729026cfa86e731e093 to your computer and use it in GitHub Desktop.

Select an option

Save begriffs/5729026cfa86e731e093 to your computer and use it in GitHub Desktop.
simplified deadlock test
module Main where
import Control.Monad (replicateM_)
import Hasql.Connection
import Hasql.Session
import Hasql.Query
main :: IO ()
main = do
acquire "postgres://postgres@localhost:5432/demo1" >>= \case
Left err -> error $ show err
Right c ->
replicateM_ 10 $ run sess c
where
sess = do
sql "begin isolation level read committed;"
sql "WITH pg_source AS (UPDATE \"public\".\"film\" SET \"rating\"='1'::unknown WHERE \"public\".\"film\".\"id\" = '1'::unknown ) SELECT '', 0, '', '';"
sql "WITH pg_source AS (UPDATE \"public\".\"film\" SET \"rating\"='1'::unknown WHERE \"public\".\"film\".\"id\" = '1'::unknown ) SELECT '', 0, '', '';"
sql "commit;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment