@@ -29,7 +29,7 @@ var LoadDataScripts = []ScriptTest{
2929 Name : "LOAD DATA with ENCLOSED BY and ESCAPED BY parsing" ,
3030 SetUpScript : []string {
3131 "create table t1(pk int primary key, c1 longtext)" ,
32- "LOAD DATA INFILE './testdata/loaddata_9969 .dat' INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\" ' ESCAPED BY '\" '" ,
32+ "LOAD DATA INFILE './testdata/loaddata_term_in_field .dat' INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\" ' ESCAPED BY '\" '" ,
3333 "create table t2(pk int primary key, c1 longtext)" ,
3434 "LOAD DATA INFILE './testdata/loaddata_escape.dat' INTO TABLE t2 FIELDS TERMINATED BY ',' ENCLOSED BY '\" ' ESCAPED BY '\\ \\ '" ,
3535 "create table t3(a varchar(20), b varchar(20))" ,
@@ -40,6 +40,14 @@ var LoadDataScripts = []ScriptTest{
4040 "LOAD DATA INFILE './testdata/loaddata_single_quotes.dat' INTO TABLE t5 FIELDS TERMINATED BY ',' ENCLOSED BY ''''" ,
4141 "create table t6(pk int, a varchar(20), b varchar(20))" ,
4242 "LOAD DATA INFILE './testdata/loaddata_nulls.dat' INTO TABLE t6 FIELDS TERMINATED BY ','" ,
43+ "create table t7(i int, v text)" ,
44+ "LOAD DATA INFILE './testdata/loaddata_eof.dat' INTO TABLE t7 FIELDS TERMINATED BY ',' ENCLOSED BY '$' ESCAPED BY '$'" ,
45+ "create table t8(i int, v text)" ,
46+ "LOAD DATA INFILE './testdata/loaddata_enc_esc_eq.dat' INTO TABLE t8 FIELDS TERMINATED BY ',' ENCLOSED BY '$' ESCAPED BY '$'" ,
47+ "create table t9(i int, v text)" ,
48+ "LOAD DATA INFILE './testdata/loaddata_lborder_null.dat' INTO TABLE t9 FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY ''" ,
49+ "create table t10(i int, v text)" ,
50+ "LOAD DATA INFILE './testdata/loaddata_null_in_field.dat' INTO TABLE t10 FIELDS TERMINATED BY ',' ENCLOSED BY '\" ' ESCAPED BY ''" ,
4351 },
4452 Assertions : []ScriptTestAssertion {
4553 {
@@ -67,7 +75,7 @@ var LoadDataScripts = []ScriptTest{
6775 },
6876 },
6977 {
70- Query : "select * from t5" , // order by a breaks
78+ Query : "select * from t5" ,
7179 Expected : []sql.Row {
7280 {"Field A" , "Field B" },
7381 {"Field 1" , "Field 2" },
@@ -84,10 +92,36 @@ var LoadDataScripts = []ScriptTest{
8492 {4 , nil , nil },
8593 },
8694 },
95+ {
96+ Query : "select * from t7" ,
97+ Expected : []sql.Row {
98+ {1 , "foo $0 $b $n $t $Z $N bar" },
99+ {2 , "$foo $ bar$" },
100+ },
101+ },
102+ {
103+ Query : "select * from t8" ,
104+ Expected : []sql.Row {
105+ {1 , "foo $0 $b $n $t $Z $N bar" },
106+ {2 , "foo $ bar" },
107+ },
108+ },
109+ {
110+ Query : "select * from t9" ,
111+ Expected : []sql.Row {
112+ {1 , "\x00 foo bar" },
113+ },
114+ },
115+ {
116+ Query : "select * from t10" ,
117+ Expected : []sql.Row {
118+ {1 , "foo \x00 bar" },
119+ },
120+ },
87121 },
88122 },
89123 {
90- Name : "LOAD DATA applies column defaults when \\ N provided" ,
124+ Name : "LOAD DATA does not apply column defaults when \\ N provided" ,
91125 SetUpScript : []string {
92126 "create table t (pk int primary key, c1 int default 1, c2 int)" ,
93127 // Explicitly use Windows-style line endings to be robust on Windows CI
@@ -96,7 +130,7 @@ var LoadDataScripts = []ScriptTest{
96130 Assertions : []ScriptTestAssertion {
97131 {
98132 Query : "select * from t" ,
99- Expected : []sql.Row {{1 , 1 , 1 }},
133+ Expected : []sql.Row {{1 , nil , 1 }},
100134 },
101135 },
102136 },
0 commit comments