pingcap/tidb

Different error code from MySQL when inserting incorrect bigint value

Open

#17 832 ouverte le 7 juin 2020

Voir sur GitHub
 (16 commentaires) (0 réactions) (1 assigné)Go (6 186 forks)batch import
challenge-programgood first issuehelp wantedseverity/minorsig/executiontype/bug

Métriques du dépôt

Stars
 (40 090 stars)
Métriques de merge PR
 (Merge moyen 14j 4h) (346 PRs mergées en 30 j)

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

  • @SunRunAway

Guide contributeur