Bug #15239 | Problem with LOAD DATA Infile | ||
---|---|---|---|
Submitted: | 25 Nov 2005 1:21 | Modified: | 27 Nov 2005 14:08 |
Reporter: | Friedrich Stockebrand | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.0.16 | OS: | Windows (windows xp) |
Assigned to: | CPU Architecture: | Any |
[25 Nov 2005 1:21]
Friedrich Stockebrand
[25 Nov 2005 7:51]
Valeriy Kravchuk
Thank you for a problem report. What exact 5.0.x version do you use, by the way? Is '.' OK in your value 42.95 for the decimal separator according to your locale settings? Don't you need to use ',' instead?
[27 Nov 2005 14:08]
Valeriy Kravchuk
The problem is empty (<TAB><TAB>) value for your Sollconto column. This problem is documented (http://dev.mysql.com/doc/refman/5.0/en/problems-with-null.html): "When reading data with LOAD DATA INFILE, empty or missing columns are updated with ''. If you want a NULL value in a column, you should use \N in the data file. The literal word “NULL” may also be used under some circumstances. See Section 13.2.5, “LOAD DATA INFILE Syntax”." So, you get '' from your empty field in the file, and it is not good for InnoDB table in the (default) STRICT_TRANS_TABLES mode on Windows: mysql> show variables like 'sql%'; +---------------+----------------------------------------------------------------+ | Variable_name | Value | +---------------+----------------------------------------------------------------+ | sql_mode | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | | sql_notes | ON | | sql_warnings | ON | +---------------+----------------------------------------------------------------+ 3 rows in set (0.06 sec) mysql> drop table tttt; Query OK, 0 rows affected (0.17 sec) mysql> create table tttt (c1 int unsigned null); Query OK, 0 rows affected (0.07 sec) mysql> insert into tttt values(''); ERROR 1264 (22003): Out of range value adjusted for column 'c1' at row 1 As explained in http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html: "Strict mode controls how MySQL handles input values that are invalid or missing. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a column that has no explicit DEFAULT clause in its definition. For transactional tables, an error occurs for invalid or missing values in a statement when either of the STRICT_ALL_TABLES or STRICT_TRANS_TABLES modes are enabled. The statement is aborted and rolled back." So, I believe, it is not a bug. Note, that '' (empty string) is OK for VARCHAR columns, as demonstrated by your second test case. And, in MySQL, '' is not the same as NULL.