From 701ec112c35b3714eb6d14a7633e3e4dba176dbc Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 15 Dec 2023 17:49:50 +0800 Subject: [PATCH] Add test for tidb/issues/49241 (#8480) (#8532) ref pingcap/tiflash#6233, close pingcap/tidb#49241 --- .../mpp/apply_with_late_materialization.test | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/fullstack-test/mpp/apply_with_late_materialization.test diff --git a/tests/fullstack-test/mpp/apply_with_late_materialization.test b/tests/fullstack-test/mpp/apply_with_late_materialization.test new file mode 100644 index 00000000000..c62df328813 --- /dev/null +++ b/tests/fullstack-test/mpp/apply_with_late_materialization.test @@ -0,0 +1,80 @@ +# Copyright 2023 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# https://github.com/pingcap/tidb/issues/49241 +# Preparation. +mysql> drop table if exists test.t; +mysql> drop table if exists test.t1; +mysql> create table test.t(id int, value int); +mysql> create table test.t1(id int, value int); +mysql> insert into test.t values(10,5),(9,5),(8,5),(7,5),(6,5),(5,5),(4,5),(3,5),(2,5),(1,5); +mysql> insert into test.t1 values(2,5); +# insert more than 8192 rows to make sure late materialization is enabled. +mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; +mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; +mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; +mysql> alter table test.t set tiflash replica 1; +mysql> alter table test.t1 set tiflash replica 1; +mysql> analyze table test.t; + +func> wait_table test t t1 + +# Test. + +# MPP +mysql> set @@tidb_allow_mpp=1; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ +mysql> set @@tidb_allow_mpp=1; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ + +# BatchCop +mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 2; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ +mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 2; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ + +# Cop +mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 0; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ +mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 0; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5; ++------+ +| xx | ++------+ +| 5 | ++------+ + +# Clean up. +mysql> drop table if exists test.t; +mysql> drop table if exists test.t1;