Bug #27670 | LOAD DATA INFILE processing does not respect TIMESTAMP default value | ||
---|---|---|---|
Submitted: | 5 Apr 2007 16:03 | Modified: | 10 May 2007 17:58 |
Reporter: | Shawn Green | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 5.0.38 enterprise | OS: | Any |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
Tags: | DEFAULT, LOAD DATA INFILE, timestamp |
[5 Apr 2007 16:03]
Shawn Green
[7 May 2007 20:55]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/26251 ChangeSet@1.2475, 2007-05-08 00:52:12+04:00, evgen@moonbone.local +3 -0 Bug#27670: LOAD DATA does not set TIMESTAMP default value when there is not enough data. The LOAD DATA sets the current time in the TIMESTAMP field with CURRENT_TIMESTAMP default value when the field is detected to be a null. But when the LOAD DATA command loads data from a file that doesn't contain enough data for all fields then the rest of fields are simply set to null without any check. This leads to no value being inserted to such TIMESTAMP field. Now the read_sep_field() and the read_fixed_length() functions set current time to the TIMESTAMP field with CURRENT_TIMESTAMP default value in all cases when a NULL value is loaded to the field.
[8 May 2007 20:25]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/26331 ChangeSet@1.2475, 2007-05-09 00:23:16+04:00, evgen@moonbone.local +3 -0 Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a TIMESTAMP field when no value has been provided. The LOAD DATA sets the current time in the TIMESTAMP field with CURRENT_TIMESTAMP default value when the field is detected as a null. But when the LOAD DATA command loads data from a file that doesn't contain enough data for all fields then the rest of fields are simply set to null without any check. This leads to no value being inserted to such TIMESTAMP field. Now the read_sep_field() and the read_fixed_length() functions set current time to the TIMESTAMP field with CURRENT_TIMESTAMP default value in all cases when a NULL value is loaded to the field.
[10 May 2007 6:38]
Bugs System
Pushed into 5.1.19-beta
[10 May 2007 6:52]
Bugs System
Pushed into 5.0.42
[10 May 2007 17:58]
Paul DuBois
Noted in 5.0.42, 5.1.19 changelogs. LOAD DATA did not use CURRENT_TIMESTAMP as the default value for a TIMESTAMP column for which no value was provided.
[13 Nov 2008 18:33]
Anand Ganapathy
The fix doesnt seem to work in mysql 5.0.67 or 5.1.26 community release. Has this been checked into these releases ? Tried a similar test case as listed in the bug and I see only zeros for the timestamp column. mysql> show create table tableA \G *************************** 1. row *************************** Table: tableA Create Table: CREATE TABLE `tablea` ( `A` varchar(2) collate latin1_general_cs NOT NULL, `B` varchar(1) collate latin1_general_cs NOT NULL, `F_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`A`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs 1 row in set (0.00 sec) mysql> load data infile '../../test.csv' into table tableA fields terminated by ',' lines terminated by '\n'; Query OK, 3 rows affected, 6 warnings (0.00 sec) Records: 3 Deleted: 0 Skipped: 0 Warnings: 6 mysql> select * from tableA \G *************************** 1. row *************************** A: AC B: N F_timestamp: 0000-00-00 00:00:00 *************************** 2. row *************************** A: AP B: N F_timestamp: 0000-00-00 00:00:00 *************************** 3. row *************************** A: BD B: N F_timestamp: 0000-00-00 00:00:00 3 rows in set (0.00 sec)
[6 Aug 2011 23:03]
Rene' Cannao'
Reproduced also on 5.1.56