Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
# Verify that the per-row RI probe sees a referenced row committed while
# the probe is parked at ri-before-pk-lock.
#
# Lack of SELECT permission on the referenced table makes RI_Initial_Check
# fall back to per-row validation.
 
setup
{
    CREATE EXTENSION injection_points;
    CREATE ROLE regress_ri_snapshot;
    CREATE TABLE ri_snapshot_pk (id int PRIMARY KEY);
    CREATE TABLE ri_snapshot_fk (pid int);
    INSERT INTO ri_snapshot_fk VALUES (500);
    ALTER TABLE ri_snapshot_fk ADD CONSTRAINT ri_snapshot_fkey
        FOREIGN KEY (pid) REFERENCES ri_snapshot_pk NOT VALID;
    ALTER TABLE ri_snapshot_fk OWNER TO regress_ri_snapshot;
}
 
teardown
{
    DROP TABLE ri_snapshot_fk, ri_snapshot_pk;
    DROP ROLE regress_ri_snapshot;
    DROP EXTENSION injection_points;
}
 
session s1
setup
{
    DO $$BEGIN
        PERFORM injection_points_set_local();
        PERFORM injection_points_attach('ri-before-pk-lock', 'wait');
    END$$;
    SET ROLE regress_ri_snapshot;
    SET default_transaction_isolation = 'read committed';
}
step validate { ALTER TABLE ri_snapshot_fk VALIDATE CONSTRAINT ri_snapshot_fkey; }
step checked { }
 
session s2
step ins { INSERT INTO ri_snapshot_pk VALUES (500); }
step wake
{
    DO $$BEGIN
        PERFORM injection_points_detach('ri-before-pk-lock');
        PERFORM injection_points_wakeup('ri-before-pk-lock');
    END$$;
}
step validated { SELECT convalidated FROM pg_constraint WHERE conname = 'ri_snapshot_fkey'; }
 
permutation validate ins wake checked validated