Skip to content

query gets incorrect result caused by hash partition #50044

@wjhuang2016

Description

@wjhuang2016

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t4e32b983` (
  `col_29` tinyint(4) DEFAULT NULL,
  UNIQUE KEY `idx_25` (`col_29`),
  KEY `idx_26` (`col_29`),
  UNIQUE KEY `idx_27` (`col_29`),
  UNIQUE KEY `idx_28` (`col_29`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
PARTITION BY HASH (`col_29`) PARTITIONS 7;
INSERT INTO `t4e32b983` VALUES (-1), (11), (-128), (39), (-46), (38), (-102), (-99), (-87), (-127), (-89), (43), (108), (59), (0), (24), (101), (37), (-103), (90), (-95), (-44), (123), (124), (-123), (-52), (-49), (-98), (-104), (-68), (2), (-24), (67), (89), (1), (-65), (36), (-109), (41), (5), (98), (-63), (-14), (127), (-6), (121), (14), (-122);

select * from t4e32b983 where col_29 between -2 and 1;

2. What did you expect to see? (Required)

Three rows

mysql> select count(*) from (select col_29 between -2 and 1 as a from t4e32b983) t where a = 1;
+----------+
| count(*) |
+----------+
|        3 |
+----------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select * from t4e32b983 where col_29 between -2 and 1;
Empty set (0.01 sec)

mysql> select * from t4e32b983 where col_29 between -2 and 2;
+--------+
| col_29 |
+--------+
|      2 |
+--------+
1 row in set (0.00 sec)

mysql> select * from t4e32b983 where col_29 between -2 and 3;
+--------+
| col_29 |
+--------+
|      0 |
|      2 |
+--------+
2 rows in set (0.01 sec)

mysql> select * from t4e32b983 where col_29 between -2 and 4;
+--------+
| col_29 |
+--------+
|      2 |
|      0 |
|     -1 |
|      1 |
+--------+
4 rows in set (0.01 sec)

4. What is your TiDB version? (Required)

33480e8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions