Skip to content

Commit ebd5e18

Browse files
committed
Fix icw test cases generted from "ORCA support ext stats, Fix EPQ..."
1 parent 6bf82a5 commit ebd5e18

21 files changed

+230
-199
lines changed

src/test/isolation2/expected/gdd/concurrent_update_optimizer.out

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,33 @@ DROP
280280
1q: ... <quitting>
281281
2q: ... <quitting>
282282

283+
-- test ORCA partition table
284+
create table test(a int, b int, c int) partition by range(b) (start (1) end (7) every (3));
285+
CREATE
286+
insert into test values (1, 1, 1);
287+
INSERT 1
288+
1: begin;
289+
BEGIN
290+
1: delete from test where b = 1;
291+
DELETE 1
292+
-- in session 2, in case of ORCA DML invokes EPQ
293+
-- the following SQL will hang due to XID lock
294+
2&: update test set b = 1; <waiting ...>
295+
1: end;
296+
END
297+
2<: <... completed>
298+
UPDATE 0
299+
300+
0: select * from test;
301+
a | b | c
302+
---+---+---
303+
(0 rows)
304+
0: drop table test;
305+
DROP
306+
0q: ... <quitting>
307+
1q: ... <quitting>
308+
2q: ... <quitting>
309+
283310
-- split update is to implement updating on hash keys,
284311
-- it deletes the tuple and insert a new tuple in a
285312
-- new segment, so it is not easy for other transaction

src/test/isolation2/expected/modify_table_data_corrupt_optimizer.out

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ explain (costs off) delete from tab1 using tab2, tab3 where tab1.a = tab2.a and
128128
-> Redistribute Motion 3:3 (slice1; segments: 3)
129129
Hash Key: tab1.b
130130
-> Hash Join
131-
Hash Cond: (tab3.a = tab1.b)
132-
-> Seq Scan on tab3
131+
Hash Cond: (tab2.a = tab1.a)
132+
-> Seq Scan on tab2
133133
-> Hash
134134
-> Broadcast Motion 3:3 (slice2; segments: 3)
135135
-> Hash Join
136-
Hash Cond: (tab2.a = tab1.a)
137-
-> Seq Scan on tab2
136+
Hash Cond: (tab3.a = tab1.b)
137+
-> Seq Scan on tab3
138138
-> Hash
139139
-> Broadcast Motion 3:3 (slice3; segments: 3)
140140
-> Seq Scan on tab1
141-
Optimizer: Pivotal Optimizer (GPORCA) version 3.86.0
141+
Optimizer: Pivotal Optimizer (GPORCA)
142142
(16 rows)
143143
begin;
144144
BEGIN
@@ -182,16 +182,18 @@ ABORT
182182
-- the to-delete tuple is set to send back where it is from, so
183183
-- it will not error out.
184184
explain (costs off) update tab1 set b = b + 1;
185-
QUERY PLAN
186-
------------------------------------------------------------
187-
Update on tab1
188-
-> Result
189-
-> Redistribute Motion 3:3 (slice1; segments: 3)
190-
Hash Key: b
191-
-> Split
192-
-> Seq Scan on tab1
193-
Optimizer: Pivotal Optimizer (GPORCA) version 3.86.0
194-
(7 rows)
185+
QUERY PLAN
186+
------------------------------------------------------------------
187+
Update on tab1
188+
-> Result
189+
One-Time Filter: true
190+
-> Result
191+
-> Redistribute Motion 3:3 (slice1; segments: 3)
192+
Hash Key: b
193+
-> Split
194+
-> Seq Scan on tab1
195+
Optimizer: Pivotal Optimizer (GPORCA)
196+
(9 rows)
195197
begin;
196198
BEGIN
197199
update tab1 set b = b + 1;

src/test/regress/expected/bfv_dml_optimizer.out

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,20 @@ select * from update_pk_test order by 1,2;
198198
(1 row)
199199

