Skip to content

Wrong ENUM value is updated to and seems it's mixed up with ENUM index  #56832

@lance6716

Description

@lance6716

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (id int primary key, c enum('0', '1', '2'));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t values (0,'0'), (1,'1'), (2,'2');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> update t set c = 2 where id = 0;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t;
+----+------+
| id | c    |
+----+------+
|  0 | 1    |
|  1 | 1    |
|  2 | 2    |
+----+------+
3 rows in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.00 sec)

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

as above

3. What did you see instead (Required)

mysql> create table t (id int primary key, c enum('0', '1', '2'));
Query OK, 0 rows affected (0.04 sec)

mysql> insert into t values (0,'0'), (1,'1'), (2,'2');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> update t set c = 2 where id = 0;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t;
+----+------+
| id | c    |
+----+------+
|  0 | 2    |
|  1 | 1    |
|  2 | 2    |
+----+------+
3 rows in set (0.01 sec)

mysql> select version();
+-----------------------------------------+
| version()                               |
+-----------------------------------------+
| 8.0.11-TiDB-v8.4.0-alpha-25-gb02581a7a4 |
+-----------------------------------------+
1 row in set (0.01 sec)

in the last SELECT, the first row is different from MySQL

4. What is your TiDB version? (Required)

Release Version: v8.4.0-alpha-25-gb02581a7a4
Edition: Community
Git Commit Hash: b02581a7a47e98b49901c025767d175ee63fbf23
Git Branch: HEAD
UTC Build Time: 2024-08-23 03:07:52
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.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