LOAD DATA INFILE syntax error on different order of params 'starting by' and 'terminated by' #8706
Closed
Description
Env:
Docker image - dolthub/dolt-sql-server:latest
root@c0ca5804a5c6:/var/lib/dolt# dolt version
dolt version 1.45.0
Host OS: arch linux, amd64
Steps:
create a csv file for import:
echo -e '1;"test1"\n2;"test2"' > example.csv
try to import data with firstly 'STARTING BY' then 'TERMINATED BY':
LOAD DATA LOCAL INFILE '/var/lib/dolt/example.csv' INTO TABLE `test_load_data` CHARACTER SET binary FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES STARTING BY '' TERMINATED BY '\n' (id,value);
Such query works perfectly.
Then, swap 'TERMINATED BY' and 'STARTING BY':
test/main*> LOAD DATA LOCAL INFILE '/var/lib/dolt/example.csv' INTO TABLE `test_load_data` CHARACTER SET binary FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (id,value);
Error parsing SQL:
syntax error at position 208 near 'STARTING'
CLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (id,value)
^
No problems with MySQL (9) when order is reversed.
Originally, problem was faced with usage of sqlc for Go, which uses such order from in external lib - https://github.com/hexon/mysqltsv/blob/main/mysqltsv.go#L17, so there is no visible way to override it.