danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 1 | # 2006 February 10 |
| 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 | # This file implements regression tests for SQLite library. |
| 12 | # |
| 13 | # This file implements tests to verify that ticket #1667 has been |
| 14 | # fixed. |
| 15 | # |
| 16 | # |
drh | f488388 | 2009-02-05 17:00:54 +0000 | [diff] [blame] | 17 | # $Id: tkt1667.test,v 1.4 2009/02/05 17:00:54 drh Exp $ |
danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 18 | |
| 19 | set testdir [file dirname $argv0] |
| 20 | source $testdir/tester.tcl |
| 21 | |
danielk1977 | 4b2688a | 2006-06-20 11:01:07 +0000 | [diff] [blame] | 22 | ifcapable !autovacuum||!tclvar { |
danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 23 | finish_test |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | db close |
mistachkin | fda06be | 2011-08-02 00:57:34 +0000 | [diff] [blame] | 28 | forcedelete test.db test.db-journal |
danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 29 | |
| 30 | # Set the pending byte offset such that the page it is on is |
| 31 | # the first autovacuum pointer map page in the file (assume a page |
| 32 | # size of 1024). |
| 33 | |
| 34 | set first_ptrmap_page [expr 1024/5 + 3] |
drh | f488388 | 2009-02-05 17:00:54 +0000 | [diff] [blame] | 35 | sqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)] |
danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 36 | |
drh | 4c0f164 | 2010-08-25 19:39:19 +0000 | [diff] [blame] | 37 | sqlite3 db test.db |
danielk1977 | 266664d | 2006-02-10 08:24:21 +0000 | [diff] [blame] | 38 | |
| 39 | do_test tkt1667-1 { |
| 40 | execsql { |
| 41 | PRAGMA auto_vacuum = 1; |
| 42 | BEGIN; |
| 43 | CREATE TABLE t1(a, b); |
| 44 | } |
| 45 | for {set i 0} {$i < 500} {incr i} { |
| 46 | execsql { |
| 47 | INSERT INTO t1 VALUES($i, randstr(1000, 2000)) |
| 48 | } |
| 49 | } |
| 50 | execsql { |
| 51 | COMMIT; |
| 52 | } |
| 53 | } {} |
| 54 | for {set i 0} {$i < 500} {incr i} { |
| 55 | do_test tkt1667-2.$i.1 { |
| 56 | execsql { |
| 57 | DELETE FROM t1 WHERE a = $i; |
| 58 | } |
| 59 | } {} |
| 60 | integrity_check tkt1667-2.$i.2 |
| 61 | } |
| 62 | |
| 63 | do_test tkt1667-3 { |
| 64 | execsql { |
| 65 | BEGIN; |
| 66 | } |
| 67 | for {set i 0} {$i < 500} {incr i} { |
| 68 | execsql { |
| 69 | INSERT INTO t1 VALUES($i, randstr(1000, 2000)) |
| 70 | } |
| 71 | } |
| 72 | execsql { |
| 73 | COMMIT; |
| 74 | } |
| 75 | } {} |
| 76 | do_test tkt1667-4.1 { |
| 77 | execsql { |
| 78 | DELETE FROM t1; |
| 79 | } |
| 80 | } {} |
| 81 | integrity_check tkt1667-4.2 |
| 82 | |
| 83 | finish_test |