| 1 |
# Simple tests for statement_timeout and lock_timeout features |
| 2 |
|
| 3 |
setup |
| 4 |
{ |
| 5 |
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null); |
| 6 |
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600); |
| 7 |
} |
| 8 |
|
| 9 |
teardown |
| 10 |
{ |
| 11 |
DROP TABLE accounts; |
| 12 |
} |
| 13 |
|
| 14 |
session s1 |
| 15 |
setup { BEGIN ISOLATION LEVEL READ COMMITTED; } |
| 16 |
step rdtbl { SELECT * FROM accounts; } |
| 17 |
step wrtbl { UPDATE accounts SET balance = balance + 100; } |
| 18 |
teardown { ABORT; } |
| 19 |
|
| 20 |
session s2 |
| 21 |
setup { BEGIN ISOLATION LEVEL READ COMMITTED; } |
| 22 |
step sto { SET statement_timeout = '10ms'; } |
| 23 |
step lto { SET lock_timeout = '10ms'; } |
| 24 |
step lsto { SET lock_timeout = '10ms'; SET statement_timeout = '10s'; } |
| 25 |
step slto { SET lock_timeout = '10s'; SET statement_timeout = '10ms'; } |
| 26 |
step locktbl { LOCK TABLE accounts; } |
| 27 |
step update { DELETE FROM accounts WHERE accountid = 'checking'; } |
| 28 |
teardown { ABORT; } |
| 29 |
|
| 30 |
# It's possible that the isolation tester will not observe the final |
| 31 |
# steps as "waiting", thanks to the relatively short timeouts we use. |
| 32 |
# We can ensure consistent test output by marking those steps with (*). |
| 33 |
|
| 34 |
# statement timeout, table-level lock |
| 35 |
permutation rdtbl sto locktbl(*) |
| 36 |
# lock timeout, table-level lock |
| 37 |
permutation rdtbl lto locktbl(*) |
| 38 |
# lock timeout expires first, table-level lock |
| 39 |
permutation rdtbl lsto locktbl(*) |
| 40 |
# statement timeout expires first, table-level lock |
| 41 |
permutation rdtbl slto locktbl(*) |
| 42 |
# statement timeout, row-level lock |
| 43 |
permutation wrtbl sto update(*) |
| 44 |
# lock timeout, row-level lock |
| 45 |
permutation wrtbl lto update(*) |
| 46 |
# lock timeout expires first, row-level lock |
| 47 |
permutation wrtbl lsto update(*) |
| 48 |
# statement timeout expires first, row-level lock |
| 49 |
permutation wrtbl slto update(*) |