tkt1667.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #
  17. # $Id: tkt1667.test,v 1.4 2009/02/05 17:00:54 drh Exp $
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. ifcapable !autovacuum||!tclvar {
  21. finish_test
  22. return
  23. }
  24. db close
  25. forcedelete test.db test.db-journal
  26. # Set the pending byte offset such that the page it is on is
  27. # the first autovacuum pointer map page in the file (assume a page
  28. # size of 1024).
  29. set first_ptrmap_page [expr 1024/5 + 3]
  30. sqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)]
  31. sqlite3 db test.db
  32. do_test tkt1667-1 {
  33. execsql {
  34. PRAGMA auto_vacuum = 1;
  35. BEGIN;
  36. CREATE TABLE t1(a, b);
  37. }
  38. for {set i 0} {$i < 500} {incr i} {
  39. execsql {
  40. INSERT INTO t1 VALUES($i, randstr(1000, 2000))
  41. }
  42. }
  43. execsql {
  44. COMMIT;
  45. }
  46. } {}
  47. for {set i 0} {$i < 500} {incr i} {
  48. do_test tkt1667-2.$i.1 {
  49. execsql {
  50. DELETE FROM t1 WHERE a = $i;
  51. }
  52. } {}
  53. integrity_check tkt1667-2.$i.2
  54. }
  55. do_test tkt1667-3 {
  56. execsql {
  57. BEGIN;
  58. }
  59. for {set i 0} {$i < 500} {incr i} {
  60. execsql {
  61. INSERT INTO t1 VALUES($i, randstr(1000, 2000))
  62. }
  63. }
  64. execsql {
  65. COMMIT;
  66. }
  67. } {}
  68. do_test tkt1667-4.1 {
  69. execsql {
  70. DELETE FROM t1;
  71. }
  72. } {}
  73. integrity_check tkt1667-4.2
  74. finish_test