blob: 3cb89260dc1e0a58e7973604a20a793fc91c8a7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# Tests for locking conflicts with VACUUM and ANALYZE commands.
setup
{
CREATE ROLE regress_vacuum_conflict;
CREATE TABLE vacuum_tab (a int);
}
teardown
{
DROP TABLE vacuum_tab;
DROP ROLE regress_vacuum_conflict;
}
session s1
step s1_begin { BEGIN; }
step s1_lock { LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; }
step s1_commit { COMMIT; }
session s2
step s2_grant { ALTER TABLE vacuum_tab OWNER TO regress_vacuum_conflict; }
step s2_auth { SET ROLE regress_vacuum_conflict; }
step s2_vacuum { VACUUM vacuum_tab; }
step s2_analyze { ANALYZE vacuum_tab; }
step s2_reset { RESET ROLE; }
# The role doesn't have privileges to vacuum the table, so VACUUM should
# immediately skip the table without waiting for a lock.
permutation s1_begin s1_lock s2_auth s2_vacuum s1_commit s2_reset
permutation s1_begin s2_auth s2_vacuum s1_lock s1_commit s2_reset
permutation s1_begin s2_auth s1_lock s2_vacuum s1_commit s2_reset
permutation s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset
# Same as previously for ANALYZE
permutation s1_begin s1_lock s2_auth s2_analyze s1_commit s2_reset
permutation s1_begin s2_auth s2_analyze s1_lock s1_commit s2_reset
permutation s1_begin s2_auth s1_lock s2_analyze s1_commit s2_reset
permutation s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset
# The role has privileges to vacuum the table, VACUUM will block if
# another session holds a lock on the table and succeed in all cases.
permutation s1_begin s2_grant s1_lock s2_auth s2_vacuum s1_commit s2_reset
permutation s1_begin s2_grant s2_auth s2_vacuum s1_lock s1_commit s2_reset
permutation s1_begin s2_grant s2_auth s1_lock s2_vacuum s1_commit s2_reset
permutation s2_grant s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset
# Same as previously for ANALYZE
permutation s1_begin s2_grant s1_lock s2_auth s2_analyze s1_commit s2_reset
permutation s1_begin s2_grant s2_auth s2_analyze s1_lock s1_commit s2_reset
permutation s1_begin s2_grant s2_auth s1_lock s2_analyze s1_commit s2_reset
permutation s2_grant s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset
|