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

Side by Side Diff: third_party/sqlite/src/test/index7.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/sqlite/src/test/index6.test ('k') | third_party/sqlite/src/test/indexedby.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2013-11-04 1 # 2013-11-04
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # Test cases for partial indices in WITHOUT ROWID tables 12 # Test cases for partial indices in WITHOUT ROWID tables
13 # 13 #
14 14
15 15
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 18
19 ifcapable !vtab { 19 ifcapable !vtab {
20 finish_test 20 finish_test
21 return 21 return
22 } 22 }
23 23
24 # Capture the output of a pragma in a TEMP table.
25 #
26 proc capture_pragma {db tabname sql} {
27 $db eval "DROP TABLE IF EXISTS temp.$tabname"
28 set once 1
29 $db eval $sql x {
30 if {$once} {
31 set once 0
32 set ins "INSERT INTO $tabname VALUES"
33 set crtab "CREATE TEMP TABLE $tabname "
34 set sep "("
35 foreach col $x(*) {
36 append ins ${sep}\$x($col)
37 append crtab ${sep}\"$col\"
38 set sep ,
39 }
40 append ins )
41 append crtab )
42 $db eval $crtab
43 }
44 $db eval $ins
45 }
46 }
47
48
24 load_static_extension db wholenumber; 49 load_static_extension db wholenumber;
25 do_test index7-1.1 { 50 do_test index7-1.1 {
26 # Able to parse and manage partial indices 51 # Able to parse and manage partial indices
27 execsql { 52 execsql {
28 CREATE TABLE t1(a,b,c PRIMARY KEY) WITHOUT rowid; 53 CREATE TABLE t1(a,b,c PRIMARY KEY) WITHOUT rowid;
29 CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL; 54 CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL;
30 CREATE INDEX t1b ON t1(b) WHERE b>10; 55 CREATE INDEX t1b ON t1(b) WHERE b>10;
31 CREATE VIRTUAL TABLE nums USING wholenumber; 56 CREATE VIRTUAL TABLE nums USING wholenumber;
32 INSERT INTO t1(a,b,c) 57 INSERT INTO t1(a,b,c)
33 SELECT CASE WHEN value%3!=0 THEN value END, value, value 58 SELECT CASE WHEN value%3!=0 THEN value END, value, value
34 FROM nums WHERE value<=20; 59 FROM nums WHERE value<=20;
35 SELECT count(a), count(b) FROM t1; 60 SELECT count(a), count(b) FROM t1;
36 PRAGMA integrity_check; 61 PRAGMA integrity_check;
37 } 62 }
38 } {14 20 ok} 63 } {14 20 ok}
39 64
65 # (The "partial" column of the PRAGMA index_list output is...)
66 # EVIDENCE-OF: R-34457-09668 "1" if the index is a partial index and "0"
67 # if not.
68 #
69 do_test index7-1.1a {
70 capture_pragma db out {PRAGMA index_list(t1)}
71 db eval {SELECT "name", "partial", '|' FROM out ORDER BY "name"}
72 } {sqlite_autoindex_t1_1 0 | t1a 1 | t1b 1 |}
73
40 # Make sure the count(*) optimization works correctly with 74 # Make sure the count(*) optimization works correctly with
41 # partial indices. Ticket [a5c8ed66cae16243be6] 2013-10-03. 75 # partial indices. Ticket [a5c8ed66cae16243be6] 2013-10-03.
42 # 76 #
43 do_execsql_test index7-1.1.1 { 77 do_execsql_test index7-1.1.1 {
44 SELECT count(*) FROM t1; 78 SELECT count(*) FROM t1;
45 } {20} 79 } {20}
46 80
47 # Error conditions during parsing... 81 # Error conditions during parsing...
48 # 82 #
49 do_test index7-1.2 { 83 do_test index7-1.2 {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 INSERT INTO t4 VALUES('def', 'xyz'); 304 INSERT INTO t4 VALUES('def', 'xyz');
271 SELECT * FROM v4 WHERE d='xyz' AND c='def' 305 SELECT * FROM v4 WHERE d='xyz' AND c='def'
272 } { 306 } {
273 def xyz 307 def xyz
274 } 308 }
275 do_eqp_test index7-6.4 { 309 do_eqp_test index7-6.4 {
276 SELECT * FROM v4 WHERE d='xyz' AND c='def' 310 SELECT * FROM v4 WHERE d='xyz' AND c='def'
277 } { 311 } {
278 0 0 0 {SEARCH TABLE t4 USING INDEX i4 (c=?)} 312 0 0 0 {SEARCH TABLE t4 USING INDEX i4 (c=?)}
279 } 313 }
314 do_catchsql_test index7-6.5 {
315 CREATE INDEX t5a ON t5(a) WHERE a=#1;
316 } {1 {near "#1": syntax error}}
317
280 318
281 finish_test 319 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/index6.test ('k') | third_party/sqlite/src/test/indexedby.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698