pingcap/tidb

Different error code from MySQL when inserting incorrect bigint value

Open

#17,832 创建于 2020年6月7日

在 GitHub 查看
 (16 评论) (0 反应) (1 负责人)Go (6,186 fork)batch import
challenge-programgood first issuehelp wantedseverity/minorsig/executiontype/bug

仓库指标

Star
 (40,090 star)
PR 合并指标
 (平均合并 14天 4小时) (30 天内合并 346 个 PR)

描述

Description

Bug Report

1. Minimal reproduce step (Required)

drop table if exists t0;create table t0 (col0 VARCHAR(0), col1 TINYINT, col2 TEXT, col3 BLOB, col4 BIGINT);insert into t0 values (NULL, '-128', 't', 'b', '2 ^ 63 - 1');

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

From both errors it is clear I shouldn't use 2^63 in the value. But I'm confused with the meaning of the error.

-- MySQL 5.7
mysql> drop table if exists t0;create table t0 (col0 VARCHAR(0), col1 TINYINT, col2 TEXT, col3 BLOB, col4 BIGINT);insert into t0 values (NULL, '-128', 't', 'b', '2 ^ 63 - 1');
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.03 sec)

ERROR 1265 (01000): Data truncated for column 'col4' at row 1

-- MySQL 8
mysql> drop table if exists t0;create table t0 (col0 VARCHAR(0), col1 TINYINT, col2 TEXT, col3 BLOB, col4 BIGINT);insert into t0 values (NULL, '-128', 't', 'b', '2 ^ 63 - 1');
Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.08 sec)

ERROR 1265 (01000): Data truncated for column 'col4' at row 1

3. What did you see instead (Required)

mysql> drop table if exists t0;create table t0 (col0 VARCHAR(0), col1 TINYINT, col2 TEXT, col3 BLOB, col4 BIGINT);insert into t0 values (NULL, '-128', 't', 'b', '2 ^ 63 - 1');
Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.01 sec)

ERROR 1366 (HY000): Incorrect bigint value: '2 ^ 63 - 1' for column 'col4' at row 1

4. Affected version (Required)

commit 8369ffd500f3fb235d8b584ac4298b2e59d8db55 (HEAD -> master, origin/master, origin/HEAD)
Author: Soup <ilovesoup@gmail.com>
Date:   Tue May 26 15:38:29 2020 +0800

5. Root Cause Analysis

SIG slack channel

#sig-exec

Score

  • 300

Mentor

  • @SunRunAway

贡献者指南