| 1 |
# Test sequence usage and concurrent sequence DDL |
| 2 |
|
| 3 |
setup |
| 4 |
{ |
| 5 |
CREATE SEQUENCE seq1; |
| 6 |
} |
| 7 |
|
| 8 |
teardown |
| 9 |
{ |
| 10 |
DROP SEQUENCE seq1; |
| 11 |
} |
| 12 |
|
| 13 |
session s1 |
| 14 |
setup { BEGIN; } |
| 15 |
step s1alter { ALTER SEQUENCE seq1 MAXVALUE 10; } |
| 16 |
step s1alter2 { ALTER SEQUENCE seq1 MAXVALUE 20; } |
| 17 |
step s1restart { ALTER SEQUENCE seq1 RESTART WITH 5; } |
| 18 |
step s1commit { COMMIT; } |
| 19 |
|
| 20 |
session s2 |
| 21 |
step s2begin { BEGIN; } |
| 22 |
step s2nv { SELECT nextval('seq1') FROM generate_series(1, 15); } |
| 23 |
step s2commit { COMMIT; } |
| 24 |
|
| 25 |
permutation s1alter s1commit s2nv |
| 26 |
|
| 27 |
# Prior to PG10, the s2nv step would see the uncommitted s1alter |
| 28 |
# change, but now it waits. |
| 29 |
permutation s1alter s2nv s1commit |
| 30 |
|
| 31 |
# Prior to PG10, the s2nv step would see the uncommitted s1restart |
| 32 |
# change, but now it waits. |
| 33 |
permutation s1restart s2nv s1commit |
| 34 |
|
| 35 |
# In contrast to ALTER setval() is non-transactional, so it doesn't |
| 36 |
# have to wait. |
| 37 |
permutation s1restart s2nv s1commit |
| 38 |
|
| 39 |
# nextval doesn't release lock until transaction end, so s1alter2 has |
| 40 |
# to wait for s2commit. |
| 41 |
permutation s2begin s2nv s1alter2 s2commit s1commit |