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

Side by Side Diff: third_party/sqlite/src/ext/session/sessionF.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 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 # 2015 June 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 #
12 # This file implements regression tests for the sessions module.
13 # Specifically, it tests that tables appear in the correct order
14 # within changesets and patchsets.
15 #
16
17
18
19 if {![info exists testdir]} {
20 set testdir [file join [file dirname [info script]] .. .. test]
21 }
22 source [file join [file dirname [info script]] session_common.tcl]
23 source $testdir/tester.tcl
24 ifcapable !session {finish_test; return}
25 set testprefix sessionF
26
27 #
28 # Test plan:
29 #
30 # 1.*: Test that sqlite3session_changeset() and sqlite3session_patchset()
31 # output tables in the right order.
32 #
33 # 2.*: Test that sqlite3session_invert() does not modify the order of
34 # tables within a changeset.
35 #
36 # 3.*: Test that sqlite3session_concat outputs tables in the right order.
37 #
38
39 # Create a db schema to use.
40 #
41 do_execsql_test 1.0 {
42 CREATE TABLE t3(e PRIMARY KEY, f);
43 CREATE TABLE t1(a PRIMARY KEY, b);
44 CREATE TABLE t2(c PRIMARY KEY, d);
45 }
46
47 #-----------------------------------------------------------------------
48 # 1.* - changeset() and patchset().
49 #
50
51 foreach {tn setup result} {
52 1 {
53 S attach *
54 } {
55 {INSERT t2 0 X. {} {i 2 t two}}
56 {INSERT t1 0 X. {} {i 1 t one}}
57 {INSERT t3 0 X. {} {i 3 t three}}
58 }
59
60 2 {
61 S attach t1
62 S attach *
63 } {
64 {INSERT t1 0 X. {} {i 1 t one}}
65 {INSERT t2 0 X. {} {i 2 t two}}
66 {INSERT t3 0 X. {} {i 3 t three}}
67 }
68
69 3 {
70 S attach t3
71 S attach t2
72 S attach t1
73 } {
74 {INSERT t3 0 X. {} {i 3 t three}}
75 {INSERT t2 0 X. {} {i 2 t two}}
76 {INSERT t1 0 X. {} {i 1 t one}}
77 }
78 } {
79 execsql {
80 DELETE FROM t1;
81 DELETE FROM t2;
82 DELETE FROM t3;
83 }
84 sqlite3session S db main
85 eval $setup
86
87 do_execsql_test 1.$tn.1 {
88 INSERT INTO t2 VALUES(2, 'two');
89 INSERT INTO t1 VALUES(1, 'one');
90 INSERT INTO t3 VALUES(3, 'three');
91 }
92
93 do_changeset_test 1.1.$tn.2 S $result
94 do_patchset_test 1.1.$tn.3 S $result
95
96 S delete
97 }
98
99 foreach {tn setup result} {
100 1 {
101 S attach *
102 } {
103 {INSERT t2 0 X. {} {i 4 t four}}
104 {INSERT t2 0 X. {} {i 5 t five}}
105 {INSERT t1 0 X. {} {i 1 t one}}
106 {INSERT t3 0 X. {} {i 6 t six}}
107 }
108
109 2 {
110 S attach t1
111 S attach *
112 } {
113 {INSERT t1 0 X. {} {i 1 t one}}
114 {INSERT t2 0 X. {} {i 4 t four}}
115 {INSERT t2 0 X. {} {i 5 t five}}
116 {INSERT t3 0 X. {} {i 6 t six}}
117 }
118
119 3 {
120 S attach t3
121 S attach t2
122 S attach t1
123 } {
124 {INSERT t3 0 X. {} {i 6 t six}}
125 {INSERT t2 0 X. {} {i 4 t four}}
126 {INSERT t2 0 X. {} {i 5 t five}}
127 {INSERT t1 0 X. {} {i 1 t one}}
128 }
129 } {
130 execsql {
131 DELETE FROM t1;
132 DELETE FROM t2;
133 DELETE FROM t3;
134 }
135 sqlite3session S db main
136 eval $setup
137
138 do_execsql_test 1.$tn.1 {
139 INSERT INTO t2 VALUES(2, 'two');
140 INSERT INTO t1 VALUES(1, 'one');
141 DELETE FROM t2;
142 INSERT INTO t2 VALUES(4, 'four');
143 INSERT INTO t2 VALUES(5, 'five');
144 INSERT INTO t3 VALUES(6, 'six');
145 }
146
147 do_changeset_test 1.2.$tn.2 S $result
148 do_patchset_test 1.2.$tn.2 S $result
149
150 S delete
151 }
152
153 #-------------------------------------------------------------------------
154 # 2.* - invert()
155 #
156
157 foreach {tn setup result} {
158 1 {
159 S attach *
160 } {
161 {DELETE t2 0 X. {i 4 t four} {}}
162 {DELETE t2 0 X. {i 5 t five} {}}
163 {DELETE t1 0 X. {i 1 t one} {}}
164 {DELETE t3 0 X. {i 6 t six} {}}
165 }
166
167 2 {
168 S attach t1
169 S attach *
170 } {
171 {DELETE t1 0 X. {i 1 t one} {}}
172 {DELETE t2 0 X. {i 4 t four} {}}
173 {DELETE t2 0 X. {i 5 t five} {}}
174 {DELETE t3 0 X. {i 6 t six} {}}
175 }
176
177 3 {
178 S attach t3
179 S attach t2
180 S attach t1
181 } {
182 {DELETE t3 0 X. {i 6 t six} {}}
183 {DELETE t2 0 X. {i 4 t four} {}}
184 {DELETE t2 0 X. {i 5 t five} {}}
185 {DELETE t1 0 X. {i 1 t one} {}}
186 }
187 } {
188 execsql {
189 DELETE FROM t1;
190 DELETE FROM t2;
191 DELETE FROM t3;
192 }
193 sqlite3session S db main
194 eval $setup
195
196 do_execsql_test 1.$tn.1 {
197 INSERT INTO t2 VALUES(2, 'two');
198 INSERT INTO t1 VALUES(1, 'one');
199 DELETE FROM t2;
200 INSERT INTO t2 VALUES(4, 'four');
201 INSERT INTO t2 VALUES(5, 'five');
202 INSERT INTO t3 VALUES(6, 'six');
203 }
204
205 do_changeset_invert_test 2.$tn.2 S $result
206
207 S delete
208 }
209
210 #-------------------------------------------------------------------------
211 # 3.* - concat()
212 #
213 foreach {tn setup1 sql1 setup2 sql2 result} {
214 1 {
215 S attach *
216 } {
217 INSERT INTO t1 VALUES(1, 'one');
218 INSERT INTO t2 VALUES(2, 'two');
219 } {
220 S attach t2
221 S attach t1
222 } {
223 INSERT INTO t1 VALUES(3, 'three');
224 INSERT INTO t2 VALUES(4, 'four');
225 } {
226 {INSERT t1 0 X. {} {i 1 t one}}
227 {INSERT t1 0 X. {} {i 3 t three}}
228 {INSERT t2 0 X. {} {i 2 t two}}
229 {INSERT t2 0 X. {} {i 4 t four}}
230 }
231
232 1 {
233 S attach t2
234 S attach t1
235 } {
236 INSERT INTO t1 VALUES(1, 'one');
237 INSERT INTO t2 VALUES(2, 'two');
238 } {
239 S attach *
240 } {
241 INSERT INTO t1 VALUES(3, 'three');
242 INSERT INTO t2 VALUES(4, 'four');
243 } {
244 {INSERT t2 0 X. {} {i 2 t two}}
245 {INSERT t2 0 X. {} {i 4 t four}}
246 {INSERT t1 0 X. {} {i 1 t one}}
247 {INSERT t1 0 X. {} {i 3 t three}}
248 }
249
250 1 {
251 S attach *
252 } {
253 INSERT INTO t2 VALUES(2, 'two');
254 } {
255 S attach *
256 } {
257 INSERT INTO t1 VALUES(3, 'three');
258 INSERT INTO t2 VALUES(4, 'four');
259 INSERT INTO t3 VALUES(5, 'five');
260 } {
261 {INSERT t2 0 X. {} {i 2 t two}}
262 {INSERT t2 0 X. {} {i 4 t four}}
263 {INSERT t1 0 X. {} {i 3 t three}}
264 {INSERT t3 0 X. {} {i 5 t five}}
265 }
266
267 } {
268 execsql {
269 DELETE FROM t1;
270 DELETE FROM t2;
271 DELETE FROM t3;
272 }
273 sqlite3session S db main
274 eval $setup1
275 execsql $sql1
276 set c1 [S changeset]
277 S delete
278
279 sqlite3session S db main
280 eval $setup2
281 execsql $sql2
282 set c2 [S changeset]
283 S delete
284
285 set res [list]
286 sqlite3session_foreach x [sqlite3changeset_concat $c1 $c2] {
287 lappend res $x
288 }
289
290 do_test 3.$tn { set res } [list {*}$result]
291 }
292
293
294 finish_test
295
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/session/sessionE.test ('k') | third_party/sqlite/src/ext/session/sessionG.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698