Index: third_party/sqlite/src/test/distinct.test |
diff --git a/third_party/sqlite/src/test/distinct.test b/third_party/sqlite/src/test/distinct.test |
index 78c2c1df363de9df1123455a22b486e3106fef92..dac2269b0bcf2321e4b28495e73b933251707c44 100644 |
--- a/third_party/sqlite/src/test/distinct.test |
+++ b/third_party/sqlite/src/test/distinct.test |
@@ -222,4 +222,51 @@ do_execsql_test 4.1 { |
SELECT quote(x) FROM t2 ORDER BY 1; |
} {'xyzzy' X'0000000000'} |
+#---------------------------------------------------------------------------- |
+# Ticket [c5ea805691bfc4204b1cb9e9aa0103bd48bc7d34] (2014-12-04) |
+# Make sure that DISTINCT works together with ORDER BY and descending |
+# indexes. |
+# |
+do_execsql_test 5.1 { |
+ DROP TABLE IF EXISTS t1; |
+ CREATE TABLE t1(x); |
+ INSERT INTO t1(x) VALUES(3),(1),(5),(2),(6),(4),(5),(1),(3); |
+ CREATE INDEX t1x ON t1(x DESC); |
+ SELECT DISTINCT x FROM t1 ORDER BY x ASC; |
+} {1 2 3 4 5 6} |
+do_execsql_test 5.2 { |
+ SELECT DISTINCT x FROM t1 ORDER BY x DESC; |
+} {6 5 4 3 2 1} |
+do_execsql_test 5.3 { |
+ SELECT DISTINCT x FROM t1 ORDER BY x; |
+} {1 2 3 4 5 6} |
+do_execsql_test 5.4 { |
+ DROP INDEX t1x; |
+ CREATE INDEX t1x ON t1(x ASC); |
+ SELECT DISTINCT x FROM t1 ORDER BY x ASC; |
+} {1 2 3 4 5 6} |
+do_execsql_test 5.5 { |
+ SELECT DISTINCT x FROM t1 ORDER BY x DESC; |
+} {6 5 4 3 2 1} |
+do_execsql_test 5.6 { |
+ SELECT DISTINCT x FROM t1 ORDER BY x; |
+} {1 2 3 4 5 6} |
+ |
+#------------------------------------------------------------------------- |
+# 2015-11-23. Problem discovered by Kostya Serebryany using libFuzzer |
+# |
+db close |
+sqlite3 db :memory: |
+do_execsql_test 6.1 { |
+ CREATE TABLE jjj(x); |
+ SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) |
+ FROM sqlite_master; |
+} {jjj} |
+do_execsql_test 6.2 { |
+ CREATE TABLE nnn(x); |
+ SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) |
+ FROM sqlite_master; |
+} {mmm} |
+ |
+ |
finish_test |