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

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5corrupt3.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
1 # 2015 Apr 24 1 # 2015 Apr 24
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 #***********************************************************************
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } {} 172 } {}
173 173
174 set nErr 0 174 set nErr 0
175 for {set i 1} {1} {incr i} { 175 for {set i 1} {1} {incr i} {
176 set struct [db one {SELECT block FROM t1_data WHERE id=10}] 176 set struct [db one {SELECT block FROM t1_data WHERE id=10}]
177 binary scan $struct c* var 177 binary scan $struct c* var
178 set end [lindex $var end] 178 set end [lindex $var end]
179 if {$end<=$i} break 179 if {$end<=$i} break
180 lset var end [expr $end - $i] 180 lset var end [expr $end - $i]
181 set struct [binary format c* $var] 181 set struct [binary format c* $var]
182
183 db close
184 sqlite3 db test.db
185
182 db eval { 186 db eval {
183 BEGIN; 187 BEGIN;
184 UPDATE t1_data SET block = $struct WHERE id=10; 188 UPDATE t1_data SET block = $struct WHERE id=10;
185 } 189 }
186 do_test 4.1.$i { 190 do_test 4.1.$i {
187 incr nErr [catch { db eval { SELECT rowid FROM t1 WHERE t1 MATCH 'x*' } }] 191 incr nErr [catch { db eval { SELECT rowid FROM t1 WHERE t1 MATCH 'x*' } }]
188 set {} {} 192 set {} {}
189 } {} 193 } {}
190 catch { db eval ROLLBACK } 194 catch { db eval ROLLBACK }
191 } 195 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 UPDATE t1_data SET block = 331 UPDATE t1_data SET block =
328 X'0000001C503061626301020204036465660102030707676869010204040808' 332 X'0000001C503061626301020204036465660102030707676869010204040808'
329 ----------^^----------------------------------------------------- 333 ----------^^-----------------------------------------------------
330 WHERE id>100; 334 WHERE id>100;
331 } 335 }
332 do_catchsql_test 6.3.5 { 336 do_catchsql_test 6.3.5 {
333 INSERT INTO t1(t1) VALUES('integrity-check'); 337 INSERT INTO t1(t1) VALUES('integrity-check');
334 } {1 {database disk image is malformed}} 338 } {1 {database disk image is malformed}}
335 339
336 340
337 }
338
339 #------------------------------------------------------------------------ 341 #------------------------------------------------------------------------
340 # 342 #
341 reset_db 343 reset_db
342 reset_db
343 proc rnddoc {n} { 344 proc rnddoc {n} {
344 set map [list a b c d] 345 set map [list a b c d]
345 set doc [list] 346 set doc [list]
346 for {set i 0} {$i < $n} {incr i} { 347 for {set i 0} {$i < $n} {incr i} {
347 lappend doc "x[lindex $map [expr int(rand()*4)]]" 348 lappend doc "x[lindex $map [expr int(rand()*4)]]"
348 } 349 }
349 set doc 350 set doc
350 } 351 }
351 352
352 db func rnddoc rnddoc 353 db func rnddoc rnddoc
(...skipping 11 matching lines...) Expand all
364 do_test 7.1 { 365 do_test 7.1 {
365 foreach i [db eval { SELECT rowid FROM t5_data WHERE rowid>100 }] { 366 foreach i [db eval { SELECT rowid FROM t5_data WHERE rowid>100 }] {
366 db eval BEGIN 367 db eval BEGIN
367 db eval {DELETE FROM t5_data WHERE rowid = $i} 368 db eval {DELETE FROM t5_data WHERE rowid = $i}
368 set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ] 369 set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ]
369 if {$r != "1 {database disk image is malformed}"} { error $r } 370 if {$r != "1 {database disk image is malformed}"} { error $r }
370 db eval ROLLBACK 371 db eval ROLLBACK
371 } 372 }
372 } {} 373 } {}
373 374
375 }
376
377 #------------------------------------------------------------------------
378 # Corruption within the structure record.
379 #
380 reset_db
381 do_execsql_test 8.1 {
382 CREATE VIRTUAL TABLE t1 USING fts5(x, y);
383 INSERT INTO t1 VALUES('one', 'two');
384 }
385
386 do_test 9.1.1 {
387 set blob "12345678" ;# cookie
388 append blob "0105" ;# 1 level, total of 5 segments
389 append blob "06" ;# write counter
390 append blob "0002" ;# first level has 0 segments merging, 2 other.
391 append blob "450108" ;# first segment
392 execsql "REPLACE INTO t1_data VALUES(10, X'$blob')"
393 } {}
394 do_catchsql_test 9.1.2 {
395 SELECT * FROM t1('one AND two');
396 } {1 {database disk image is malformed}}
397
398 do_test 9.2.1 {
399 set blob "12345678" ;# cookie
400 append blob "0205" ;# 2 levels, total of 5 segments
401 append blob "06" ;# write counter
402 append blob "0001" ;# first level has 0 segments merging, 1 other.
403 append blob "450108" ;# first segment
404 execsql "REPLACE INTO t1_data VALUES(10, X'$blob')"
405 } {}
406 do_catchsql_test 9.2.2 {
407 SELECT * FROM t1('one AND two');
408 } {1 {database disk image is malformed}}
409
374 sqlite3_fts5_may_be_corrupt 0 410 sqlite3_fts5_may_be_corrupt 0
375 finish_test 411 finish_test
376 412
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5corrupt2.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5detail.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698