|
| 1 | +# Copyright 2023 PingCAP, Ltd. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Preparation. |
| 16 | +=> DBGInvoke __init_fail_point() |
| 17 | + |
| 18 | +mysql> drop table if exists test.t |
| 19 | +mysql> create table test.t (x int, a varchar(50), y int, t time) partition by range (x) (partition p0 values less than (5), partition p1 values less than (10)); |
| 20 | + |
| 21 | +mysql> insert into test.t values (1, 'a', 1, '700:11:11.1234'), (2, 'b', 2, '711:12:12.1234'); |
| 22 | +mysql> insert into test.t select * from test.t; |
| 23 | +mysql> insert into test.t select * from test.t; |
| 24 | +mysql> insert into test.t select * from test.t; |
| 25 | +mysql> insert into test.t select * from test.t; |
| 26 | +mysql> insert into test.t select * from test.t; |
| 27 | +mysql> insert into test.t select * from test.t; |
| 28 | +mysql> insert into test.t select * from test.t; |
| 29 | +mysql> insert into test.t select * from test.t; |
| 30 | +mysql> insert into test.t select * from test.t; |
| 31 | +mysql> insert into test.t select * from test.t; |
| 32 | +mysql> insert into test.t select * from test.t; |
| 33 | +mysql> insert into test.t select * from test.t; |
| 34 | +mysql> insert into test.t select * from test.t; |
| 35 | +mysql> insert into test.t values (8, 'c', 8, '500:21:21.1234'); |
| 36 | + |
| 37 | +mysql> alter table test.t set tiflash replica 1; |
| 38 | +func> wait_table test t |
| 39 | +mysql> analyze table test.t; |
| 40 | + |
| 41 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select count(*) from test.t; |
| 42 | ++----------+ |
| 43 | +| count(*) | |
| 44 | ++----------+ |
| 45 | +| 16385 | |
| 46 | ++----------+ |
| 47 | + |
| 48 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select * from test.t where x >= 5 and x < 10; |
| 49 | ++------+------+------+-----------+ |
| 50 | +| x | a | y | t | |
| 51 | ++------+------+------+-----------+ |
| 52 | +| 8 | c | 8 | 500:21:21 | |
| 53 | ++------+------+------+-----------+ |
| 54 | + |
| 55 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select x, a, y, hour(t) from test.t where x >= 5 and x < 10; |
| 56 | ++------+------+------+---------+ |
| 57 | +| x | a | y | hour(t) | |
| 58 | ++------+------+------+---------+ |
| 59 | +| 8 | c | 8 | 500 | |
| 60 | ++------+------+------+---------+ |
| 61 | + |
| 62 | +=> DBGInvoke __enable_fail_point(force_remote_read_for_batch_cop) |
| 63 | + |
| 64 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select count(*) from test.t; |
| 65 | ++----------+ |
| 66 | +| count(*) | |
| 67 | ++----------+ |
| 68 | +| 16385 | |
| 69 | ++----------+ |
| 70 | + |
| 71 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select * from test.t where x >= 5 and x < 10; |
| 72 | ++------+------+------+-----------+ |
| 73 | +| x | a | y | t | |
| 74 | ++------+------+------+-----------+ |
| 75 | +| 8 | c | 8 | 500:21:21 | |
| 76 | ++------+------+------+-----------+ |
| 77 | + |
| 78 | +mysql> set tidb_partition_prune_mode=dynamic; set tidb_enforce_mpp=1; select x, a, y, hour(t) from test.t where x >= 5 and x < 10; |
| 79 | ++------+------+------+---------+ |
| 80 | +| x | a | y | hour(t) | |
| 81 | ++------+------+------+---------+ |
| 82 | +| 8 | c | 8 | 500 | |
| 83 | ++------+------+------+---------+ |
| 84 | + |
| 85 | +=> DBGInvoke __disable_fail_point(force_remote_read_for_batch_cop) |
| 86 | + |
| 87 | +# Clean up. |
| 88 | +mysql> drop table if exists test.t; |
0 commit comments