@@ -1017,15 +1017,17 @@ 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 {
10271028 file : "outfile.txt" ,
10281029 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 " +
@@ -1034,11 +1036,13 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10341036 {
10351037 file : "dumpfile.txt" ,
10361038 query : "select * from mytable limit 1 into dumpfile 'dumpfile.txt';" ,
1039+ expRows : []sql.Row {{types .NewOkResult (1 )}},
10371040 exp : "1first row" ,
10381041 },
10391042 {
10401043 file : "outfile.txt" ,
10411044 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 " +
@@ -1047,6 +1051,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10471051 {
10481052 file : "outfile.txt" ,
10491053 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 " +
@@ -1055,6 +1060,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10551060 {
10561061 file : "outfile.txt" ,
10571062 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 " +
@@ -1073,6 +1079,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10731079 {
10741080 file : "outfile.txt" ,
10751081 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 " +
@@ -1081,6 +1088,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10811088 {
10821089 file : "outfile.txt" ,
10831090 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;" +
@@ -1089,6 +1097,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10891097 {
10901098 file : "outfile.txt" ,
10911099 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" +
@@ -1097,6 +1106,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
10971106 {
10981107 file : "outfile.txt" ,
10991108 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 " +
@@ -1105,6 +1115,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11051115 {
11061116 file : "outfile.txt" ,
11071117 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 " +
@@ -1113,6 +1124,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11131124 {
11141125 file : "outfile.txt" ,
11151126 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" +
@@ -1121,6 +1133,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11211133 {
11221134 file : "outfile.txt" ,
11231135 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 " +
@@ -1131,6 +1144,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11311144 {
11321145 file : "outfile.txt" ,
11331146 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 " +
@@ -1141,6 +1155,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11411155 {
11421156 file : "outfile.txt" ,
11431157 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 " +
@@ -1151,6 +1166,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11511166 {
11521167 file : "outfile.txt" ,
11531168 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 " +
@@ -1161,6 +1177,7 @@ func TestSelectIntoFile(t *testing.T, harness Harness) {
11611177 {
11621178 file : "./subdir/outfile.txt" ,
11631179 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,7 @@ 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+ TestQueryWithContext (t , ctx , e , harness , tt .query , tt . expRows , types . OkResultSchema , nil , nil )
12021219 res , err := os .ReadFile (tt .file )
12031220 require .NoError (t , err )
12041221 require .Equal (t , tt .exp , string (res ))
0 commit comments