OLD | NEW |
1 # 2005 December 30 | 1 # 2005 December 30 |
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 PRAGMA read_uncommitted = 1; | 394 PRAGMA read_uncommitted = 1; |
395 BEGIN; | 395 BEGIN; |
396 CREATE TABLE t1(a, b, UNIQUE(a, b)); | 396 CREATE TABLE t1(a, b, UNIQUE(a, b)); |
397 } db2 | 397 } db2 |
398 for {set i 0} {$i < 2} {incr i} { | 398 for {set i 0} {$i < 2} {incr i} { |
399 set a [string repeat $i 10] | 399 set a [string repeat $i 10] |
400 set b [string repeat $i 2000] | 400 set b [string repeat $i 2000] |
401 execsql {INSERT INTO t1 VALUES($a, $b)} db2 | 401 execsql {INSERT INTO t1 VALUES($a, $b)} db2 |
402 } | 402 } |
403 execsql {COMMIT} db2 | 403 execsql {COMMIT} db2 |
| 404 execsql BEGIN |
| 405 execsql ROLLBACK |
404 set ::DB2 [sqlite3_connection_pointer db2] | 406 set ::DB2 [sqlite3_connection_pointer db2] |
405 set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY] | 407 set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY] |
406 sqlite3_step $::STMT ;# Cursor points at 0000000000 | 408 sqlite3_step $::STMT ;# Cursor points at 0000000000 |
407 sqlite3_step $::STMT ;# Cursor points at 1111111111 | 409 sqlite3_step $::STMT ;# Cursor points at 1111111111 |
408 } -tclbody { | 410 } -tclbody { |
409 execsql { | 411 execsql { |
410 BEGIN; | 412 BEGIN; |
411 INSERT INTO t1 VALUES(6, NULL); | 413 INSERT INTO t1 VALUES(6, NULL); |
412 ROLLBACK; | 414 ROLLBACK} |
413 } | |
414 } -cleanup { | 415 } -cleanup { |
415 # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned. | 416 # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned. |
416 # So these tests have been updated to expect SQLITE_CORRUPT and its | 417 # So these tests have been updated to expect SQLITE_CORRUPT and its |
417 # associated English language error message. | 418 # associated English language error message. |
418 # | 419 # |
419 do_test shared_malloc-8.$::n.cleanup.1 { | 420 do_test shared_malloc-8.$::n.cleanup.1 { |
420 set res [catchsql {SELECT a FROM t1} db2] | 421 set res [catchsql {SELECT a FROM t1} db2] |
421 set ans [lindex $res 1] | 422 set ans [lindex $res 1] |
422 if {[lindex $res 0]} { | 423 if {[lindex $res 0]} { |
423 set r [expr { | 424 set r [expr { |
(...skipping 14 matching lines...) Expand all Loading... |
438 expr { | 439 expr { |
439 ($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") || | 440 ($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") || |
440 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") || | 441 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") || |
441 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM") || | 442 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM") || |
442 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR") || | 443 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR") || |
443 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_CORRUPT") | 444 ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_CORRUPT") |
444 } | 445 } |
445 } {1} | 446 } {1} |
446 db2 close | 447 db2 close |
447 } | 448 } |
| 449 |
| 450 # When this test case was written, OOM errors in write statements would |
| 451 # cause transaction rollback, which would trip cursors in other statements, |
| 452 # aborting them. This no longer happens. |
| 453 # |
448 do_test shared_malloc-8.X { | 454 do_test shared_malloc-8.X { |
449 # Test that one or more queries were aborted due to the malloc() failure. | 455 # Test that one or more queries were aborted due to the malloc() failure. |
450 expr $::aborted>=1 | 456 # expr $::aborted>=1 |
| 457 expr $::aborted==0 |
451 } {1} | 458 } {1} |
452 | 459 |
453 # This test is designed to catch a specific bug that was present during | 460 # This test is designed to catch a specific bug that was present during |
454 # development of 3.5.0. If a malloc() failed while setting the page-size, | 461 # development of 3.5.0. If a malloc() failed while setting the page-size, |
455 # a buffer (Pager.pTmpSpace) was being freed. This could cause a seg-fault | 462 # a buffer (Pager.pTmpSpace) was being freed. This could cause a seg-fault |
456 # later if another connection tried to use the pager. | 463 # later if another connection tried to use the pager. |
457 # | 464 # |
458 # This test will crash 3.4.2. | 465 # This test will crash 3.4.2. |
459 # | 466 # |
460 do_malloc_test shared_err-9 -tclprep { | 467 do_malloc_test shared_err-9 -tclprep { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 519 |
513 do_malloc_test shared_err-12 -sqlbody { | 520 do_malloc_test shared_err-12 -sqlbody { |
514 CREATE TABLE abc(a, b, c); | 521 CREATE TABLE abc(a, b, c); |
515 INSERT INTO abc VALUES(1, 2, 3); | 522 INSERT INTO abc VALUES(1, 2, 3); |
516 } | 523 } |
517 | 524 |
518 catch {db close} | 525 catch {db close} |
519 catch {db2 close} | 526 catch {db2 close} |
520 sqlite3_enable_shared_cache $::enable_shared_cache | 527 sqlite3_enable_shared_cache $::enable_shared_cache |
521 finish_test | 528 finish_test |
OLD | NEW |