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: load data FIELDS TERMINATED BY and FIELDS ENCLOSED BY values are both empty (''), return error #1866

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 (a int default 100, b int, c varchar(60));
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t1;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                        |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` int(11) DEFAULT '100',
  `b` int(11) DEFAULT NULL,
  `c` varchar(60) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> load data infile '/stonedb57/install/mysql-test/std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b);
ERROR 1265 (01000): Data truncated for column 'a' at row 1

Expected behavior

No response

How To Reproduce

No response

Environment

[root@stonedb-test bin]# ./mysqld --version
./mysqld  Ver 5.7.36-StoneDB-v1.0.1 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: 12fa952
        Last commit time: Date:   Sat Jun 3 10:07:20 2023 +0800
        Build time: Date: Mon Jun  5 08:49:16 UTC 2023

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

davidshiz commented 1 year ago

ref https://dev.mysql.com/doc/refman/5.7/en/load-data.html If the FIELDS TERMINATED BY and FIELDS ENCLOSED BY values are both empty (''), a fixed-row (nondelimited) format is used. With fixed-row format, no delimiters are used between fields (but you can still have a line terminator). Instead, column values are read and written using a field width wide enough to hold all values in the field. For TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT, the field widths are 4, 6, 8, 11, and 20, respectively, no matter what the declared display width is.