sl@0: # 2008 Feb 1 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # This file is to test that ticket #2920 is fixed. sl@0: # sl@0: # $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $ sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # Create a database file that is full. sl@0: # sl@0: do_test tkt2920-1.1 { sl@0: db eval { sl@0: PRAGMA page_size=1024; sl@0: PRAGMA max_page_count=40; sl@0: PRAGMA auto_vacuum=0; sl@0: CREATE TABLE filler (fill); sl@0: } sl@0: file size test.db sl@0: } {2048} sl@0: do_test tkt2920-1.2 { sl@0: db eval BEGIN sl@0: for {set i 0} {$i<34} {incr i} { sl@0: db eval {INSERT INTO filler VALUES(randomblob(1024))} sl@0: } sl@0: db eval COMMIT sl@0: } {} sl@0: sl@0: # Try to add a single new page to the full database. We get sl@0: # a disk full error. But this does not corrupt the database. sl@0: # sl@0: do_test tkt2920-1.3 { sl@0: db eval BEGIN sl@0: catchsql { sl@0: INSERT INTO filler VALUES(randomblob(1024)) sl@0: } sl@0: } {1 {database or disk is full}} sl@0: integrity_check tkt2920-1.4 sl@0: sl@0: # Increase the maximum size of the database file by 1 page, sl@0: # but then try to add a two-page record. This also fails. sl@0: # sl@0: do_test tkt2920-1.5 { sl@0: db eval {PRAGMA max_page_count=41} sl@0: catchsql { sl@0: INSERT INTO filler VALUES(randomblob(2048)) sl@0: } sl@0: } {1 {database or disk is full}} sl@0: integrity_check tkt2920-1.6 sl@0: sl@0: # Increase the maximum size of the database by one more page. sl@0: # This time the insert works. sl@0: # sl@0: do_test tkt2920-1.7 { sl@0: db eval {PRAGMA max_page_count=42} sl@0: catchsql { sl@0: INSERT INTO filler VALUES(randomblob(2048)) sl@0: } sl@0: } {0 {}} sl@0: integrity_check tkt2920-1.8 sl@0: sl@0: # The previous errors cancelled the transaction. sl@0: # sl@0: do_test tkt2920-1.9 { sl@0: catchsql {COMMIT} sl@0: } {1 {cannot commit - no transaction is active}} sl@0: sl@0: finish_test