Bug #39616 Missing quotes from .CSV crashes server
Submitted: 23 Sep 2008 19:04 Modified: 2 Feb 2009 15:29
Reporter: Scott Noyes Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: CSV Severity:S3 (Non-critical)
Version:5.0.68 OS:Linux
Assigned to: V Venkateswaran CPU Architecture:Any

[23 Sep 2008 19:04] Scott Noyes
Description:
Editing the .CSV file and leaving out quotes from around an integer field crashes the server.

How to repeat:
CREATE TABLE test.t (id int not null, d varchar(50) NOT NULL) ENGINE=csv;

echo 2,\"sans quotes\" > data/test/t.CSV
mysql test -e "SELECT * FROM t"

ERROR 2013 (HY000) at line 1: Lost connection to MySQL server during query
080923 20:43:26  mysqld restarted

Including quotes around the number works correctly:

echo \"3\",\"with quotes\" > data/test/t.CSV
mysql test -e "SELECT * FROM t"

+----+-------------+
| id | d           |
+----+-------------+
|  3 | with quotes |
+----+-------------+

Suggested fix:
The server should not crash. Either the server should simply report a corrupt file, or (preferably) be able to handle a CSV file without quotes around numeric fields.
[11 Nov 2008 12: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/58450

2712 V Narayanan	2008-11-11
      Bug#39616: Missing quotes from .CSV crashes server
      
      When a CSV file contained comma separated elements 
      that were not enclosed in quotes, it was causing the
      mysql server to crash.
      
      The algorithm that parsed the content of a row in
      mysql 5.0 was assuming that the values of the fields
      in a .CSV file will be enclosed in quotes and will be
      separated by commas.
      
      This was causing the algorithm to fail when the content
      of the file resembled the following
      3,"with quotes"
      The CSV engine that is part of mysql 5.0 was expecting
      the above to be
      "3","with quotes"
      
      The above is just one example of where the engine was
      failing for what would be recognized as a valid .CSV 
      file content otherwise.
      
      The proposed fix changes the previous algorithm being used
      to parse rows from the .CSV file to handle two separate
      cases
      
      1) When the current field of the row is enclosed in quotes
      2) When the current field of the row is not enclosed in quotes
[12 Nov 2008 14:59] Ingo Strüwing
Please see email.
[18 Nov 2008 6:01] 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/59028

2718 V Narayanan	2008-11-18
      Bug#39616: Missing quotes from .CSV crashes server
            
      When a CSV file contained comma separated elements 
      that were not enclosed in quotes, it was causing the
      mysql server to crash.
            
      The old algorithm that parsed the content of a row in
      mysql 5.0 was assuming that the values of the fields
      in a .CSV file will be enclosed in quotes and will be
      separated by commas.
      
      This was causing the old algorithm to fail when the 
      content of the file resembled the following
      3,"sans quotes"
      The CSV engine that is part of mysql 5.0 was expecting
      the above to be
      "3","sans quotes"
            
      The above is just one example of where the engine was
      failing for what would be recognized as a valid .CSV 
      file content otherwise.
            
      The proposed fix changes the old algorithm being used
      to parse rows from the .CSV file to handle two separate
      cases
      
      1) When the current field of the row is enclosed in quotes
      2) When the current field of the row is not enclosed in 
         quotes
[6 Jan 2009 13:56] Bugs System
Pushed into 5.0.76 (revid:joro@sun.com-20090105160414-8q9j4bi1klkfwiup) (version source revid:azundris@mysql.com-20081230114734-nmsc37ak330zlygn) (merge vers: 5.0.76) (pib:6)
[15 Jan 2009 6:35] Bugs System
Pushed into 5.1.31 (revid:joro@sun.com-20090115053147-tx1oapthnzgvs1ro) (version source revid:azundris@mysql.com-20081230114838-cn52tu180wcrvh0h) (merge vers: 5.1.31) (pib:6)
[19 Jan 2009 11:27] Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090115073240-1wanl85vlvw2she1) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:05] Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:11] Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)
[20 Jan 2009 18:57] Bugs System
Pushed into 6.0.10-alpha (revid:joro@sun.com-20090119171328-2hemf2ndc1dxl0et) (version source revid:azundris@mysql.com-20081230114916-c290n83z25wkt6e4) (merge vers: 6.0.9-alpha) (pib:6)
[2 Feb 2009 15:29] Tony Bedford
An entry has been added to the 6.0.10, 5.1.31 and 5.0.76 changelogs:

The server crashed if an integer field in a CSV file did not have delimiting quotes.