3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the reverse_select_order pragma.
14 # $Id: whereA.test,v 1.3 2009/06/10 19:33:29 drh Exp $
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
21 CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
22 INSERT INTO t1 VALUES(1,2,3);
23 INSERT INTO t1 values(2,'hello','world');
24 INSERT INTO t1 VALUES(3,4.53,NULL);
27 } {1 2 3 2 hello world 3 4.53 {}}
30 PRAGMA reverse_unordered_selects=1;
33 } {3 4.53 {} 2 hello world 1 2 3}
39 PRAGMA reverse_unordered_selects=1;
42 } {3 4.53 {} 2 hello world 1 2 3}
47 PRAGMA reverse_unordered_selects=1;
48 SELECT * FROM t1 ORDER BY rowid;
50 } {1 2 3 2 hello world 3 4.53 {}}
54 SELECT * FROM t1 ORDER BY rowid;
56 } {1 2 3 2 hello world 3 4.53 {}}
59 PRAGMA reverse_unordered_selects;
66 PRAGMA reverse_unordered_selects=1;
70 } {3 4.53 {} 2 hello world 1 2 3}
74 PRAGMA reverse_unordered_selects=0;
75 SELECT * FROM t1 WHERE a>0;
77 } {1 2 3 2 hello world 3 4.53 {}}
80 PRAGMA reverse_unordered_selects=1;
81 SELECT * FROM t1 WHERE a>0;
83 } {3 4.53 {} 2 hello world 1 2 3}
87 PRAGMA reverse_unordered_selects=1;
88 SELECT * FROM t1 WHERE a>0 ORDER BY rowid;
90 } {1 2 3 2 hello world 3 4.53 {}}
94 PRAGMA reverse_unordered_selects=0;
95 SELECT * FROM t1 WHERE b>0;
97 } {1 2 3 3 4.53 {} 2 hello world}
100 PRAGMA reverse_unordered_selects=1;
101 SELECT * FROM t1 WHERE b>0;
103 } {2 hello world 3 4.53 {} 1 2 3}
106 PRAGMA reverse_unordered_selects=1;
107 SELECT * FROM t1 WHERE b>0 ORDER BY b;
109 } {1 2 3 3 4.53 {} 2 hello world}
114 INSERT INTO t2 VALUES(1);
115 INSERT INTO t2 VALUES(2);
119 # Do an SQL statement. Append the search count to the end of the result.
122 set ::sqlite_sort_count 0
123 return [concat [execsql $sql] $::sqlite_sort_count]
125 do_test whereA-4.2 { ;# Ticket #3904
127 CREATE INDEX t2x ON t2(x);
135 SELECT x FROM t2 ORDER BY x;
140 SELECT x FROM t2 ORDER BY x DESC;
144 db eval {DROP INDEX t2x;}
146 SELECT x FROM t2 ORDER BY x;
151 SELECT x FROM t2 ORDER BY x DESC;