Mysql – LOAD DATA statement returns a syntax error a fraction of the time

database-internalserrorsMySQLmysql-5.5

MySQL 5.5.32, MyISAM

A LOAD DATA INFILE statement usually executes and returns normally, succeeding at loading the data. On rare occasion it fails, returning a generic syntax error, always indicating the same character as the problem spot.

ERROR 1064 (42000) at line 36: You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the right syntax to 
use near 'ull, @field_name)' 

I have no reason to believe there is a syntax error because the large majority of the time it succeeds, and it always succeeds on MySQL 5.5.19 and other versions. So all of these details might be red herrings. But, for what it's worth, that line in the statement is

field_name = if(@field_name='None', null, @field_name);

The question is whether this is a known bug, or a theoretically explainable behavior, and not what the syntax error is. Are there conditions in a database, or perhaps a file or filesystem, that could generate the same generic syntax error inconsistently but persistently like this?

Best Answer

See if this works as a workaround:

field_name = NULLIF(@field_name, 'None');

Suggest upgrading to 5.6, though I doubt if something this obscure is fixed.

Also, you should change from MyISAM to InnoDB.