pingcap/tidb

Different error code from MySQL when inserting incorrect bigint value

Open

#17.832 aperta il 7 giu 2020

Vedi su GitHub
 (16 commenti) (0 reazioni) (1 assegnatario)Go (6186 fork)batch import
challenge-programgood first issuehelp wantedseverity/minorsig/executiontype/bug

Metriche repository

Star
 (40.090 star)
Metriche merge PR
 (Merge medio 14g 4h) (346 PR mergiate in 30 g)

Descrizione

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

Guida contributor