tkt2920.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 2008 Feb 1
  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. # This file is to test that ticket #2920 is fixed.
  13. #
  14. # $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. # Create a database file that is full.
  19. #
  20. do_test tkt2920-1.1 {
  21. db eval {
  22. PRAGMA page_size=1024;
  23. PRAGMA max_page_count=40;
  24. PRAGMA auto_vacuum=0;
  25. CREATE TABLE filler (fill);
  26. }
  27. file size test.db
  28. } {2048}
  29. do_test tkt2920-1.2 {
  30. db eval BEGIN
  31. for {set i 0} {$i<34} {incr i} {
  32. db eval {INSERT INTO filler VALUES(randomblob(1024))}
  33. }
  34. db eval COMMIT
  35. } {}
  36. # Try to add a single new page to the full database. We get
  37. # a disk full error. But this does not corrupt the database.
  38. #
  39. do_test tkt2920-1.3 {
  40. db eval BEGIN
  41. catchsql {
  42. INSERT INTO filler VALUES(randomblob(1024))
  43. }
  44. } {1 {database or disk is full}}
  45. integrity_check tkt2920-1.4
  46. # Increase the maximum size of the database file by 1 page,
  47. # but then try to add a two-page record. This also fails.
  48. #
  49. do_test tkt2920-1.5 {
  50. db eval {PRAGMA max_page_count=41}
  51. catchsql {
  52. INSERT INTO filler VALUES(randomblob(2048))
  53. }
  54. } {1 {database or disk is full}}
  55. integrity_check tkt2920-1.6
  56. # Increase the maximum size of the database by one more page.
  57. # This time the insert works.
  58. #
  59. do_test tkt2920-1.7 {
  60. db eval {PRAGMA max_page_count=42}
  61. catchsql {
  62. INSERT INTO filler VALUES(randomblob(2048))
  63. }
  64. } {0 {}}
  65. integrity_check tkt2920-1.8
  66. # The previous errors cancelled the transaction.
  67. #
  68. do_test tkt2920-1.9 {
  69. catchsql {COMMIT}
  70. } {1 {cannot commit - no transaction is active}}
  71. finish_test