Bug #18729 LOAD DATA does NOT take all records!
Submitted: 3 Apr 2006 8:14 Modified: 9 Jun 2007 16:25
Reporter: Wolfgang Schrecker Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:mysql-standard-5.0.15-linux-i686-glibc23 OS:Linux (SuSe enterprise linux)
Assigned to: CPU Architecture:Any

[3 Apr 2006 8:14] Wolfgang Schrecker
Description:
with a C program, I prepare data and load it into MySQL.
E.g. there are 111570 rows in the file, but only 111560 are loaded.
When I just take the last, missing rows and load 'em using the mysql client,
they just load fine.
But from the C-Programm always the last 2 - 10  rows are missing,
when I load lots of rows!

---------------------------------------------------------------------------------
here is part of the code:
(process_statement ist from DuBios 3rd edition MySQL Sams Publishing)

          sprintf( addfilename, "D%02.02d", mytime->tm_mday );
          strcat( tablename, addfilename );
          sprintf( querystring, "CREATE TABLE IF NOT EXISTS %s LIKE %s",
            tablename , outfilename );
          if( verbose )
            fprintf( stderr, "\nQUERY: %s\n", querystring );
          process_statement( conn, querystring );

      sprintf( querystring,
        "LOAD DATA LOCAL INFILE '%s' INTO TABLE %s FIELDS TERMINATED BY '%c' ",
          outfilename, tablename , DELIMITER );
      if( verbose )
        fprintf( stderr, "\nQUERY: %s\n", querystring );
      process_statement( conn, querystring );

      sprintf( querystring, "SHOW WARNINGS" );
      if( verbose )
        fprintf( stderr, "\nQUERY: %s\n", querystring );
      process_statement( conn, querystring );
---------------------------------------------------------------------------------
here is the log:

111570 record(s) read!
starting DB processing for TRX03!

QUERY: CREATE TABLE IF NOT EXISTS TRX03D03 LIKE TRX03
0 rows affected

QUERY: LOAD DATA LOCAL INFILE 'TRX03' INTO TABLE TRX03D03 FIELDS TERMINATED BY '|'
111560 rows affected

QUERY: SHOW WARNINGS
+---------+------+-------------------------------------------------+
| Level   | Code | Message                                         |
+---------+------+-------------------------------------------------+
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
| Warning | 1261 | Row 111560 doesn't contain data for all columns |
+---------+------+-------------------------------------------------+
11 rows returned
closing database!

How to repeat:
load lots of rows (over 100000 ?) from a C-Program
[3 Apr 2006 9:20] Valeriy Kravchuk
Thank you for a problem report. Please, send the SHOW CREATE TABLE TRX03 results and, surely, several lines of data you are trying to load, including that line 111560.
[3 May 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 May 2006 11:10] Wolfgang Schrecker
It seems, when I load a file with over 100000 rows from a C - programm,
that at the end, between 1-5 records are NOT properly loading,
claiming
Warning | 1261 | Row 124377 doesn't contain data for all columns 
but when loading exactly the same file with the mysql client, it works fine.
Yes, I checked the data carefilly, no column is missing !
[8 May 2006 14:20] Valeriy Kravchuk
Please, check with the newer version, 5.0.21. If the problem is still repeatable with that version, please, send the SHOW CREATE TABLE TRX03 results
and, surely, several lines of data you are trying to load, including that line
111560.
[8 Jun 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 May 2007 20:52] John Common
Row 14 doesn't contain data for all columns, I am getting this error when I am trying to load data into the table, really frustrating, how do I work around this.
[9 Jun 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[22 Aug 2007 22:21] Sean Pringle
Just a possibility - A similar problem was seen with a Perl script generating a CSV file;  the script was not closing/flushing the file before issuing the LOAD DATA INFILE statement, hence some data was always missing at the end.  Inspecting the file afterward of course showed no apparent problems as by then the script had exited, closing the file automatically.