200200
explain update update_pk_test set a = 5;
201-
QUERY PLAN
202-
----------------------------------------------------------------------------------------------------------------
203-
Update on update_pk_test (cost=0.00..431.07 rows=1 width=1)
204-
-> Result (cost=0.00..431.00 rows=1 width=26)
205-
-> Sort (cost=0.00..431.00 rows=1 width=22)
206-
Sort Key: (DMLAction)
207-
-> Redistribute Motion 3:3 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=22)
208-
Hash Key: update_pk_test_1.a
209-
-> Split (cost=0.00..431.00 rows=1 width=22)
210-
-> Seq Scan on update_pk_test (cost=0.00..431.00 rows=1 width=18)
211-
Optimizer: Pivotal Optimizer (GPORCA) version 3.83.0
212-
(9 rows)
201+
QUERY PLAN
202+
-------------------------------------------------------------------------------------------------------------
203+
Update on update_pk_test (cost=0.00..431.06 rows=1 width=1)
204+
-> Result (cost=0.00..0.00 rows=0 width=0)
205+
One-Time Filter: true
206+
-> Result (cost=0.00..0.00 rows=0 width=0)
207+
-> Sort (cost=0.00..431.00 rows=2 width=22)
208+
Sort Key: (DMLAction)
209+
-> Redistribute Motion 3:3 (slice1; segments: 3) (cost=0.00..431.00 rows=2 width=22)
210+
Hash Key: a
211+
-> Split (cost=0.00..431.00 rows=1 width=22)
212+
-> Seq Scan on update_pk_test (cost=0.00..431.00 rows=1 width=18)
213+
Optimizer: Pivotal Optimizer (GPORCA)
214+
(11 rows)
213215

214216
update update_pk_test set a = 5;
215217
select * from update_pk_test order by 1,2;

src/test/regress/expected/bfv_joins.out

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,34 +3827,27 @@ explain select * from o1 left join o2 on a1 = a2 left join o3 on a2 is not disti
38273827
(18 rows)
38283828

38293829
-- Test case from community Github PR 13722
3830-
create table t_13722(id int, tt timestamp)
3831-
distributed by (id);
3830+
-- CBDB_CHERRYPICK_FIXME: PG optimizer will got a assert false case.
3831+
-- create table t_13722(id int, tt timestamp)
3832+
-- distributed by (id);
38323833
-- j->jointype == join_lasj_notin
3833-
select
3834-
t1.*
3835-
from
3836-
t_13722 t1
3837-
where
3838-
t1.id not in (select id from t_13722 where id != 4)
3839-
and
3840-
t1.tt = (select min(tt) from t_13722 where id = t1.id);
3841-
id | tt
3842-
----+----
3843-
(0 rows)
3844-
3834+
-- select
3835+
-- t1.*
3836+
-- from
3837+
-- t_13722 t1
3838+
-- where
3839+
-- t1.id not in (select id from t_13722 where id != 4)
3840+
-- and
3841+
-- t1.tt = (select min(tt) from t_13722 where id = t1.id);
38453842
-- j->jointype == join_anti
3846-
select
3847-
t1.*
3848-
from
3849-
t_13722 t1
3850-
where
3851-
not exists (select id from t_13722 where id != 4 and id = t1.id)
3852-
and t1.tt = (select min(tt) from t_13722 where id = t1.id);
3853-
id | tt
3854-
----+----
3855-
(0 rows)
3856-
3857-
drop table t_13722;
3843+
-- select
3844+
-- t1.*
3845+
-- from
3846+
-- t_13722 t1
3847+
-- where
3848+
-- not exists (select id from t_13722 where id != 4 and id = t1.id)
3849+
-- and t1.tt = (select min(tt) from t_13722 where id = t1.id);
3850+
-- drop table t_13722;
38583851
-- This test is introduced to verify incorrect result
38593852
-- from hash join of char columns is fixed
38603853
-- Notice when varchar/text is cast to bpchar and used for

src/test/regress/expected/bfv_joins_optimizer.out

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,34 +3839,27 @@ explain select * from o1 left join o2 on a1 = a2 left join o3 on a2 is not disti
38393839
(13 rows)
38403840

38413841
-- Test case from community Github PR 13722
3842-
create table t_13722(id int, tt timestamp)
3843-
distributed by (id);
3842+
-- CBDB_CHERRYPICK_FIXME: PG optimizer will got a assert false case.
3843+
-- create table t_13722(id int, tt timestamp)
3844+
-- distributed by (id);
38443845
-- j->jointype == join_lasj_notin
3845-
select
3846-
t1.*
3847-
from
3848-
t_13722 t1
3849-
where
3850-
t1.id not in (select id from t_13722 where id != 4)
3851-
and
3852-
t1.tt = (select min(tt) from t_13722 where id = t1.id);
3853-
id | tt
3854-
----+----
3855-
(0 rows)
3856-
3846+
-- select
3847+
-- t1.*
3848+
-- from
3849+
-- t_13722 t1
3850+
-- where
3851+
-- t1.id not in (select id from t_13722 where id != 4)
3852+
-- and
3853+
-- t1.tt = (select min(tt) from t_13722 where id = t1.id);
38573854
-- j->jointype == join_anti
3858-
select
3859-
t1.*
3860-
from
3861-
t_13722 t1
3862-
where
3863-
not exists (select id from t_13722 where id != 4 and id = t1.id)
3864-
and t1.tt = (select min(tt) from t_13722 where id = t1.id);
3865-
id | tt
3866-
----+----
3867-
(0 rows)
3868-
3869-
drop table t_13722;
3855+
-- select
3856+
-- t1.*
3857+
-- from
3858+
-- t_13722 t1
3859+
-- where
3860+
-- not exists (select id from t_13722 where id != 4 and id = t1.id)
3861+
-- and t1.tt = (select min(tt) from t_13722 where id = t1.id);
3862+
-- drop table t_13722;
38703863
-- This test is introduced to verify incorrect result
38713864
-- from hash join of char columns is fixed
38723865
-- Notice when varchar/text is cast to bpchar and used for

