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

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/test/fordelete.test

Issue 1610543003: [sql] Import reference version of 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
OLDNEW
(Empty)
1 # 2001 September 15
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 SELECT statement.
13 #
14 # $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $
15
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 set ::testprefix fordelete
19
20 # This function returns a list of the tables or indexes opened with
21 # OP_OpenWrite instructions when the SQL statement passed as the only
22 # argument is executed. If the OPFLAG_FORDELETE flag is specified on
23 # the OP_OpenWrite, an asterix is appended to the object name. The list
24 # is sorted in [lsort] order before it is returned.
25 #
26 proc analyze_delete_program {sql} {
27 # Build a map from root page to table/index name.
28 db eval {
29 SELECT name, rootpage FROM sqlite_master
30 } {
31 set T($rootpage) $name
32 }
33
34 # Calculate the results.
35 set res [list]
36 db eval "EXPLAIN $sql" R {
37 if {$R(opcode) == "OpenWrite"} {
38 set obj $T($R(p2))
39 if {"0x$R(p5)" & 0x08} { append obj *}
40 lappend res $obj
41 }
42 }
43
44 lsort $res
45 }
46
47 proc do_adp_test {tn sql res} {
48 uplevel [list do_test $tn [list analyze_delete_program $sql] [list {*}$res]]
49 }
50
51 do_execsql_test 1.0 {
52 CREATE TABLE t1(a PRIMARY KEY, b);
53 }
54
55 foreach {tn sql res} {
56 1 { DELETE FROM t1 WHERE a=?} { sqlite_autoindex_t1_1 t1* }
57 2 { DELETE FROM t1 WHERE a=? AND b=? } { sqlite_autoindex_t1_1 t1 }
58 3 { DELETE FROM t1 WHERE a>? } { sqlite_autoindex_t1_1 t1* }
59 4 { DELETE FROM t1 WHERE rowid=? } { sqlite_autoindex_t1_1* t1 }
60 } {
61 do_adp_test 1.$tn $sql $res
62 }
63
64 do_execsql_test 2.0 {
65 CREATE TABLE t2(a, b, c);
66 CREATE INDEX t2a ON t2(a);
67 CREATE INDEX t2b ON t2(b);
68 CREATE INDEX t2c ON t2(c);
69 }
70 foreach {tn sql res} {
71 1 { DELETE FROM t2 WHERE a=?} { t2* t2a t2b* t2c* }
72 2 { DELETE FROM t2 WHERE a=? AND +b=?} { t2 t2a t2b* t2c* }
73 3 { DELETE FROM t2 WHERE a=? OR b=?} { t2 t2a* t2b* t2c* }
74 4 { DELETE FROM t2 WHERE +a=? } { t2 t2a* t2b* t2c* }
75 5 { DELETE FROM t2 WHERE rowid=? } { t2 t2a* t2b* t2c* }
76 } {
77 do_adp_test 2.$tn $sql $res
78 }
79
80 #-------------------------------------------------------------------------
81 # Test that a record that consists of the bytes:
82 #
83 # 0x01 0x00
84 #
85 # is interpreted by OP_Column as a vector of NULL values (assuming the
86 # default column values are NULL). Also test that:
87 #
88 # 0x00
89 #
90 # is handled in the same way.
91 #
92 do_execsql_test 3.0 {
93 CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c, d);
94 CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c, d);
95 }
96
97 do_test 3.1 {
98 set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x1' }]
99 db eval {
100 BEGIN IMMEDIATE;
101 }
102 set bt [btree_from_db db]
103 set csr [btree_cursor $bt $root 1]
104 btree_insert $csr 5 "\000"
105 btree_close_cursor $csr
106 db eval { COMMIT }
107
108 db eval {
109 SELECT * FROM x1;
110 }
111 } {5 {} {} {}}
112
113 do_test 3.2 {
114 set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x2' }]
115 db eval {
116 BEGIN IMMEDIATE;
117 }
118 set bt [btree_from_db db]
119 set csr [btree_cursor $bt $root 1]
120 btree_insert $csr 6 "\000"
121 btree_close_cursor $csr
122 db eval { COMMIT }
123
124 db eval {
125 SELECT * FROM x2;
126 }
127 } {6 {} {} {}}
128
129 finish_test
130
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/test/fkey_malloc.test ('k') | third_party/sqlite/sqlite-src-3100200/test/format4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698