1# Test for page level predicate locking in rum 2# 3# Test to check reduced false positives 4# 5# Queries are written in such a way that an index scan(from one transaction) and an index insert(from another transaction) will try to access different parts(sub-tree) of the index. 6 7setup 8{ 9 CREATE EXTENSION rum; 10 11 CREATE TABLE rum_tbl (id serial, tsv tsvector); 12 13 CREATE TABLE text_table (id1 serial, t text[]); 14 15 SELECT SETSEED(0.5); 16 17 INSERT INTO text_table(t) SELECT array[chr(i) || chr(j)] FROM generate_series(65,90) i, 18 generate_series(65,90) j ; 19 20 INSERT INTO rum_tbl(tsv) SELECT to_tsvector('simple', t[1] ) FROM text_table; 21 22 DO $$ 23 BEGIN 24 FOR j in 1..10 LOOP 25 UPDATE rum_tbl SET tsv = tsv || q.t1 FROM (SELECT id1,to_tsvector('simple', t[1] ) 26 as t1 FROM text_table) as q WHERE id = (random()*q.id1)::integer; 27 END LOOP; 28 END; 29 $$; 30 31 CREATE INDEX rum_tbl_idx ON rum_tbl USING rum (tsv rum_tsvector_ops); 32} 33 34teardown 35{ 36 DROP TABLE text_table; 37 DROP TABLE rum_tbl; 38 DROP EXTENSION rum; 39} 40 41session "s1" 42setup { 43 BEGIN ISOLATION LEVEL SERIALIZABLE; 44 set enable_seqscan=off; 45 } 46step "rxy1" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'hx'; } 47step "wx1" { INSERT INTO rum_tbl(tsv) values('ab'); } 48step "c1" { COMMIT; } 49 50session "s2" 51setup { 52 BEGIN ISOLATION LEVEL SERIALIZABLE; 53 set enable_seqscan=off; 54 } 55 56step "rxy2" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'qh'; } 57step "wy2" { INSERT INTO rum_tbl(tsv) values('xz'); } 58step "c2" { COMMIT; } 59 60