Skip to content

doesn't handle collate for min/max(enum/set column) #31638

@wjhuang2016

Description

@wjhuang2016

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table tt(a char(10), b enum('a', 'B', 'c'), c set('a', 'B', 'c'), d json) collate utf8mb4_general_ci;
insert into tt values ("a", "a", "a", JSON_OBJECT("a", "a"));
insert into tt values ("A", "A", "A", JSON_OBJECT("A", "A"));
insert into tt values ("b", "b", "b", JSON_OBJECT("b", "b"));
insert into tt values ("B", "B", "B", JSON_OBJECT("B", "B"));
insert into tt values ("c", "c", "c", JSON_OBJECT("c", "c"));
insert into tt values ("C", "C", "C", JSON_OBJECT("C", "C"));
split table tt by (0), (1), (2), (3), (4), (5);
select min(b) from tt;
select max(b) from tt;
select min(c) from tt;
select max(c) from tt;

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

mysql> select min(b) from tt;
+--------+
| min(b) |
+--------+
| a      |
+--------+
1 row in set (0.00 sec)

mysql> select max(b) from tt;
+--------+
| max(b) |
+--------+
| c      |
+--------+
1 row in set (0.00 sec)

mysql> select min(c) from tt;
+--------+
| min(c) |
+--------+
| a      |
+--------+
1 row in set (0.00 sec)

mysql> select max(c) from tt;
+--------+
| max(c) |
+--------+
| c      |
+--------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select min(b) from tt;
+--------+
| min(b) |
+--------+
| B      |
+--------+
1 row in set (0.02 sec)

mysql> select max(b) from tt;
+--------+
| max(b) |
+--------+
| c      |
+--------+
1 row in set (0.00 sec)

mysql> select min(c) from tt;
+--------+
| min(c) |
+--------+
| B      |
+--------+
1 row in set (0.00 sec)

mysql> select max(c) from tt;
+--------+
| max(c) |
+--------+
| c      |
+--------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Assignees

Labels

affects-4.0This bug affects 4.0.x versions.affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.severity/criticalsig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions