【TiDB 使用环境】生产环境
【TiDB 版本】
【操作系统】
【部署方式】v8.5.1
【问题复现路径】增加索引 CREATE INDEX idx_create_at ON cell (create_at);
该字段类型为timestamp
create_at timestamp DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间’,
【遇到的问题:问题现象及影响】
ERROR 1105 (HY000): json: cannot unmarshal object into Go value of type json.RawMessage
xfworld
(魔幻之翼)
2
用 Date,或者 DateTime 类型试试看,
这肯定是bug了,恭喜抓到大虫子了
1 个赞
AN_12
(Xiaoqiao)
6
必现的话 可以给他们提Bug单了 ,看样子是内部错误
1 个赞
WalterWj
(王军 - PingCAP)
9
mysql --comments --host 127.0.0.1 --port 4000 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 513802246
Server version: 8.0.11-TiDB-v8.5.1 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(root@127.0.0.1) [(none)]>-- 创建测试数据库
Query OK, 0 rows affected (0.00 sec)
(root@127.0.0.1) [(none)]>DROP DATABASE IF EXISTS test_index_bug;
Query OK, 0 rows affected (0.01 sec)
(root@127.0.0.1) [(none)]>CREATE DATABASE test_index_bug;
Query OK, 0 rows affected (0.11 sec)
(root@127.0.0.1) [(none)]>USE test_index_bug;
Database changed
(root@127.0.0.1) [test_index_bug]>-- Step 1: 创建测试表
Query OK, 0 rows affected (0.00 sec)
(root@127.0.0.1) [test_index_bug]>CREATE TABLE cell (
-> id BIGINT PRIMARY KEY AUTO_INCREMENT,
-> name VARCHAR(100),
-> create_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-> update_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-> );
Query OK, 0 rows affected (0.09 sec)
(root@127.0.0.1) [test_index_bug]>
(root@127.0.0.1) [test_index_bug]>-- Step 2: 插入测试数据
Query OK, 0 rows affected (0.00 sec)
(root@127.0.0.1) [test_index_bug]>INSERT INTO cell (name) VALUES ('test1');
Query OK, 1 row affected (0.03 sec)
(root@127.0.0.1) [test_index_bug]>INSERT INTO cell (name) VALUES ('test2');
Query OK, 1 row affected (0.00 sec)
(root@127.0.0.1) [test_index_bug]>INSERT INTO cell (name) VALUES ('test3');
Query OK, 1 row affected (0.01 sec)
(root@127.0.0.1) [test_index_bug]>INSERT INTO cell (name, create_at) VALUES ('test4', '2024-01-01 10:00:00');
Query OK, 1 row affected (0.01 sec)
(root@127.0.0.1) [test_index_bug]>INSERT INTO cell (name, create_at) VALUES ('test5', NULL);
Query OK, 1 row affected (0.01 sec)
(root@127.0.0.1) [test_index_bug]>
(root@127.0.0.1) [test_index_bug]>-- Step 3: 查看表结构和数据
Query OK, 1 row affected (0.00 sec)
(root@127.0.0.1) [test_index_bug]>SHOW CREATE TABLE cell;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cell | CREATE TABLE `cell` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`create_at` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30001 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
(root@127.0.0.1) [test_index_bug]>SELECT * FROM cell;
+----+-------+---------------------+---------------------+
| id | name | create_at | update_at |
+----+-------+---------------------+---------------------+
| 1 | test1 | 2025-11-07 10:54:25 | 2025-11-07 10:54:25 |
| 2 | test2 | 2025-11-07 10:54:25 | 2025-11-07 10:54:25 |
| 3 | test3 | 2025-11-07 10:54:25 | 2025-11-07 10:54:25 |
| 4 | test4 | 2024-01-01 10:00:00 | 2025-11-07 10:54:25 |
| 5 | test5 | NULL | 2025-11-07 10:54:25 |
+----+-------+---------------------+---------------------+
5 rows in set (0.00 sec)
(root@127.0.0.1) [test_index_bug]>
(root@127.0.0.1) [test_index_bug]>-- Step 4: 尝试创建索引(复现问题)
Query OK, 0 rows affected (0.00 sec)
(root@127.0.0.1) [test_index_bug]>CREATE INDEX idx_create_at ON cell (create_at);
Query OK, 0 rows affected (2.31 sec)
8.5.1 没复现。。。麻烦了。。。
lllzd
(时光旅行者)
12
此问题已在 TiDB v8.5.2 版本中修复,建议用新版本再试试。
1 个赞