| 1 |
# Tests for inheritance trees with temporary relations |
| 2 |
# |
| 3 |
# Inheritance trees are allowed to mix relations with different persistence |
| 4 |
# as long as a persistent child relation does not try to inherit from a |
| 5 |
# temporary parent. This checks several scenarios with SELECT, INSERT, UPDATE, |
| 6 |
# DELETE and TRUNCATE. Any temporary relation inheriting from the same |
| 7 |
# persistent parent should be isolated and handled only in its own session. |
| 8 |
|
| 9 |
setup |
| 10 |
{ |
| 11 |
CREATE TABLE inh_parent (a int); |
| 12 |
} |
| 13 |
|
| 14 |
teardown |
| 15 |
{ |
| 16 |
DROP TABLE inh_parent; |
| 17 |
} |
| 18 |
|
| 19 |
# Session 1 executes actions which act directly on both the parent and |
| 20 |
# its child. Abbreviation "c" is used for queries working on the child |
| 21 |
# and "p" on the parent. |
| 22 |
session s1 |
| 23 |
setup |
| 24 |
{ |
| 25 |
CREATE TEMPORARY TABLE inh_temp_child_s1 () INHERITS (inh_parent); |
| 26 |
} |
| 27 |
step s1_begin { BEGIN; } |
| 28 |
step s1_truncate_p { TRUNCATE inh_parent; } |
| 29 |
step s1_select_p { SELECT a FROM inh_parent; } |
| 30 |
step s1_select_c { SELECT a FROM inh_temp_child_s1; } |
| 31 |
step s1_insert_p { INSERT INTO inh_parent VALUES (1), (2); } |
| 32 |
step s1_insert_c { INSERT INTO inh_temp_child_s1 VALUES (3), (4); } |
| 33 |
step s1_update_p { UPDATE inh_parent SET a = 11 WHERE a = 1; } |
| 34 |
step s1_update_c { UPDATE inh_parent SET a = 13 WHERE a IN (3, 5); } |
| 35 |
step s1_delete_p { DELETE FROM inh_parent WHERE a = 2; } |
| 36 |
step s1_delete_c { DELETE FROM inh_parent WHERE a IN (4, 6); } |
| 37 |
step s1_commit { COMMIT; } |
| 38 |
teardown |
| 39 |
{ |
| 40 |
DROP TABLE inh_temp_child_s1; |
| 41 |
} |
| 42 |
|
| 43 |
# Session 2 executes actions on the parent which act only on the child. |
| 44 |
session s2 |
| 45 |
setup |
| 46 |
{ |
| 47 |
CREATE TEMPORARY TABLE inh_temp_child_s2 () INHERITS (inh_parent); |
| 48 |
} |
| 49 |
step s2_truncate_p { TRUNCATE inh_parent; } |
| 50 |
step s2_select_p { SELECT a FROM inh_parent; } |
| 51 |
step s2_select_c { SELECT a FROM inh_temp_child_s2; } |
| 52 |
step s2_insert_c { INSERT INTO inh_temp_child_s2 VALUES (5), (6); } |
| 53 |
step s2_update_c { UPDATE inh_parent SET a = 15 WHERE a IN (3, 5); } |
| 54 |
step s2_delete_c { DELETE FROM inh_parent WHERE a IN (4, 6); } |
| 55 |
teardown |
| 56 |
{ |
| 57 |
DROP TABLE inh_temp_child_s2; |
| 58 |
} |
| 59 |
|
| 60 |
# Check INSERT behavior across sessions |
| 61 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_select_p s1_select_c s2_select_p s2_select_c |
| 62 |
|
| 63 |
# Check UPDATE behavior across sessions |
| 64 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_update_p s1_update_c s1_select_p s1_select_c s2_select_p s2_select_c |
| 65 |
permutation s1_insert_p s1_insert_c s2_insert_c s2_update_c s1_select_p s1_select_c s2_select_p s2_select_c |
| 66 |
|
| 67 |
# Check DELETE behavior across sessions |
| 68 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_delete_p s1_delete_c s1_select_p s1_select_c s2_select_p s2_select_c |
| 69 |
permutation s1_insert_p s1_insert_c s2_insert_c s2_delete_c s1_select_p s1_select_c s2_select_p s2_select_c |
| 70 |
|
| 71 |
# Check TRUNCATE behavior across sessions |
| 72 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_truncate_p s1_select_p s1_select_c s2_select_p s2_select_c |
| 73 |
permutation s1_insert_p s1_insert_c s2_insert_c s2_truncate_p s1_select_p s1_select_c s2_select_p s2_select_c |
| 74 |
|
| 75 |
# TRUNCATE on a parent tree does not block access to temporary child relation |
| 76 |
# of another session, and blocks when scanning the parent. |
| 77 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_begin s1_truncate_p s2_select_p s1_commit |
| 78 |
permutation s1_insert_p s1_insert_c s2_insert_c s1_begin s1_truncate_p s2_select_c s1_commit |