summaryrefslogtreecommitdiff
path: root/test/orderby5.test
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2014-10-16 22:51:43 -0400
committerHans-Christoph Steiner <hans@eds.org>2014-10-16 22:51:43 -0400
commit9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch)
treec88a33f01f20a3d13a09594f114fffacebd0d1a4 /test/orderby5.test
parentee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff)
parent569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff)
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0 # gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81 # gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>" # gpg: aka "Hans-Christoph Steiner <hans@eds.org>" # gpg: aka "Hans-Christoph Steiner <hans@at.or.at>" # gpg: aka "[jpeg image of size 5408]"
Diffstat (limited to 'test/orderby5.test')
-rw-r--r--test/orderby5.test130
1 files changed, 130 insertions, 0 deletions
diff --git a/test/orderby5.test b/test/orderby5.test
new file mode 100644
index 0000000..c9cce70
--- /dev/null
+++ b/test/orderby5.test
@@ -0,0 +1,130 @@
+# 2013-06-14
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that the optimizations that disable
+# ORDER BY clauses work correctly
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby5
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1bc ON t1(b,c);
+
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, b, c FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.2.1 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, c, b FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
+} {/B-TREE/}
+do_execsql_test 1.2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz';
+} {/B-TREE/}
+do_execsql_test 1.2.4 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
+} {~/B-TREE/}
+do_execsql_test 1.3 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT b, a, c FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.4 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT b, c, a FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.5 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, a, b FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.6 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, b, a FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.7 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, b, a FROM t1 WHERE +a=0;
+} {/B-TREE/}
+
+# In some cases, it is faster to do repeated index lookups than it is to
+# sort. But in other cases, it is faster to sort than to do repeated index
+# lookups.
+#
+do_execsql_test 2.1a {
+ CREATE TABLE t2(a,b,c);
+ CREATE INDEX t2bc ON t2(b,c);
+ ANALYZE;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1bc','1000000 10 9');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2bc','100 10 5');
+ ANALYZE sqlite_master;
+
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a=0 ORDER BY a, b, c;
+} {~/B-TREE/}
+
+do_execsql_test 2.1b {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE likelihood(a=0, 0.05) ORDER BY a, b, c;
+} {/B-TREE/}
+
+do_execsql_test 2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE +a=0 ORDER BY a, b, c;
+} {/B-TREE/}
+do_execsql_test 2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY b, a, c;
+} {~/B-TREE/}
+do_execsql_test 2.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY b, c, a;
+} {~/B-TREE/}
+do_execsql_test 2.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY a, c, b;
+} {/B-TREE/}
+do_execsql_test 2.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY c, a, b;
+} {/B-TREE/}
+do_execsql_test 2.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY c, b, a;
+} {/B-TREE/}
+
+
+do_execsql_test 3.0 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f);
+ CREATE INDEX t3bcde ON t3(b, c, d, e);
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;
+} {~/B-TREE/}
+do_execsql_test 3.1 {
+ DROP TABLE t3;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f) WITHOUT rowid;
+ CREATE INDEX t3bcde ON t3(b, c, d, e);
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;
+} {~/B-TREE/}
+
+
+finish_test