tkt3918.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # 2009 June 17
  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. #
  12. # $Id: tkt3918.test,v 1.1 2009/06/17 11:13:28 danielk1977 Exp $
  13. set testdir [file dirname $argv0]
  14. source $testdir/tester.tcl
  15. do_test tkt3918.1 {
  16. execsql {
  17. PRAGMA page_size = 1024;
  18. PRAGMA auto_vacuum = incremental;
  19. CREATE TABLE t1(i, x);
  20. }
  21. } {}
  22. do_test tkt3918.2 {
  23. execsql {
  24. INSERT INTO t1 VALUES(1, randstr(1000,1000));
  25. INSERT INTO t1 VALUES(2, zeroblob(248*1020 + 100));
  26. INSERT INTO t1 VALUES(3, zeroblob(2*1020 + 100));
  27. }
  28. } {}
  29. # This set of statements sets up the free list so that the
  30. # first free-list trunk page contains only a single leaf.
  31. # The leaf page is also the last page in the database. The
  32. # second free-list trunk page contains, amongst other things,
  33. # page number 4.
  34. do_test tkt3918.3 {
  35. execsql {
  36. DELETE FROM t1 WHERE i = 2;
  37. DELETE FROM t1 WHERE i = 1;
  38. DELETE FROM t1 WHERE i = 3;
  39. }
  40. } {}
  41. # Incrementally vacuum the database to reduce its size by a single
  42. # page. This will remove the single leaf from the first page in
  43. # the linked list of free-list trunk pages.
  44. do_test tkt3918.4 {
  45. execsql { PRAGMA incremental_vacuum = 1 }
  46. } {}
  47. # Create another table. This operation will attempt to extract
  48. # page 4 from the database free-list. Bug 3918 caused sqlite to
  49. # incorrectly report corruption here.
  50. do_test tkt3918.5 {
  51. execsql { CREATE TABLE t2(a, b) }
  52. } {}
  53. finish_test