1515package queries
1616
1717import (
18+ "github.com/dolthub/vitess/go/mysql"
1819 "math"
1920 "time"
2021
@@ -121,114 +122,108 @@ type ScriptTestAssertion struct {
121122// the tests.
122123var ScriptTests = []ScriptTest {
123124 {
124- // https://github.com/dolthub/dolt/issues/9733
125- Name : "String to number casting should handle partial numeric strings with warnings " ,
125+ // https://github.com/dolthub/dolt/issues/9836
126+ Name : "Ordering by pk does not change the order of results " ,
126127 SetUpScript : []string {
127- "CREATE TABLE test01(pk VARCHAR(20) PRIMARY KEY)" ,
128- "INSERT INTO test01 VALUES ('11d'), ('11wha?'), ('11'), ('12')" ,
129128 "CREATE TABLE test_cast(pk VARCHAR(50) PRIMARY KEY)" ,
130129 "INSERT INTO test_cast VALUES (' 3 12 4'), ('3. 12 4'), ('3.2 12 4'), ('-3.1234'), ('-3.1a'), ('-5+8'), ('+3.1234'), ('11-5'), ('1a1'), ('2,345'), ('4,12'), ('5.932887e+07'), ('5.932887e+07abc'), ('5.932887e7'), ('5.932887e7abc'), ('a1a1')" ,
131130 },
132131 Assertions : []ScriptTestAssertion {
133132 {
134- Query : "SELECT cast(pk as signed) FROM test01" ,
135- Expected : []sql.Row {{11 }, {11 }, {11 }, {12 }},
136- //ExpectedWarning: mysql.ERTruncatedWrongValue,
137- //ExpectedWarningsCount: 2,
138- },
139- {
140- Query : "SELECT cast(pk as unsigned) FROM test01" ,
141- Expected : []sql.Row {{uint64 (11 )}, {uint64 (11 )}, {uint64 (11 )}, {uint64 (12 )}},
142- //ExpectedWarning: mysql.ERTruncatedWrongValue,
143- //ExpectedWarningsCount: 2,
133+ Skip : true ,
134+ Query : "SELECT cast(pk as signed) FROM test_cast ORDER BY pk" ,
135+ Expected : []sql.Row {{3 }, {- 3 }, {- 3 }, {- 5 }, {3 }, {11 }, {1 }, {2 }, {3 }, {3 }, {4 }, {5 }, {5 }, {5 }, {5 }, {0 }},
136+ ExpectedWarningsCount : 16 ,
137+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
144138 },
145139 {
146- Query : "SELECT cast(pk as signed) FROM test_cast ORDER BY pk" ,
147- //Expected: []sql.Row{{3}, {-3}, {-3}, {-5}, {3}, {11}, {1}, {2}, {3}, {3}, {4}, {5}, {5}, {5}, {5}, {0}} ,
148- //actual : []sql.Row{sql.Row{3 }, sql.Row{3 }, sql.Row{-3 }, sql.Row{-3 }, sql.Row{-5 }, sql.Row{11 }, sql.Row{1 }, sql.Row{2 }, sql.Row{3 }, sql.Row{3 }, sql.Row{4 }, sql.Row{5 }, sql.Row{5 }, sql.Row{5 }, sql.Row{5 }, sql.Row{0}}
149- //ExpectedWarning: mysql.ERTruncatedWrongValue ,
150- //ExpectedWarningsCount: 16 ,
140+ Skip : true ,
141+ Query : "SELECT cast(pk as unsigned) FROM test_cast ORDER BY pk" ,
142+ Expected : []sql.Row {{ uint64 ( 3 ) }, { uint64 ( 18446744073709551613 ) }, { uint64 ( 18446744073709551613 ) }, { uint64 ( 18446744073709551611 ) }, { uint64 ( 3 ) }, { uint64 ( 11 ) }, { uint64 ( 1 ) }, { uint64 ( 2 ) }, { uint64 ( 3 ) }, { uint64 ( 3 ) }, { uint64 ( 4 ) }, { uint64 ( 5 ) }, { uint64 ( 5 ) }, { uint64 ( 5 ) }, { uint64 ( 5 ) }, { uint64 ( 0 )}},
143+ ExpectedWarningsCount : 19 ,
144+ ExpectedWarning : mysql . ERTruncatedWrongValue ,
151145 },
152146 {
153- Query : "SELECT cast(pk as unsigned) FROM test_cast ORDER BY pk" ,
154- //Expected: []sql.Row{{uint64(3)}, {uint64(1844674407309552000)}, {uint64(1844674407309552000)}, {uint64(1844674407309552000)}, {uint64(3)}, {uint64(11)}, {uint64(1)}, {uint64(2)}, {uint64(3)}, {uint64(3)}, {uint64(4)}, {uint64(5)}, {uint64(5)}, {uint64(5)}, {uint64(5)}, {uint64(0)}},
155- //actual: [3, 3, 18446744073709551613, 18446744073709551613, 18446744073709551611, 11, 1, 2, 3, 3, 4, 5, 5, 5, 5, 0]
156- //ExpectedWarning: mysql.ERTruncatedWrongValue,
157- //ExpectedWarningsCount: 19,
158- },
159- {
160- Query : "SELECT cast(pk as double) FROM test_cast ORDER BY pk" ,
161- //Expected: []sql.Row{{3.0}, {-3.1234}, {-3.1}, {-5.0}, {3.1234}, {11.0}, {1.0}, {2.0}, {3.0}, {3.2}, {4.0}, {59328870.0}, {59328870.0}, {59328870.0}, {59328870.0}, {0.0}},
162- //actual : []sql.Row{sql.Row{3}, sql.Row{3.1234}, sql.Row{-3.1234}, sql.Row{-3.1}, sql.Row{-5}, sql.Row{11}, sql.Row{1}, sql.Row{2}, sql.Row{3}, sql.Row{3.2}, sql.Row{4}, sql.Row{5.932887e+07}, sql.Row{5.932887e+07}, sql.Row{5.932887e+07}, sql.Row{5.932887e+07}, sql.Row{0}}
163- //ExpectedWarning: mysql.ERTruncatedWrongValue,
164- //ExpectedWarningsCount: 9,
147+ Skip : true ,
148+ Query : "SELECT cast(pk as double) FROM test_cast ORDER BY pk" ,
149+ Expected : []sql.Row {{3.0 }, {- 3.1234 }, {- 3.1 }, {- 5.0 }, {3.1234 }, {11.0 }, {1.0 }, {2.0 }, {3.0 }, {3.2 }, {4.0 }, {59328870.0 }, {59328870.0 }, {59328870.0 }, {59328870.0 }, {0.0 }},
150+ ExpectedWarningsCount : 9 ,
151+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
165152 },
166153 },
167154 },
168155 {
169156 // https://github.com/dolthub/dolt/issues/9812
170157 Name : "String-to-number comparison operators should behave consistently" ,
171- Dialect : "mysql" ,
172158 Assertions : []ScriptTestAssertion {
173159 {
174- Query : "SELECT ('A') = (0)" ,
175- Expected : []sql.Row {{true }},
160+ Dialect : "mysql" ,
161+ Query : "SELECT ('A') = (0)" ,
162+ Expected : []sql.Row {{true }},
176163 //ExpectedWarningsCount: 1,
177164 //ExpectedWarning: mysql.ERTruncatedWrongValue,
178165 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
179166 },
180167 {
181- Query : "SELECT ('A') IN (0)" ,
182- Expected : []sql.Row {{true }},
168+ Dialect : "mysql" ,
169+ Query : "SELECT ('A') IN (0)" ,
170+ Expected : []sql.Row {{true }},
183171 //ExpectedWarningsCount: 1,
184172 //ExpectedWarning: mysql.ERTruncatedWrongValue,
185173 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
186174 },
187175 {
188- Query : "SELECT ('A') != (0)" ,
189- Expected : []sql.Row {{false }},
176+ Dialect : "mysql" ,
177+ Query : "SELECT ('A') != (0)" ,
178+ Expected : []sql.Row {{false }},
190179 //ExpectedWarningsCount: 1,
191180 //ExpectedWarning: mysql.ERTruncatedWrongValue,
192181 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
193182 },
194183 {
195- Query : "SELECT ('A') <> (0)" ,
196- Expected : []sql.Row {{false }},
184+ Dialect : "mysql" ,
185+ Query : "SELECT ('A') <> (0)" ,
186+ Expected : []sql.Row {{false }},
197187 //ExpectedWarningsCount: 1,
198188 //ExpectedWarning: mysql.ERTruncatedWrongValue,
199189 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
200190 },
201191 {
202- Query : "SELECT ('A') < (0)" ,
203- Expected : []sql.Row {{false }},
192+ Dialect : "mysql" ,
193+ Query : "SELECT ('A') < (0)" ,
194+ Expected : []sql.Row {{false }},
204195 //ExpectedWarningsCount: 1,
205196 //ExpectedWarning: mysql.ERTruncatedWrongValue,
206197 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
207198 },
208199 {
209- Query : "SELECT ('A') <= (0)" ,
210- Expected : []sql.Row {{true }},
200+ Dialect : "mysql" ,
201+ Query : "SELECT ('A') <= (0)" ,
202+ Expected : []sql.Row {{true }},
211203 //ExpectedWarningsCount: 1,
212204 //ExpectedWarning: mysql.ERTruncatedWrongValue,
213205 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
214206 },
215207 {
216- Query : "SELECT ('A') > (0)" ,
217- Expected : []sql.Row {{false }},
208+ Dialect : "mysql" ,
209+ Query : "SELECT ('A') > (0)" ,
210+ Expected : []sql.Row {{false }},
218211 //ExpectedWarningsCount: 1,
219212 //ExpectedWarning: mysql.ERTruncatedWrongValue,
220213 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
221214 },
222215 {
223- Query : "SELECT ('A') >= (0)" ,
224- Expected : []sql.Row {{true }},
216+ Dialect : "mysql" ,
217+ Query : "SELECT ('A') >= (0)" ,
218+ Expected : []sql.Row {{true }},
225219 //ExpectedWarningsCount: 1,
226220 //ExpectedWarning: mysql.ERTruncatedWrongValue,
227221 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
228222 },
229223 {
230- Query : "SELECT ('A') NOT IN (0)" ,
231- Expected : []sql.Row {{false }},
224+ Dialect : "mysql" ,
225+ Query : "SELECT ('A') NOT IN (0)" ,
226+ Expected : []sql.Row {{false }},
232227 //ExpectedWarningsCount: 1,
233228 //ExpectedWarning: mysql.ERTruncatedWrongValue,
234229 //ExpectedWarningMessageSubstring: "Truncated incorrect double value: A",
@@ -11777,6 +11772,8 @@ select * from t1 except (
1177711772 {"5.932887e7abc" , float32 (5.932887e+07 )},
1177811773 {"a1a1" , float32 (0 )},
1177911774 },
11775+ //ExpectedWarningsCount: 12,
11776+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1178011777 },
1178111778 {
1178211779 Dialect : "mysql" ,
@@ -11801,6 +11798,8 @@ select * from t1 except (
1180111798 {"5.932887e7abc" , 5.932887e+07 },
1180211799 {"a1a1" , 0.0 },
1180311800 },
11801+ //ExpectedWarningsCount: 12,
11802+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1180411803 },
1180511804 {
1180611805 Dialect : "mysql" ,
@@ -11825,6 +11824,8 @@ select * from t1 except (
1182511824 {"5.932887e7abc" , 5 },
1182611825 {"a1a1" , 0 },
1182711826 },
11827+ //ExpectedWarningsCount: 12,
11828+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1182811829 },
1182911830 {
1183011831 Dialect : "mysql" ,
@@ -11849,6 +11850,8 @@ select * from t1 except (
1184911850 {"5.932887e7abc" , uint64 (5 )},
1185011851 {"a1a1" , uint64 (0 )},
1185111852 },
11853+ //ExpectedWarningsCount: 19,
11854+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1185211855 },
1185311856 {
1185411857 Dialect : "mysql" ,
@@ -11873,10 +11876,13 @@ select * from t1 except (
1187311876 {"5.932887e7abc" , "59328870.000" },
1187411877 {"a1a1" , "0.000" },
1187511878 },
11879+ //ExpectedWarningsCount: 13,
11880+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1187611881 },
1187711882 {
1187811883 Query : "select * from test01 where pk in ('11')" ,
1187911884 Expected : []sql.Row {{"11" }},
11885+ //ExpectedWarningsCount: 0,
1188011886 },
1188111887 {
1188211888 // https://github.com/dolthub/dolt/issues/9739
@@ -11889,6 +11895,8 @@ select * from t1 except (
1188911895 {"11d" },
1189011896 {"11wha?" },
1189111897 },
11898+ //ExpectedWarningsCount: 12,
11899+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1189211900 },
1189311901 {
1189411902 // https://github.com/dolthub/dolt/issues/9739
@@ -11900,6 +11908,8 @@ select * from t1 except (
1190011908 {" 3. 12 4" },
1190111909 {"3. 12 4" },
1190211910 },
11911+ //ExpectedWarningsCount: 12,
11912+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1190311913 },
1190411914 {
1190511915 // https://github.com/dolthub/dolt/issues/9739
@@ -11913,20 +11923,26 @@ select * from t1 except (
1191311923 {"+3.1234" },
1191411924 {"3. 12 4" },
1191511925 },
11926+ //ExpectedWarningsCount: 20,
11927+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1191611928 },
1191711929 {
1191811930 // https://github.com/dolthub/dolt/issues/9739
1191911931 Skip : true ,
1192011932 Dialect : "mysql" ,
1192111933 Query : "select * from test02 where pk in ('11asdf')" ,
1192211934 Expected : []sql.Row {{"11" }},
11935+ //ExpectedWarningsCount: 1,
11936+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1192311937 },
1192411938 {
1192511939 // https://github.com/dolthub/dolt/issues/9739
1192611940 Skip : true ,
1192711941 Dialect : "mysql" ,
1192811942 Query : "select * from test02 where pk='11.12asdf'" ,
1192911943 Expected : []sql.Row {},
11944+ //ExpectedWarningsCount: 1,
11945+ //ExpectedWarning: mysql.ERTruncatedWrongValue,
1193011946 },
1193111947 },
1193211948 },
0 commit comments