Skip to content

Different error code from MySQL when inserting incorrect bigint value #17832

Open
@zhangysh1995

Description

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

Metadata

Assignees

Labels

challenge-programgood first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.severity/minorsig/executionSIG executiontype/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