OLD | NEW |
1 # 2011 July 1 | 1 # 2011 July 1 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 CREATE TABLE t2(x); | 215 CREATE TABLE t2(x); |
216 INSERT INTO t2 | 216 INSERT INTO t2 |
217 SELECT DISTINCT | 217 SELECT DISTINCT |
218 CASE a WHEN 1 THEN x'0000000000' | 218 CASE a WHEN 1 THEN x'0000000000' |
219 WHEN 2 THEN zeroblob(5) | 219 WHEN 2 THEN zeroblob(5) |
220 ELSE 'xyzzy' END | 220 ELSE 'xyzzy' END |
221 FROM t1; | 221 FROM t1; |
222 SELECT quote(x) FROM t2 ORDER BY 1; | 222 SELECT quote(x) FROM t2 ORDER BY 1; |
223 } {'xyzzy' X'0000000000'} | 223 } {'xyzzy' X'0000000000'} |
224 | 224 |
| 225 #---------------------------------------------------------------------------- |
| 226 # Ticket [c5ea805691bfc4204b1cb9e9aa0103bd48bc7d34] (2014-12-04) |
| 227 # Make sure that DISTINCT works together with ORDER BY and descending |
| 228 # indexes. |
| 229 # |
| 230 do_execsql_test 5.1 { |
| 231 DROP TABLE IF EXISTS t1; |
| 232 CREATE TABLE t1(x); |
| 233 INSERT INTO t1(x) VALUES(3),(1),(5),(2),(6),(4),(5),(1),(3); |
| 234 CREATE INDEX t1x ON t1(x DESC); |
| 235 SELECT DISTINCT x FROM t1 ORDER BY x ASC; |
| 236 } {1 2 3 4 5 6} |
| 237 do_execsql_test 5.2 { |
| 238 SELECT DISTINCT x FROM t1 ORDER BY x DESC; |
| 239 } {6 5 4 3 2 1} |
| 240 do_execsql_test 5.3 { |
| 241 SELECT DISTINCT x FROM t1 ORDER BY x; |
| 242 } {1 2 3 4 5 6} |
| 243 do_execsql_test 5.4 { |
| 244 DROP INDEX t1x; |
| 245 CREATE INDEX t1x ON t1(x ASC); |
| 246 SELECT DISTINCT x FROM t1 ORDER BY x ASC; |
| 247 } {1 2 3 4 5 6} |
| 248 do_execsql_test 5.5 { |
| 249 SELECT DISTINCT x FROM t1 ORDER BY x DESC; |
| 250 } {6 5 4 3 2 1} |
| 251 do_execsql_test 5.6 { |
| 252 SELECT DISTINCT x FROM t1 ORDER BY x; |
| 253 } {1 2 3 4 5 6} |
| 254 |
| 255 #------------------------------------------------------------------------- |
| 256 # 2015-11-23. Problem discovered by Kostya Serebryany using libFuzzer |
| 257 # |
| 258 db close |
| 259 sqlite3 db :memory: |
| 260 do_execsql_test 6.1 { |
| 261 CREATE TABLE jjj(x); |
| 262 SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) |
| 263 FROM sqlite_master; |
| 264 } {jjj} |
| 265 do_execsql_test 6.2 { |
| 266 CREATE TABLE nnn(x); |
| 267 SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) |
| 268 FROM sqlite_master; |
| 269 } {mmm} |
| 270 |
| 271 |
225 finish_test | 272 finish_test |
OLD | NEW |