|
| 1 | +// Copyright 2019 PingCAP, Inc. |
| 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 | +package logicalop_test |
| 16 | + |
| 17 | +import ( |
| 18 | + "testing" |
| 19 | + |
| 20 | + "github.com/pingcap/tidb/pkg/testkit" |
| 21 | +) |
| 22 | + |
| 23 | +func TestIssue58743(t *testing.T) { |
| 24 | + store := testkit.CreateMockStore(t) |
| 25 | + |
| 26 | + tk := testkit.NewTestKit(t, store) |
| 27 | + |
| 28 | + tk.MustExec("use test") |
| 29 | + tk.MustExec(` |
| 30 | + CREATE TABLE tlf5d55361 ( |
| 31 | + col_9 time NOT NULL, |
| 32 | + col_10 float NOT NULL, |
| 33 | + col_11 json NOT NULL, |
| 34 | + col_12 date NOT NULL, |
| 35 | + col_13 json NOT NULL, |
| 36 | + col_14 tinyint NOT NULL, |
| 37 | + col_15 date DEFAULT NULL, |
| 38 | + col_16 tinyblob NOT NULL, |
| 39 | + col_17 time DEFAULT '03:51:26', |
| 40 | + PRIMARY KEY (col_14, col_9, col_10) /*T![clustered_index] CLUSTERED */ |
| 41 | + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci |
| 42 | + PARTITION BY RANGE (col_14) |
| 43 | + ( |
| 44 | + PARTITION p0 VALUES LESS THAN (-128), |
| 45 | + PARTITION p1 VALUES LESS THAN (-84), |
| 46 | + PARTITION p2 VALUES LESS THAN (-41), |
| 47 | + PARTITION p3 VALUES LESS THAN (-30) |
| 48 | + ); |
| 49 | + `) |
| 50 | + tk.MustExec(` |
| 51 | + CREATE TABLE td8d55878 ( |
| 52 | + col_26 datetime DEFAULT NULL, |
| 53 | + col_27 time DEFAULT NULL, |
| 54 | + col_28 json DEFAULT NULL, |
| 55 | + col_29 char(186) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT '4-BJKi', |
| 56 | + col_30 date NOT NULL DEFAULT '1998-07-28', |
| 57 | + col_31 datetime NOT NULL |
| 58 | + ) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci; |
| 59 | + `) |
| 60 | + |
| 61 | + tk.MustQuery(` |
| 62 | + WITH cte_3 (col_128) AS ( |
| 63 | + SELECT /*+ USE_INDEX_MERGE(td8d55878 tlf5d55361)*/ |
| 64 | + MIN(td8d55878.col_26) AS r0 |
| 65 | + FROM tlf5d55361 |
| 66 | + JOIN td8d55878 |
| 67 | + GROUP BY tlf5d55361.col_17 |
| 68 | + HAVING tlf5d55361.col_17 <= '20:22:14.00' OR tlf5d55361.col_17 BETWEEN '21:56:23.00' AND '19:42:43.00' |
| 69 | + ORDER BY r0 |
| 70 | + LIMIT 772780933 |
| 71 | + ), |
| 72 | + cte_4 (col_129) AS ( |
| 73 | + SELECT /*+ HASH_AGG()*/ |
| 74 | + SUM(tlf5d55361.col_14) AS r0 |
| 75 | + FROM td8d55878 |
| 76 | + JOIN tlf5d55361 ON tlf5d55361.col_17 = td8d55878.col_27 |
| 77 | + GROUP BY td8d55878.col_30 |
| 78 | + HAVING ISNULL(td8d55878.col_30) OR td8d55878.col_30 BETWEEN '2009-09-08' AND '1980-11-17' |
| 79 | + ) |
| 80 | + SELECT SUM((cte_4.col_129 IN (0.65, 564617.3335, 45, 0.319, 0.4427)) IS TRUE) |
| 81 | + FROM cte_4 |
| 82 | + JOIN cte_3; |
| 83 | + `).Equal(nil) |
| 84 | +} |
0 commit comments