| OLD | NEW |
| (Empty) |
| 1 # 2009 February 23 | |
| 2 # | |
| 3 # The author disclaims copyright to this source code. In place of | |
| 4 # a legal notice, here is a blessing: | |
| 5 # | |
| 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. | |
| 9 # | |
| 10 #*********************************************************************** | |
| 11 # This file implements regression tests for SQLite library. The | |
| 12 # focus of this file is testing the reverse_select_order pragma. | |
| 13 # | |
| 14 # $Id: whereA.test,v 1.3 2009/06/10 19:33:29 drh Exp $ | |
| 15 | |
| 16 set testdir [file dirname $argv0] | |
| 17 source $testdir/tester.tcl | |
| 18 | |
| 19 do_test whereA-1.1 { | |
| 20 db eval { | |
| 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); | |
| 25 SELECT * FROM t1 | |
| 26 } | |
| 27 } {1 2 3 2 hello world 3 4.53 {}} | |
| 28 do_test whereA-1.2 { | |
| 29 db eval { | |
| 30 PRAGMA reverse_unordered_selects=1; | |
| 31 SELECT * FROM t1; | |
| 32 } | |
| 33 } {3 4.53 {} 2 hello world 1 2 3} | |
| 34 | |
| 35 do_test whereA-1.3 { | |
| 36 db eval { | |
| 37 PRAGMA reverse_unordered_selects=1; | |
| 38 SELECT * FROM t1 ORDER BY rowid; | |
| 39 } | |
| 40 } {1 2 3 2 hello world 3 4.53 {}} | |
| 41 | |
| 42 do_test whereA-2.1 { | |
| 43 db eval { | |
| 44 PRAGMA reverse_unordered_selects=0; | |
| 45 SELECT * FROM t1 WHERE a>0; | |
| 46 } | |
| 47 } {1 2 3 2 hello world 3 4.53 {}} | |
| 48 do_test whereA-2.2 { | |
| 49 db eval { | |
| 50 PRAGMA reverse_unordered_selects=1; | |
| 51 SELECT * FROM t1 WHERE a>0; | |
| 52 } | |
| 53 } {3 4.53 {} 2 hello world 1 2 3} | |
| 54 | |
| 55 do_test whereA-2.3 { | |
| 56 db eval { | |
| 57 PRAGMA reverse_unordered_selects=1; | |
| 58 SELECT * FROM t1 WHERE a>0 ORDER BY rowid; | |
| 59 } | |
| 60 } {1 2 3 2 hello world 3 4.53 {}} | |
| 61 | |
| 62 do_test whereA-3.1 { | |
| 63 db eval { | |
| 64 PRAGMA reverse_unordered_selects=0; | |
| 65 SELECT * FROM t1 WHERE b>0; | |
| 66 } | |
| 67 } {1 2 3 3 4.53 {} 2 hello world} | |
| 68 do_test whereA-3.2 { | |
| 69 db eval { | |
| 70 PRAGMA reverse_unordered_selects=1; | |
| 71 SELECT * FROM t1 WHERE b>0; | |
| 72 } | |
| 73 } {2 hello world 3 4.53 {} 1 2 3} | |
| 74 do_test whereA-3.3 { | |
| 75 db eval { | |
| 76 PRAGMA reverse_unordered_selects=1; | |
| 77 SELECT * FROM t1 WHERE b>0 ORDER BY b; | |
| 78 } | |
| 79 } {1 2 3 3 4.53 {} 2 hello world} | |
| 80 | |
| 81 do_test whereA-4.1 { | |
| 82 db eval { | |
| 83 CREATE TABLE t2(x); | |
| 84 INSERT INTO t2 VALUES(1); | |
| 85 INSERT INTO t2 VALUES(2); | |
| 86 SELECT x FROM t2; | |
| 87 } | |
| 88 } {2 1} | |
| 89 # Do an SQL statement. Append the search count to the end of the result. | |
| 90 # | |
| 91 proc count sql { | |
| 92 set ::sqlite_sort_count 0 | |
| 93 return [concat [execsql $sql] $::sqlite_sort_count] | |
| 94 } | |
| 95 do_test whereA-4.2 { ;# Ticket #3904 | |
| 96 db eval { | |
| 97 CREATE INDEX t2x ON t2(x); | |
| 98 } | |
| 99 count { | |
| 100 SELECT x FROM t2; | |
| 101 } | |
| 102 } {2 1 0} | |
| 103 do_test whereA-4.3 { | |
| 104 count { | |
| 105 SELECT x FROM t2 ORDER BY x; | |
| 106 } | |
| 107 } {1 2 0} | |
| 108 do_test whereA-4.4 { | |
| 109 count { | |
| 110 SELECT x FROM t2 ORDER BY x DESC; | |
| 111 } | |
| 112 } {2 1 0} | |
| 113 do_test whereA-4.5 { | |
| 114 db eval {DROP INDEX t2x;} | |
| 115 count { | |
| 116 SELECT x FROM t2 ORDER BY x; | |
| 117 } | |
| 118 } {1 2 1} | |
| 119 do_test whereA-4.6 { | |
| 120 count { | |
| 121 SELECT x FROM t2 ORDER BY x DESC; | |
| 122 } | |
| 123 } {2 1 1} | |
| 124 | |
| 125 | |
| 126 finish_test | |
| OLD | NEW |