| OLD | NEW |
| 1 # 2008 November 20 | 1 # 2008 November 20 |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 INSERT INTO t1 VALUES(0, 0, zeroblob(676)); | 43 INSERT INTO t1 VALUES(0, 0, zeroblob(676)); |
| 44 } | 44 } |
| 45 execsql { | 45 execsql { |
| 46 INSERT INTO t1 VALUES(1, 1, zeroblob(676)); | 46 INSERT INTO t1 VALUES(1, 1, zeroblob(676)); |
| 47 } | 47 } |
| 48 } {} | 48 } {} |
| 49 | 49 |
| 50 # Trigger the problem using statement rollback. | 50 # Trigger the problem using statement rollback. |
| 51 # | 51 # |
| 52 db close | 52 db close |
| 53 file delete test.db | 53 delete_file test.db |
| 54 sqlite3 db test.db | 54 sqlite3 db test.db |
| 55 set big [string repeat abcdefghij 22] ;# 220 byte string | 55 set big [string repeat abcdefghij 22] ;# 220 byte string |
| 56 do_test tkt35xx-1.2.1 { | 56 do_test tkt35xx-1.2.1 { |
| 57 execsql { | 57 execsql { |
| 58 PRAGMA auto_vacuum = 0; | 58 PRAGMA auto_vacuum = 0; |
| 59 PRAGMA page_size = 1024; | 59 PRAGMA page_size = 1024; |
| 60 CREATE TABLE t3(a INTEGER PRIMARY KEY, b); | 60 CREATE TABLE t3(a INTEGER PRIMARY KEY, b); |
| 61 INSERT INTO t3 VALUES(1, $big); | 61 INSERT INTO t3 VALUES(1, $big); |
| 62 INSERT INTO t3 VALUES(2, $big); | 62 INSERT INTO t3 VALUES(2, $big); |
| 63 INSERT INTO t3 VALUES(3, $big); | 63 INSERT INTO t3 VALUES(3, $big); |
| 64 INSERT INTO t3 VALUES(4, $big); | 64 INSERT INTO t3 VALUES(4, $big); |
| 65 CREATE TABLE t4(c, d); | 65 CREATE TABLE t4(c, d); |
| 66 INSERT INTO t4 VALUES(5, $big); | 66 INSERT INTO t4 VALUES(5, $big); |
| 67 INSERT INTO t4 VALUES(1, $big); | 67 INSERT INTO t4 VALUES(1, $big); |
| 68 } | 68 } |
| 69 } {} | 69 } {} |
| 70 do_test tkt35xx-1.2.2 { | 70 do_test tkt35xx-1.2.2 { |
| 71 catchsql { | 71 catchsql { |
| 72 BEGIN; | 72 BEGIN; |
| 73 CREATE TABLE t5(e PRIMARY KEY, f); | 73 CREATE TABLE t5(e PRIMARY KEY, f); |
| 74 DROP TABLE t5; | 74 DROP TABLE t5; |
| 75 INSERT INTO t3(a, b) SELECT c, d FROM t4; | 75 INSERT INTO t3(a, b) SELECT c, d FROM t4; |
| 76 } | 76 } |
| 77 } {1 {PRIMARY KEY must be unique}} | 77 } {1 {UNIQUE constraint failed: t3.a}} |
| 78 do_test tkt35xx-1.2.3 { | 78 do_test tkt35xx-1.2.3 { |
| 79 # Show that the transaction has not been rolled back. | 79 # Show that the transaction has not been rolled back. |
| 80 catchsql BEGIN | 80 catchsql BEGIN |
| 81 } {1 {cannot start a transaction within a transaction}} | 81 } {1 {cannot start a transaction within a transaction}} |
| 82 do_test tkt35xx-1.2.4 { | 82 do_test tkt35xx-1.2.4 { |
| 83 execsql { SELECT count(*) FROM t3 } | 83 execsql { SELECT count(*) FROM t3 } |
| 84 } {4} | 84 } {4} |
| 85 do_test tkt35xx-1.2.5 { | 85 do_test tkt35xx-1.2.5 { |
| 86 # Before the bug was fixed, if SQLITE_DEBUG was defined an assert() | 86 # Before the bug was fixed, if SQLITE_DEBUG was defined an assert() |
| 87 # would fail during the following INSERT statement. If SQLITE_DEBUG | 87 # would fail during the following INSERT statement. If SQLITE_DEBUG |
| 88 # was not defined, then the statement would pass and the transaction | 88 # was not defined, then the statement would pass and the transaction |
| 89 # would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would | 89 # would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would |
| 90 # return 1, not 5. Data magically disappeared! | 90 # return 1, not 5. Data magically disappeared! |
| 91 # | 91 # |
| 92 execsql { | 92 execsql { |
| 93 INSERT INTO t3 VALUES(5, $big); | 93 INSERT INTO t3 VALUES(5, $big); |
| 94 COMMIT; | 94 COMMIT; |
| 95 } | 95 } |
| 96 } {} | 96 } {} |
| 97 do_test tkt35xx-1.2.6 { | 97 do_test tkt35xx-1.2.6 { |
| 98 execsql { SELECT count(*) FROM t3 } | 98 execsql { SELECT count(*) FROM t3 } |
| 99 } {5} | 99 } {5} |
| 100 integrity_check tkt35xx-1.2.7 | 100 integrity_check tkt35xx-1.2.7 |
| 101 | 101 |
| 102 finish_test | 102 finish_test |
| OLD | NEW |