]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add a couple of tests to see if the new compound select optimizations work when the...
authordanielk1977 <danielk1977@noemail.net>
Mon, 30 Jun 2008 07:53:09 +0000 (07:53 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 30 Jun 2008 07:53:09 +0000 (07:53 +0000)
FossilOrigin-Name: 1a711249c25aafbaf08057ffdcbb9cf2f872f13d

manifest
manifest.uuid
test/select9.test

index 343630ee046c0fdf64e385f5ce591d1bd3122153..4dbf17ca043807badf5db5b29b4515007fc61576 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sassert()\sthat\swas\sfailing\sif\sthere\swere\sany\sopen\sincremental\sblob\shandles\swhen\sa\sstatement\stransaction\swas\srolled\sback.\s(CVS\s5326)
-D 2008-06-28T15:33:25
+C Add\sa\scouple\sof\stests\sto\ssee\sif\sthe\snew\scompound\sselect\soptimizations\swork\swhen\sthe\scompound\sselect\sis\shidden\sinside\sa\sview.\s(CVS\s5327)
+D 2008-06-30T07:53:10
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -447,7 +447,7 @@ F test/select5.test 5ad14ea338aada2e6394ba98fa9aa40e3e50aec0
 F test/select6.test 399f14b9ba37b768afe5d2cd8c12e4f340a69db8
 F test/select7.test 7906735805cfbee4dddc0bed4c14e68d7f5f9c5f
 F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
-F test/select9.test 0e1a5470bac7e6daa757d8df3fbfaee6730c544e
+F test/select9.test 2f52de9bcca6002ff9ad57b045a023e2dff6438d
 F test/selectA.test e4501789a1d0fe9d00db15187623fb5b7031357b
 F test/server1.test f5b790d4c0498179151ca8a7715a65a7802c859c
 F test/shared.test c6769531e0cb751d46a9838c0532d3786606c0f6
@@ -595,7 +595,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 0ab0b030dea03ec6693358b733329328828cf802
-R 8c25ea2dec6b6961f92bbdeafaa47650
+P f66491ab2ba3645d4e44e33ec6fa0ab94b2989be
+R 611ba85a3e5544f4f674bd15a237607d
 U danielk1977
-Z 103f0194a9136d291f48c62f781a1953
+Z 1eba408b59726db78885f41885acd9e1
index bc52ef9272e17b78b1e4f9b4f399640fd8a981fd..ad8f2cd688562df9ff79f2b86748351ffba614ce 100644 (file)
@@ -1 +1 @@
-f66491ab2ba3645d4e44e33ec6fa0ab94b2989be
\ No newline at end of file
+1a711249c25aafbaf08057ffdcbb9cf2f872f13d
\ No newline at end of file
index 08b8ed973a6e07d7989c9f504f2fc87ec6c7c471..db40c592a5b23b0caa6934e8826a1c2b61b7a85c 100644 (file)
@@ -10,7 +10,7 @@
 #***********************************************************************
 # This file implements regression tests for SQLite library. 
 #
-# $Id: select9.test,v 1.2 2008/06/24 15:39:44 danielk1977 Exp $
+# $Id: select9.test,v 1.3 2008/06/30 07:53:10 danielk1977 Exp $
 
 # The tests in this file are focused on test compound SELECT statements 
 # that have any or all of an ORDER BY, LIMIT or OFFSET clauses. As of
@@ -328,5 +328,94 @@ foreach indexes [list {
 
 }
 
+do_test select9-2.X {
+  execsql {
+    DROP INDEX i1;
+    DROP INDEX i2;
+    DROP INDEX i3;
+  }
+} {}
+
+# This procedure executes the SQL.  Then it checks the generated program
+# for the SQL and appends a "nosort" to the result if the program contains the
+# SortCallback opcode.  If the program does not contain the SortCallback
+# opcode it appends "sort"
+#
+proc cksort {sql} {
+  set ::sqlite_sort_count 0
+  set data [execsql $sql]
+  if {$::sqlite_sort_count} {set x sort} {set x nosort}
+  lappend data $x
+  return $data
+}
+
+# If the right indexes exist, the following query:
+#
+#     SELECT t1.a FROM t1 UNION ALL SELECT t2.d FROM t2 ORDER BY 1
+#
+# can use indexes to run without doing a in-memory sort operation.
+# This block of tests (select9-3.*) is used to check if the same 
+# is possible with:
+#
+#     CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2
+#     SELECT a FROM v1 ORDER BY 1
+#
+# Currently it is not.
+#
+do_test select9-3.1 {
+  cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 sort}
+do_test select9-3.2 {
+  execsql { CREATE INDEX i1 ON t1(a) }
+  cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 nosort}
+do_test select9-3.3 {
+  cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 sort}
+do_test select9-3.4 {
+  execsql { CREATE INDEX i2 ON t2(d) }
+  cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 nosort}
+do_test select9-3.5 {
+  execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2 }
+  cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }
+} {1 1 2 2 3 sort}
+do_test select9-3.X {
+  execsql {
+    DROP INDEX i1;
+    DROP INDEX i2;
+    DROP VIEW v1;
+  }
+} {}
+
+# This block of tests is the same as the preceding one, except that
+# "UNION" is tested instead of "UNION ALL".
+#
+do_test select9-4.1 {
+  cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 sort}
+do_test select9-4.2 {
+  execsql { CREATE INDEX i1 ON t1(a) }
+  cksort { SELECT a FROM t1 ORDER BY 1 }
+} {1 2 3 4 5 6 7 8 9 10 nosort}
+do_test select9-4.3 {
+  cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 sort}
+do_test select9-4.4 {
+  execsql { CREATE INDEX i2 ON t2(d) }
+  cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 nosort}
+do_test select9-4.5 {
+  execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION SELECT d FROM t2 }
+  cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }
+} {1 2 3 4 5 sort}
+do_test select9-4.X {
+  execsql {
+    DROP INDEX i1;
+    DROP INDEX i2;
+    DROP VIEW v1;
+  }
+} {}
+
 
 finish_test