@@ -1017,44 +1017,50 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10171017 })
10181018
10191019 tests := []struct {
1020- file string
1021- query string
1022- exp string
1023- err * errors.Kind
1024- skip bool
1020+ file string
1021+ query string
1022+ exp string
1023+ expRows []sql.Row
1024+ err * errors.Kind
1025+ skip bool
10251026 }{
10261027 {
1027- file : "outfile.txt" ,
1028- query : "select * from mytable into outfile 'outfile.txt';" ,
1028+ file : "outfile.txt" ,
1029+ query : "select * from mytable into outfile 'outfile.txt';" ,
1030+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10291031 exp : "" +
10301032 "1\t first row\n " +
10311033 "2\t second row\n " +
10321034 "3\t third row\n " ,
10331035 },
10341036 {
1035- file : "dumpfile.txt" ,
1036- query : "select * from mytable limit 1 into dumpfile 'dumpfile.txt';" ,
1037- exp : "1first row" ,
1037+ file : "dumpfile.txt" ,
1038+ query : "select * from mytable limit 1 into dumpfile 'dumpfile.txt';" ,
1039+ expRows : []sql.Row {{types .NewOkResult (1 )}},
1040+ exp : "1first row" ,
10381041 },
10391042 {
1040- file : "outfile.txt" ,
1041- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',';" ,
1043+ file : "outfile.txt" ,
1044+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',';" ,
1045+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10421046 exp : "" +
10431047 "1,first row\n " +
10441048 "2,second row\n " +
10451049 "3,third row\n " ,
10461050 },
10471051 {
1048- file : "outfile.txt" ,
1049- query : "select * from mytable into outfile 'outfile.txt' fields terminated by '$$';" ,
1052+ file : "outfile.txt" ,
1053+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by '$$';" ,
1054+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10501055 exp : "" +
10511056 "1$$first row\n " +
10521057 "2$$second row\n " +
10531058 "3$$third row\n " ,
10541059 },
10551060 {
1056- file : "outfile.txt" ,
1057- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' optionally enclosed by '\" ';" ,
1061+ file : "outfile.txt" ,
1062+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' optionally enclosed by '\" ';" ,
1063+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10581064 exp : "" +
10591065 "1,\" first row\" \n " +
10601066 "2,\" second row\" \n " +
@@ -1071,56 +1077,63 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10711077 err : sql .ErrUnexpectedSeparator ,
10721078 },
10731079 {
1074- file : "outfile.txt" ,
1075- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' enclosed by '\" ';" ,
1080+ file : "outfile.txt" ,
1081+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' enclosed by '\" ';" ,
1082+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10761083 exp : "" +
10771084 "\" 1\" ,\" first row\" \n " +
10781085 "\" 2\" ,\" second row\" \n " +
10791086 "\" 3\" ,\" third row\" \n " ,
10801087 },
10811088 {
1082- file : "outfile.txt" ,
1083- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by ';';" ,
1089+ file : "outfile.txt" ,
1090+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by ';';" ,
1091+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10841092 exp : "" +
10851093 "1,first row;" +
10861094 "2,second row;" +
10871095 "3,third row;" ,
10881096 },
10891097 {
1090- file : "outfile.txt" ,
1091- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by 'r';" ,
1098+ file : "outfile.txt" ,
1099+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by 'r';" ,
1100+ expRows : []sql.Row {{types .NewOkResult (3 )}},
10921101 exp : "" +
10931102 "1,fi\\ rst \\ rowr" +
10941103 "2,second \\ rowr" +
10951104 "3,thi\\ rd \\ rowr" ,
10961105 },
10971106 {
1098- file : "outfile.txt" ,
1099- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines starting by 'r';" ,
1107+ file : "outfile.txt" ,
1108+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines starting by 'r';" ,
1109+ expRows : []sql.Row {{types .NewOkResult (3 )}},
11001110 exp : "" +
11011111 "r1,first row\n " +
11021112 "r2,second row\n " +
11031113 "r3,third row\n " ,
11041114 },
11051115 {
1106- file : "outfile.txt" ,
1107- query : "select * from mytable into outfile 'outfile.txt' fields terminated by '';" ,
1116+ file : "outfile.txt" ,
1117+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by '';" ,
1118+ expRows : []sql.Row {{types .NewOkResult (3 )}},
11081119 exp : "" +
11091120 "1\t first row\n " +
11101121 "2\t second row\n " +
11111122 "3\t third row\n " ,
11121123 },
11131124 {
1114- file : "outfile.txt" ,
1115- query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by '';" ,
1125+ file : "outfile.txt" ,
1126+ query : "select * from mytable into outfile 'outfile.txt' fields terminated by ',' lines terminated by '';" ,
1127+ expRows : []sql.Row {{types .NewOkResult (3 )}},
11161128 exp : "" +
11171129 "1,first row" +
11181130 "2,second row" +
11191131 "3,third row" ,
11201132 },
11211133 {
1122- file : "outfile.txt" ,
1123- query : "select * from niltable into outfile 'outfile.txt';" ,
1134+ file : "outfile.txt" ,
1135+ query : "select * from niltable into outfile 'outfile.txt';" ,
1136+ expRows : []sql.Row {{types .NewOkResult (6 )}},
11241137 exp : "1\t \\ N\t \\ N\t \\ N\n " +
11251138 "2\t 2\t 1\t \\ N\n " +
11261139 "3\t \\ N\t 0\t \\ N\n " +
@@ -1129,8 +1142,9 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11291142 "6\t 6\t 0\t 6\n " ,
11301143 },
11311144 {
1132- file : "outfile.txt" ,
1133- query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' enclosed by '\" ';" ,
1145+ file : "outfile.txt" ,
1146+ query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' enclosed by '\" ';" ,
1147+ expRows : []sql.Row {{types .NewOkResult (6 )}},
11341148 exp : "\" 1\" ,\\ N,\\ N,\\ N\n " +
11351149 "\" 2\" ,\" 2\" ,\" 1\" ,\\ N\n " +
11361150 "\" 3\" ,\\ N,\" 0\" ,\\ N\n " +
@@ -1139,8 +1153,9 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11391153 "\" 6\" ,\" 6\" ,\" 0\" ,\" 6\" \n " ,
11401154 },
11411155 {
1142- file : "outfile.txt" ,
1143- query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' escaped by '$';" ,
1156+ file : "outfile.txt" ,
1157+ query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' escaped by '$';" ,
1158+ expRows : []sql.Row {{types .NewOkResult (6 )}},
11441159 exp : "1,$N,$N,$N\n " +
11451160 "2,2,1,$N\n " +
11461161 "3,$N,0,$N\n " +
@@ -1149,8 +1164,9 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11491164 "6,6,0,6\n " ,
11501165 },
11511166 {
1152- file : "outfile.txt" ,
1153- query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' escaped by '';" ,
1167+ file : "outfile.txt" ,
1168+ query : "select * from niltable into outfile 'outfile.txt' fields terminated by ',' escaped by '';" ,
1169+ expRows : []sql.Row {{types .NewOkResult (6 )}},
11541170 exp : "1,NULL,NULL,NULL\n " +
11551171 "2,2,1,NULL\n " +
11561172 "3,NULL,0,NULL\n " +
@@ -1159,8 +1175,9 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11591175 "6,6,0,6\n " ,
11601176 },
11611177 {
1162- file : "./subdir/outfile.txt" ,
1163- query : "select * from mytable into outfile './subdir/outfile.txt';" ,
1178+ file : "./subdir/outfile.txt" ,
1179+ query : "select * from mytable into outfile './subdir/outfile.txt';" ,
1180+ expRows : []sql.Row {{types .NewOkResult (3 )}},
11641181 exp : "" +
11651182 "1\t first row\n " +
11661183 "2\t second row\n " +
@@ -1198,7 +1215,11 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11981215 }
11991216 // in case there are any residual files from previous runs
12001217 os .Remove (tt .file )
1201- TestQueryWithContext (t , ctx , e , harness , tt .query , nil , nil , nil , nil )
1218+ var expected = tt .expRows
1219+ if IsServerEngine (e ) {
1220+ expected = nil
1221+ }
1222+ TestQueryWithContext (t , ctx , e , harness , tt .query , expected , types .OkResultSchema , nil , nil )
12021223 res , err := os .ReadFile (tt .file )
12031224 require .NoError (t , err )
12041225 require .Equal (t , tt .exp , string (res ))
0 commit comments