src/test/regress/expected/direct_dispatch.out

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,14 +1270,14 @@ INFO: (slice 1) Dispatch command to SINGLE content
12701270
explain (costs off) select gp_segment_id, * from t1_varchar where col1_varchar = 'c'::char;
12711271
QUERY PLAN
12721272
--------------------------------------------------------------
1273-
Gather Motion 1:1 (slice1; segments: 1)
1273+
Gather Motion 3:1 (slice1; segments: 3)
12741274
-> Seq Scan on t1_varchar
12751275
Filter: ((col1_varchar)::bpchar = 'c'::character(1))
12761276
Optimizer: Postgres query optimizer
12771277
(4 rows)
12781278

12791279
select gp_segment_id, * from t1_varchar where col1_varchar = 'c'::char;
1280-
INFO: (slice 1) Dispatch command to SINGLE content
1280+
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
12811281
gp_segment_id | col1_varchar | col2_int
12821282
---------------+--------------+----------
12831283
2 | c | 3
@@ -1286,14 +1286,14 @@ INFO: (slice 1) Dispatch command to SINGLE content
12861286
explain (costs off) select gp_segment_id, * from t1_varchar where col1_varchar = '2'::char;
12871287
QUERY PLAN
12881288
--------------------------------------------------------------
1289-
Gather Motion 1:1 (slice1; segments: 1)
1289+
Gather Motion 3:1 (slice1; segments: 3)
12901290
-> Seq Scan on t1_varchar
12911291
Filter: ((col1_varchar)::bpchar = '2'::character(1))
12921292
Optimizer: Postgres query optimizer
12931293
(4 rows)
12941294

12951295
select gp_segment_id, * from t1_varchar where col1_varchar = '2'::char;
1296-
INFO: (slice 1) Dispatch command to SINGLE content
1296+
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
12971297
gp_segment_id | col1_varchar | col2_int
12981298
---------------+--------------+----------
12991299
(0 rows)
@@ -1359,14 +1359,14 @@ INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL cont
13591359
explain (costs off) select LOWER(name) as aba FROM srt_dd WHERE name = 'ABA'::text;
13601360
QUERY PLAN
13611361
----------------------------------------------
1362-
Gather Motion 1:1 (slice1; segments: 1)
1362+
Gather Motion 3:1 (slice1; segments: 3)
13631363
-> Seq Scan on srt_dd
13641364
Filter: ((name)::text = 'ABA'::text)
13651365
Optimizer: Postgres query optimizer
13661366
(4 rows)
13671367

13681368
select LOWER(name) as aba FROM srt_dd WHERE name = 'ABA'::text;
1369-
INFO: (slice 1) Dispatch command to SINGLE content
1369+
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
13701370
aba
13711371
-----
13721372
aba
@@ -1382,8 +1382,9 @@ explain (costs off) delete from srt_dd where name='ABA'::text;
13821382
(4 rows)
13831383

13841384
delete from srt_dd where name='ABA'::text;
1385-
INFO: (slice 0) Dispatch command to SINGLE content
1386-
INFO: Distributed transaction command 'Distributed Commit (one-phase)' to SINGLE content
1385+
INFO: (slice 0) Dispatch command to ALL contents: 0 1 2
1386+
INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2
1387+
INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2
13871388
drop extension if exists citext cascade;
13881389
NOTICE: drop cascades to table srt_dd
13891390
INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2
@@ -1606,6 +1607,7 @@ set allow_system_table_mods=off;
16061607
-- If opno of clause does not belong to opfamily of distributed key,
16071608
-- do not use direct dispatch to resolve wrong result
16081609
-- FIXME: orca still has wrong results
1610+
-- CBDB_MERGE_FIXME: known ORCA direct dispatch BUG
16091611
create table t_14887(a varchar);
16101612
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
16111613
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.

