Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2418f9

Browse files
committed
Test some more cases with partitioned tables in EvalPlanQual.
We weren't testing anything involving EPQ on UPDATEs that move tuplesinto different partitions. Depending on the implementation,it might be that these cases aren't actually very interesting ...but given our thin coverage of EPQ in general, I think it's a goodidea to have a test case.Amit Langote, minor tweak by meDiscussion:https://postgr.es/m/7889df35-ad1a-691a-00e3-4d4b18f364e3@lab.ntt.co.jp
1 parentba3fb5d commita2418f9

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

‎src/test/isolation/expected/eval-plan-qual.out

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,55 @@ step complexpartupdate:
641641
step c1: COMMIT;
642642
step complexpartupdate: <... completed>
643643
step c2: COMMIT;
644+
645+
starting permutation: simplepartupdate_route1to2 complexpartupdate_route_err1 c1 c2
646+
step simplepartupdate_route1to2:
647+
update parttbl set a = 2 where c = 1 returning *;
648+
649+
a b c
650+
651+
2 1 1
652+
step complexpartupdate_route_err1:
653+
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
654+
update parttbl p set a = u.a from u where p.a = u.a and p.c = 1 returning p.*;
655+
<waiting ...>
656+
step c1: COMMIT;
657+
step complexpartupdate_route_err1: <... completed>
658+
error in steps c1 complexpartupdate_route_err1: ERROR: tuple to be locked was already moved to another partition due to concurrent update
659+
step c2: COMMIT;
660+
661+
starting permutation: simplepartupdate_noroute complexpartupdate_route c1 c2
662+
step simplepartupdate_noroute:
663+
update parttbl set b = 2 where c = 1 returning *;
664+
665+
a b c
666+
667+
1 2 1
668+
step complexpartupdate_route:
669+
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
670+
update parttbl p set a = p.b from u where p.a = u.a and p.c = 1 returning p.*;
671+
<waiting ...>
672+
step c1: COMMIT;
673+
step complexpartupdate_route: <... completed>
674+
a b c
675+
676+
2 2 1
677+
step c2: COMMIT;
678+
679+
starting permutation: simplepartupdate_noroute complexpartupdate_doesnt_route c1 c2
680+
step simplepartupdate_noroute:
681+
update parttbl set b = 2 where c = 1 returning *;
682+
683+
a b c
684+
685+
1 2 1
686+
step complexpartupdate_doesnt_route:
687+
with u as (update another_parttbl set a = 1 returning another_parttbl.*)
688+
update parttbl p set a = 3 - p.b from u where p.a = u.a and p.c = 1 returning p.*;
689+
<waiting ...>
690+
step c1: COMMIT;
691+
step complexpartupdate_doesnt_route: <... completed>
692+
a b c
693+
694+
1 2 1
695+
step c2: COMMIT;

‎src/test/isolation/specs/eval-plan-qual.spec

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ setup
3333
CREATETABLEjointestASSELECTgenerate_series(1,10)ASid,0ASdata;
3434
CREATEINDEXONjointest(id);
3535

36-
CREATETABLEparttbl (aint)PARTITIONBYLIST (a);
36+
CREATETABLEparttbl (aint,bint,cint)PARTITIONBYLIST (a);
3737
CREATETABLEparttbl1PARTITIONOFparttblFORVALUESIN (1);
38-
INSERTINTOparttblVALUES (1);
38+
CREATETABLEparttbl2PARTITIONOFparttblFORVALUESIN (2);
39+
INSERTINTOparttblVALUES (1,1,1);
40+
41+
CREATETABLEanother_parttbl (aint,bint,cint)PARTITIONBYLIST (a);
42+
CREATETABLEanother_parttbl1PARTITIONOFanother_parttblFORVALUESIN (1);
43+
CREATETABLEanother_parttbl2PARTITIONOFanother_parttblFORVALUESIN (2);
44+
INSERTINTOanother_parttblVALUES (1,1,1);
3945
}
4046

4147
teardown
@@ -46,6 +52,7 @@ teardown
4652
DROPTABLEpCASCADE;
4753
DROPTABLEtable_a,table_b,jointest;
4854
DROPTABLEparttbl;
55+
DROPTABLEanother_parttbl;
4956
}
5057

5158
session"s1"
@@ -148,6 +155,16 @@ step "simplepartupdate"{
148155
updateparttblseta=a;
149156
}
150157

158+
# test scenarios where update may cause row movement
159+
160+
step"simplepartupdate_route1to2" {
161+
updateparttblseta=2wherec=1returning*;
162+
}
163+
164+
step"simplepartupdate_noroute" {
165+
updateparttblsetb=2wherec=1returning*;
166+
}
167+
151168

152169
session"s2"
153170
setup{BEGINISOLATIONLEVELREADCOMMITTED; }
@@ -190,6 +207,21 @@ step "complexpartupdate"{
190207
updateparttblseta=u.afromu;
191208
}
192209

210+
step"complexpartupdate_route_err1" {
211+
withuas (updateanother_parttblseta=1returninganother_parttbl.*)
212+
updateparttblpseta=u.afromuwherep.a=u.aandp.c=1returningp.*;
213+
}
214+
215+
step"complexpartupdate_route" {
216+
withuas (updateanother_parttblseta=1returninganother_parttbl.*)
217+
updateparttblpseta=p.bfromuwherep.a=u.aandp.c=1returningp.*;
218+
}
219+
220+
step"complexpartupdate_doesnt_route" {
221+
withuas (updateanother_parttblseta=1returninganother_parttbl.*)
222+
updateparttblpseta=3-p.bfromuwherep.a=u.aandp.c=1returningp.*;
223+
}
224+
193225
# Use writable CTEs to create self-updated rows, that then are
194226
# (updated|deleted). The *fail versions of the tests additionally
195227
# perform an update, via a function, in a different command, to test
@@ -278,3 +310,6 @@ permutation "wrjt" "selectresultforupdate" "c2" "c1"
278310
permutation"wrtwcte""multireadwcte""c1""c2"
279311

280312
permutation"simplepartupdate""complexpartupdate""c1""c2"
313+
permutation"simplepartupdate_route1to2""complexpartupdate_route_err1""c1""c2"
314+
permutation"simplepartupdate_noroute""complexpartupdate_route""c1""c2"
315+
permutation"simplepartupdate_noroute""complexpartupdate_doesnt_route""c1""c2"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp