AryaWu/sqlite
0
1# 2008 Feb 12#3# The author disclaims copyright to this source code. In place of4# 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 17set testdir [file dirname $argv0]18source $testdir/tester.tcl19 20# Create a database file that is full.21#22do_test tkt2920-1.1 {23 db eval {24 PRAGMA page_size=1024;25 PRAGMA max_page_count=40;26 PRAGMA auto_vacuum=0;27 CREATE TABLE filler (fill);28 }29 file size test.db30} {2048}31do_test tkt2920-1.2 {32 db eval BEGIN33 for {set i 0} {$i<34} {incr i} {34 db eval {INSERT INTO filler VALUES(randomblob(1024))}35 }36 db eval COMMIT37} {}38 39# Try to add a single new page to the full database. We get40# a disk full error. But this does not corrupt the database.41#42do_test tkt2920-1.3 {43 db eval BEGIN44 catchsql {45 INSERT INTO filler VALUES(randomblob(1024))46 }47} {1 {database or disk is full}}48integrity_check tkt2920-1.449 50# Increase the maximum size of the database file by 1 page,51# but then try to add a two-page record. This also fails.52#53do_test tkt2920-1.5 {54 db eval {PRAGMA max_page_count=41}55 catchsql {56 INSERT INTO filler VALUES(randomblob(2048))57 }58} {1 {database or disk is full}}59integrity_check tkt2920-1.660 61# Increase the maximum size of the database by one more page.62# This time the insert works.63#64do_test tkt2920-1.7 {65 db eval {PRAGMA max_page_count=42}66 catchsql {67 INSERT INTO filler VALUES(randomblob(2048))68 }69} {0 {}}70integrity_check tkt2920-1.871 72# The previous errors cancelled the transaction.73#74do_test tkt2920-1.9 {75 catchsql {COMMIT}76} {1 {cannot commit - no transaction is active}}77 78finish_test79 