stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
862 stars 139 forks source link

bug: sql batch paste and execute, return Out of range #1489

Open davidshiz opened 1 year ago

davidshiz commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

mysql> create table t1 (
    ->         col_signed tinyint,
    ->         col_unsigned tinyint unsigned
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> LOAD DATA LOCAL infile '/stonedb57/install/mysql-test/suite/tianmu/std_data/tinyint_range.tbl' INTO TABLE t1 FIELDS TERMINATED BY '|';
Query OK, 254 rows affected (0.37 sec)
Records: 254  Deleted: 0  Skipped: 0  Warnings: 0

mysql> ALTER TABLE t1 ADD COLUMN col_small_signed SMALLINT;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE t1 ADD COLUMN col_small_unsigned SMALLINT UNSIGNED;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE t1 ADD COLUMN col_med_signed MEDIUMINT;
Query OK, 0 rows affected (0.13 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> UPDATE t1 SET col_small_signed=col_signed + sign(col_signed) * 32000;
Query OK, 254 rows affected (0.02 sec)
Rows matched: 254  Changed: 254  Warnings: 0

mysql> UPDATE t1 SET col_small_unsigned=col_unsigned + 65000;
ERROR 1264 (22003): Out of range value for column 'col_small_signed' at row 1
mysql> UPDATE t1 SET col_med_signed=col_signed + sign(col_signed) * 8388000;
Query OK, 254 rows affected (0.01 sec)
Rows matched: 254  Changed: 254  Warnings: 0

Expected behavior

mysql> UPDATE t1 SET col_small_signed=col_signed + sign(col_signed) * 32000;
Query OK, 254 rows affected (0.05 sec)
Rows matched: 254  Changed: 254  Warnings: 0

mysql> UPDATE t1 SET col_small_unsigned=col_unsigned + 65000;
Query OK, 254 rows affected (0.01 sec)
Rows matched: 254  Changed: 254  Warnings: 0

mysql> UPDATE t1 SET col_med_signed=col_signed + sign(col_signed) * 8388000;
Query OK, 254 rows affected (0.01 sec)
Rows matched: 254  Changed: 254  Warnings: 0

How To Reproduce

create table t1 (
        col_signed tinyint,
        col_unsigned tinyint unsigned
);
LOAD DATA LOCAL infile '/stonedb57/install/mysql-test/suite/tianmu/std_data/tinyint_range.tbl' INTO TABLE t1 FIELDS TERMINATED BY '|';
ALTER TABLE t1 ADD COLUMN col_small_signed SMALLINT;
ALTER TABLE t1 ADD COLUMN col_small_unsigned SMALLINT UNSIGNED;
ALTER TABLE t1 ADD COLUMN col_med_signed MEDIUMINT;
UPDATE t1 SET col_small_signed=col_signed + sign(col_signed) * 32000;
UPDATE t1 SET col_small_unsigned=col_unsigned + 65000;
UPDATE t1 SET col_med_signed=col_signed + sign(col_signed) * 8388000

Environment

root@ub01:~# /stonedb57/install//bin/mysqld --version
/stonedb57/install//bin/mysqld  Ver 5.7.36-StoneDB-v1.0.3 for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 1fa5661e4
        Last commit time: Date:   Thu Mar 23 20:19:17 2023 +0800
        Build time: Date: Wed Mar 29 10:31:02 CST 2023

Are you interested in submitting a PR to solve the problem?

davidshiz commented 1 year ago

It is normal to execute one by one sql