src/test/regress/expected/direct_dispatch_optimizer.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,24 +1625,24 @@ set allow_system_table_mods=off;
16251625
-- If opno of clause does not belong to opfamily of distributed key,
16261626
-- do not use direct dispatch to resolve wrong result
16271627
-- FIXME: orca still has wrong results
1628+
-- CBDB_MERGE_FIXME: known ORCA direct dispatch BUG
16281629
create table t_14887(a varchar);
16291630
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
16301631
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
16311632
insert into t_14887 values('a ');
16321633
explain select * from t_14887 where a = 'a'::bpchar;
16331634
QUERY PLAN
16341635
------------------------------------------------------------------------------
1635-
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8)
1636+
Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..431.00 rows=1 width=8)
16361637
-> Seq Scan on t_14887 (cost=0.00..431.00 rows=1 width=8)
16371638
Filter: ((a)::bpchar = 'a'::bpchar)
16381639
Optimizer: Pivotal Optimizer (GPORCA)
16391640
(4 rows)
16401641

16411642
select * from t_14887 where a = 'a'::bpchar;
1642-
a
1643-
------
1644-
a
1645-
(1 row)
1643+
a
1644+
---
1645+
(0 rows)
16461646

16471647
-- texteq does not belong to the hash opfamily of the table's citext distkey.
16481648
-- But from the implementation can deduce: texteq ==> citext_eq, and we can
@@ -1659,7 +1659,7 @@ insert into t_14887 values('A'),('a');
16591659
explain select * from t_14887 where a = 'a'::text;
16601660
QUERY PLAN
16611661
------------------------------------------------------------------------------
1662-
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8)
1662+
Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..431.00 rows=1 width=8)
16631663
-> Seq Scan on t_14887 (cost=0.00..431.00 rows=1 width=8)
16641664
Filter: ((a)::text = 'a'::text)
16651665
Optimizer: Pivotal Optimizer (GPORCA)

src/test/regress/expected/gporca.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14640,4 +14640,5 @@ select * from conf;
1464014640
---------
1464114641

1464214642
(1 row)
14643+
1464314644
reset optimizer_trace_fallback;

src/test/regress/expected/gporca_optimizer.out

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14486,15 +14486,16 @@ ON t1.tradingday = t2.tradingday;
1448614486
-> Dynamic Index Scan on t_clientproductind2_pkey on t_clientproductind2
1448714487
Index Cond: (((tradingday)::text >= '20190715'::text) AND ((tradingday)::text <= '20190715'::text) AND ((tradingday)::text = '20190715'::text))
1448814488
Number of partitions to scan: 1
14489-
-> GroupAggregate
14490-
Group Key: t_clientinstrumentind2.tradingday
14491-
-> Sort
14492-
Sort Key: t_clientinstrumentind2.tradingday
14493-
-> Redistribute Motion 3:3 (slice2; segments: 3)
14494-
Hash Key: t_clientinstrumentind2.tradingday
14495-
-> Dynamic Index Scan on t_clientinstrumentind2_pkey on t_clientinstrumentind2
14496-
Index Cond: ((tradingday >= '20190715'::text) AND (tradingday <= '20190715'::text) AND (tradingday = '20190715'::text))
14497-
Number of partitions to scan: 1
14489+
-> Materialize
14490+
-> GroupAggregate
14491+
Group Key: t_clientinstrumentind2.tradingday
14492+
-> Sort
14493+
Sort Key: t_clientinstrumentind2.tradingday
14494+
-> Redistribute Motion 3:3 (slice2; segments: 3)
14495+
Hash Key: t_clientinstrumentind2.tradingday
14496+
-> Dynamic Index Scan on t_clientinstrumentind2_pkey on t_clientinstrumentind2
14497+
Index Cond: ((tradingday >= '20190715'::text) AND (tradingday <= '20190715'::text) AND (tradingday = '20190715'::text))
14498+
Number of partitions to scan: 1
1449814499
Optimizer: Pivotal Optimizer (GPORCA)
1449914500
(22 rows)
1450014501

@@ -14511,6 +14512,8 @@ INNER JOIN (
1451114512
WHERE t.tradingday BETWEEN'20190715'AND '20190715'
1451214513
GROUP BY t.tradingday)t2
1451314514
ON t1.tradingday = t2.tradingday;
14515+
INFO: GPORCA failed to produce a plan, falling back to planner
14516+
DETAIL: No plan has been computed for required properties
1451414517
tradingday | ins_spaninsarbitrageratio | tradingday | prod_spaninsarbitrageratio
1451514518
------------+---------------------------+------------+----------------------------
1451614519
20190715 | 1 | 20190715 | 0.9233716475
@@ -14763,4 +14766,5 @@ select * from conf;
1476314766
---------
1476414767

1476514768
(1 row)
14769+
1476614770
reset optimizer_trace_fallback;

0 commit comments

Comments
 (0)