@ -33,9 +33,15 @@ setup
CREATE TABLE jointest AS SELECT generate_series(1,10) AS id, 0 AS data;
CREATE INDEX ON jointest(id);
CREATE TABLE parttbl (a int) PARTITION BY LIST (a);
CREATE TABLE parttbl (a int, b int, c int ) PARTITION BY LIST (a);
CREATE TABLE parttbl1 PARTITION OF parttbl FOR VALUES IN (1);
INSERT INTO parttbl VALUES (1);
CREATE TABLE parttbl2 PARTITION OF parttbl FOR VALUES IN (2);
INSERT INTO parttbl VALUES (1, 1, 1);
CREATE TABLE another_parttbl (a int, b int, c int) PARTITION BY LIST (a);
CREATE TABLE another_parttbl1 PARTITION OF another_parttbl FOR VALUES IN (1);
CREATE TABLE another_parttbl2 PARTITION OF another_parttbl FOR VALUES IN (2);
INSERT INTO another_parttbl VALUES (1, 1, 1);
}
teardown
@ -46,6 +52,7 @@ teardown
DROP TABLE p CASCADE;
DROP TABLE table_a, table_b, jointest;
DROP TABLE parttbl;
DROP TABLE another_parttbl;
}
session "s1"
@ -148,6 +155,16 @@ step "simplepartupdate" {
update parttbl set a = a;
}
# test scenarios where update may cause row movement
step "simplepartupdate_route1to2" {
update parttbl set a = 2 where c = 1 returning *;
}
step "simplepartupdate_noroute" {
update parttbl set b = 2 where c = 1 returning *;
}
session "s2"
setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
@ -190,6 +207,21 @@ step "complexpartupdate" {
update parttbl set a = u.a from u;
}
step "complexpartupdate_route_err1" {
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
update parttbl p set a = u.a from u where p.a = u.a and p.c = 1 returning p.*;
}
step "complexpartupdate_route" {
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
update parttbl p set a = p.b from u where p.a = u.a and p.c = 1 returning p.*;
}
step "complexpartupdate_doesnt_route" {
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
update parttbl p set a = 3 - p.b from u where p.a = u.a and p.c = 1 returning p.*;
}
# Use writable CTEs to create self-updated rows, that then are
# (updated|deleted). The *fail versions of the tests additionally
# perform an update, via a function, in a different command, to test
@ -278,3 +310,6 @@ permutation "wrjt" "selectresultforupdate" "c2" "c1"
permutation "wrtwcte" "multireadwcte" "c1" "c2"
permutation "simplepartupdate" "complexpartupdate" "c1" "c2"
permutation "simplepartupdate_route1to2" "complexpartupdate_route_err1" "c1" "c2"
permutation "simplepartupdate_noroute" "complexpartupdate_route" "c1" "c2"
permutation "simplepartupdate_noroute" "complexpartupdate_doesnt_route" "c1" "c2"