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

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/ext/rbu/rbu3.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: Created 3 years, 9 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 # 2014 August 30
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 #
12
13 if {![info exists testdir]} {
14 set testdir [file join [file dirname [info script]] .. .. test]
15 }
16 source $testdir/tester.tcl
17 set ::testprefix rbu3
18
19
20 # Run the RBU in file $rbu on target database $target until completion.
21 #
22 proc run_rbu {target rbu} {
23 sqlite3rbu rbu $target $rbu
24 while { [rbu step]=="SQLITE_OK" } {}
25 rbu close
26 }
27
28 forcedelete test.db-oal rbu.db
29 db close
30 sqlite3_shutdown
31 sqlite3_config_uri 1
32 reset_db
33
34 #--------------------------------------------------------------------
35 # Test that for an RBU to be applied, no corruption results if the
36 # affinities on the source and target table do not match.
37 #
38 do_execsql_test 1.0 {
39 CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);
40 CREATE INDEX i1 ON x1(b, c);
41 } {}
42
43 do_test 1.1 {
44 sqlite3 db2 rbu.db
45 db2 eval {
46 CREATE TABLE data_x1(a, b, c, rbu_control);
47 INSERT INTO data_x1 VALUES(1, '123', '123', 0);
48 INSERT INTO data_x1 VALUES(2, 123, 123, 0);
49 }
50 db2 close
51 run_rbu test.db rbu.db
52 } {SQLITE_DONE}
53
54 do_execsql_test 1.2 {
55 PRAGMA integrity_check;
56 } {ok}
57
58 #--------------------------------------------------------------------
59 # Test that NULL values may not be inserted into INTEGER PRIMARY KEY
60 # columns.
61 #
62 forcedelete rbu.db
63 reset_db
64
65 do_execsql_test 2.0 {
66 CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);
67 CREATE INDEX i1 ON x1(b, c);
68 } {}
69
70 foreach {tn rbudb} {
71 1 {
72 CREATE TABLE data_x1(a, b, c, rbu_control);
73 INSERT INTO data_x1 VALUES(NULL, 'a', 'b', 0);
74 }
75
76 2 {
77 CREATE TABLE data_x1(c, b, a, rbu_control);
78 INSERT INTO data_x1 VALUES('b', 'a', NULL, 0);
79 }
80 } {
81 do_test 2.$tn.1 {
82 forcedelete rbu.db
83 sqlite3 db2 rbu.db
84 db2 eval $rbudb
85 db2 close
86 list [catch { run_rbu test.db rbu.db } msg] $msg
87 } {1 {SQLITE_MISMATCH - datatype mismatch}}
88
89 do_execsql_test 2.1.2 {
90 PRAGMA integrity_check;
91 } {ok}
92 }
93
94 #--------------------------------------------------------------------
95 # Test that missing columns are detected.
96 #
97 forcedelete rbu.db
98 reset_db
99
100 do_execsql_test 2.0 {
101 CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);
102 CREATE INDEX i1 ON x1(b, c);
103 } {}
104
105 do_test 2.1 {
106 sqlite3 db2 rbu.db
107 db2 eval {
108 CREATE TABLE data_x1(a, b, rbu_control);
109 INSERT INTO data_x1 VALUES(1, 'a', 0);
110 }
111 db2 close
112 list [catch { run_rbu test.db rbu.db } msg] $msg
113 } {1 {SQLITE_ERROR - column missing from data_x1: c}}
114
115 do_execsql_test 2.2 {
116 PRAGMA integrity_check;
117 } {ok}
118
119 # Also extra columns.
120 #
121 do_execsql_test 2.3 {
122 CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c);
123 CREATE INDEX i2 ON x2(b, c);
124 } {}
125
126 do_test 2.4 {
127 forcedelete rbu.db
128 sqlite3 db2 rbu.db
129 db2 eval {
130 CREATE TABLE data_x2(a, b, c, d, rbu_control);
131 INSERT INTO data_x2 VALUES(1, 'a', 2, 3, 0);
132 }
133 db2 close
134 list [catch { run_rbu test.db rbu.db } msg] $msg
135 } {1 SQLITE_ERROR}
136
137 do_execsql_test 2.5 {
138 PRAGMA integrity_check;
139 } {ok}
140
141
142 #-------------------------------------------------------------------------
143 # Test that sqlite3rbu_create_vfs() returns an error if the requested
144 # parent VFS is unknown.
145 #
146 # And that nothing disasterous happens if a VFS name passed to
147 # sqlite3rbu_destroy_vfs() is unknown or not an RBU vfs.
148 #
149 do_test 3.1 {
150 list [catch {sqlite3rbu_create_vfs xyz nosuchparent} msg] $msg
151 } {1 SQLITE_NOTFOUND}
152
153 do_test 3.2 {
154 sqlite3rbu_destroy_vfs nosuchvfs
155 sqlite3rbu_destroy_vfs unix
156 sqlite3rbu_destroy_vfs win32
157 } {}
158
159 #-------------------------------------------------------------------------
160 # Test that it is an error to specify an explicit VFS that does not
161 # include rbu VFS functionality.
162 #
163 do_test 4.1 {
164 testvfs tvfs
165 sqlite3rbu rbu file:test.db?vfs=tvfs rbu.db
166 list [catch { rbu step } msg] $msg
167 } {0 SQLITE_ERROR}
168 do_test 4.2 {
169 list [catch { rbu close } msg] $msg
170 } {1 {SQLITE_ERROR - rbu vfs not found}}
171 tvfs delete
172
173 #-------------------------------------------------------------------------
174 # Test a large rbu update to ensure that wal_autocheckpoint does not get
175 # in the way.
176 #
177 forcedelete rbu.db
178 reset_db
179 do_execsql_test 5.1 {
180 CREATE TABLE x1(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;
181 CREATE INDEX i1 ON x1(a);
182
183 ATTACH 'rbu.db' AS rbu;
184 CREATE TABLE rbu.data_x1(a, b, c, rbu_control);
185 WITH s(a, b, c) AS (
186 SELECT randomblob(300), randomblob(300), 1
187 UNION ALL
188 SELECT randomblob(300), randomblob(300), c+1 FROM s WHERE c<2000
189 )
190 INSERT INTO data_x1 SELECT a, b, c, 0 FROM s;
191 }
192
193 do_test 5.2 {
194 sqlite3rbu rbu test.db rbu.db
195 while {[rbu step]=="SQLITE_OK" && [file exists test.db-wal]==0} {}
196 rbu close
197 } {SQLITE_OK}
198
199 do_test 5.3 {
200 expr {[file size test.db-wal] > (1024 * 1200)}
201 } 1
202
203 do_test 6.1 { sqlite3rbu_internal_test } {}
204
205 finish_test
206
207
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3170000/ext/rbu/rbu14.test ('k') | third_party/sqlite/sqlite-src-3170000/ext/rbu/rbu5.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698