Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: third_party/sqlite/test/descidx3.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/test/descidx2.test ('k') | third_party/sqlite/test/diskfull.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2006 January 02
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 script is descending indices.
13 #
14 # $Id: descidx3.test,v 1.6 2008/03/19 00:21:31 drh Exp $
15 #
16
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19
20 ifcapable !bloblit {
21 finish_test
22 return
23 }
24 db eval {PRAGMA legacy_file_format=OFF}
25
26 # This procedure sets the value of the file-format in file 'test.db'
27 # to $newval. Also, the schema cookie is incremented.
28 #
29 proc set_file_format {newval} {
30 hexio_write test.db 44 [hexio_render_int32 $newval]
31 set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
32 incr schemacookie
33 hexio_write test.db 40 [hexio_render_int32 $schemacookie]
34 return {}
35 }
36
37 # This procedure returns the value of the file-format in file 'test.db'.
38 #
39 proc get_file_format {{fname test.db}} {
40 return [hexio_get_int [hexio_read $fname 44 4]]
41 }
42
43 # Verify that the file format starts as 4.
44 #
45 do_test descidx3-1.1 {
46 execsql {
47 CREATE TABLE t1(i INTEGER PRIMARY KEY,a,b,c,d);
48 CREATE INDEX t1i1 ON t1(a DESC, b ASC, c DESC);
49 CREATE INDEX t1i2 ON t1(b DESC, c ASC, d DESC);
50 }
51 get_file_format
52 } {4}
53
54 # Put some information in the table and verify that the descending
55 # index actually works.
56 #
57 do_test descidx3-2.1 {
58 execsql {
59 INSERT INTO t1 VALUES(1, NULL, NULL, NULL, NULL);
60 INSERT INTO t1 VALUES(2, 2, 2, 2, 2);
61 INSERT INTO t1 VALUES(3, 3, 3, 3, 3);
62 INSERT INTO t1 VALUES(4, 2.5, 2.5, 2.5, 2.5);
63 INSERT INTO t1 VALUES(5, -5, -5, -5, -5);
64 INSERT INTO t1 VALUES(6, 'six', 'six', 'six', 'six');
65 INSERT INTO t1 VALUES(7, x'77', x'77', x'77', x'77');
66 INSERT INTO t1 VALUES(8, 'eight', 'eight', 'eight', 'eight');
67 INSERT INTO t1 VALUES(9, x'7979', x'7979', x'7979', x'7979');
68 SELECT count(*) FROM t1;
69 }
70 } 9
71 do_test descidx3-2.2 {
72 execsql {
73 SELECT i FROM t1 ORDER BY a;
74 }
75 } {1 5 2 4 3 8 6 7 9}
76 do_test descidx3-2.3 {
77 execsql {
78 SELECT i FROM t1 ORDER BY a DESC;
79 }
80 } {9 7 6 8 3 4 2 5 1}
81
82 # The "natural" order for the index is decreasing
83 do_test descidx3-2.4 {
84 execsql {
85 SELECT i FROM t1 WHERE a<=x'7979';
86 }
87 } {9 7 6 8 3 4 2 5}
88 do_test descidx3-2.5 {
89 execsql {
90 SELECT i FROM t1 WHERE a>-99;
91 }
92 } {9 7 6 8 3 4 2 5}
93
94 # Even when all values of t1.a are the same, sorting by A returns
95 # the rows in reverse order because this the natural order of the
96 # index.
97 #
98 do_test descidx3-3.1 {
99 execsql {
100 UPDATE t1 SET a=1;
101 SELECT i FROM t1 ORDER BY a;
102 }
103 } {9 7 6 8 3 4 2 5 1}
104 do_test descidx3-3.2 {
105 execsql {
106 SELECT i FROM t1 WHERE a=1 AND b>0 AND b<'zzz'
107 }
108 } {2 4 3 8 6}
109 do_test descidx3-3.3 {
110 execsql {
111 SELECT i FROM t1 WHERE b>0 AND b<'zzz'
112 }
113 } {6 8 3 4 2}
114 do_test descidx3-3.4 {
115 execsql {
116 SELECT i FROM t1 WHERE a=1 AND b>-9999 AND b<x'ffffffff'
117 }
118 } {5 2 4 3 8 6 7 9}
119 do_test descidx3-3.5 {
120 execsql {
121 SELECT i FROM t1 WHERE b>-9999 AND b<x'ffffffff'
122 }
123 } {9 7 6 8 3 4 2 5}
124
125 ifcapable subquery {
126 # If the subquery capability is not compiled in to the binary, then
127 # the IN(...) operator is not available. Hence these tests cannot be
128 # run.
129 do_test descidx3-4.1 {
130 execsql {
131 UPDATE t1 SET a=2 WHERE i<6;
132 SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
133 }
134 } {8 6 2 4 3}
135 do_test descidx3-4.2 {
136 execsql {
137 UPDATE t1 SET a=1;
138 SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
139 }
140 } {2 4 3 8 6}
141 do_test descidx3-4.3 {
142 execsql {
143 UPDATE t1 SET b=2;
144 SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
145 }
146 } {9 7 6 8 3 4 2 5 1}
147 }
148
149 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/descidx2.test ('k') | third_party/sqlite/test/diskfull.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698