From 047d4836ffc11b3b92848a3653625b1c53bf1fdd Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Oct 2004 14:38:02 +0000 Subject: [PATCH] Additional code to test the SQLITE_FULL return when the disk is full. (CVS 1994) FossilOrigin-Name: 44e56f0bba61245d342d6e75510d6c35785efd49 --- manifest | 19 ++++++++++--------- manifest.uuid | 2 +- src/os_common.h | 5 +++++ src/os_unix.c | 1 + src/test2.c | 5 ++++- test/diskfull.test | 40 ++++++++++++++++++++++++++++++++++++++++ test/ioerr.test | 9 +-------- 7 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 test/diskfull.test diff --git a/manifest b/manifest index 7717a2a5b6..a84eca7e4a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fully\srelease\sexclusive\slocks\sin\sthe\sUnlock\sprimitive\sof\sUnix.\nTicket\s#913.\s(CVS\s1993) -D 2004-10-01T03:02:48 +C Additional\scode\sto\stest\sthe\sSQLITE_FULL\sreturn\swhen\sthe\sdisk\sis\sfull.\s(CVS\s1994) +D 2004-10-01T14:38:03 F Makefile.in abdeb5bd9d017822691884935c320037c33f6ee6 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -42,12 +42,12 @@ F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/main.c 2a1b9623fde3fe5e22fe726cdae4e10f33671caa F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/os.h 5834a404b7c8318dc1928c9fc0137a65c9c0416c -F src/os_common.h cd7eb025fdab7dc91e0e97bf6310f1648205857f +F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73 F src/os_mac.c 7367dab0c44ab0b2c4337e73ac6f6f97f171c2cb F src/os_mac.h 608fdf39eafa1ce25fc8cb223b8b0a073341d4da F src/os_test.c d9a21852d170f20adeae6f224d1beba2cb5af8aa F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162 -F src/os_unix.c 8ee13cc8efb47dd3269327f1659f0aa59449e7e0 +F src/os_unix.c ca7891d1f84994559899ced37b45541a68028282 F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13 F src/os_win.c 0ab81ce1e4739e0e251b6aa3e74e1a6b75b612da F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b @@ -64,7 +64,7 @@ F src/sqliteInt.h 5c406ebc830c5129748b77539283c0e20f978887 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008 F src/test1.c 3d78e5d827bf5d037f697c233c5934d45af46cb5 -F src/test2.c 2d25e3893f7d1efeeba21958e6e66d92d5ec7762 +F src/test2.c b11fa244fff02190707dd0879987c37c75e61fc8 F src/test3.c 5b5b0f3d11b097399c1054fff73d8f3711092301 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1 @@ -112,6 +112,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/date.test fd3db29bba089578b1b008e3511ea9e74840377a F test/delete.test ec0b455f2dcc0e189d96ee438438ba026c4e51d8 F test/delete2.test 050a3a6e8ea0f83aed817d164b16af2a499fb452 +F test/diskfull.test e2f6cfd868713ead06dc82b84a4938e868128fc0 F test/enc.test 2f5463af488d50aef60c6110bec6b21b5efba961 F test/enc2.test 7a60971a62748be6b607b4b4380eb4c5e151a6ec F test/enc3.test 2ae80b11adf5b2c171d2e17214dabd356b9672c1 @@ -125,7 +126,7 @@ F test/insert.test ebbab63db4ad69395a058514bccb3cdb0a029d48 F test/insert2.test 614a29d3ed7dd0d8644a059c6d8ce742c63a734a F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91 F test/intpkey.test c8efd06db62b8b27216558ef439cc867d113cfec -F test/ioerr.test 7d087bfd1a1a53442940e000df936e0df0c5b886 +F test/ioerr.test 3ce897ee998ee874073f3b23b0396d9ff804759c F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8 F test/join3.test 67dc0d7c8dab3fff25796d0f3c3fd9c999aeded3 @@ -247,7 +248,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 8972c004dc825f668d952e7d082a89046b9260f1 -R c18f14c1b88558caba10e1e626c64832 +P 11a37a74b101b9e37dcf1c3e57e45fbcd39a1c21 +R 5cd09489a21e3070d0d9f7d48f412e67 U drh -Z cf49e4565c24c55963de6fd9ac42f0ce +Z 4aac176e6504fc7c2836065cfd34556a diff --git a/manifest.uuid b/manifest.uuid index 7f9f788547..4bd79f69e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11a37a74b101b9e37dcf1c3e57e45fbcd39a1c21 \ No newline at end of file +44e56f0bba61245d342d6e75510d6c35785efd49 \ No newline at end of file diff --git a/src/os_common.h b/src/os_common.h index dc8f88096a..94311b9604 100644 --- a/src/os_common.h +++ b/src/os_common.h @@ -81,14 +81,19 @@ static unsigned int elapse; */ #ifdef SQLITE_TEST int sqlite3_io_error_pending = 0; +int sqlite3_diskfull_pending = 0; #define SimulateIOError(A) \ if( sqlite3_io_error_pending ) \ if( sqlite3_io_error_pending-- == 1 ){ local_ioerr(); return A; } static void local_ioerr(){ sqlite3_io_error_pending = 0; /* Really just a place to set a breakpoint */ } +#define SimulateDiskfullError \ + if( sqlite3_diskfull_pending ) \ + if( sqlite3_diskfull_pending-- == 1 ){ local_ioerr(); return SQLITE_FULL; } #else #define SimulateIOError(A) +#define SimulateDiskfullError #endif /* diff --git a/src/os_unix.c b/src/os_unix.c index c0261e1c79..a5be702f28 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -646,6 +646,7 @@ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ int wrote = 0; assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); + SimulateDiskfullError; TIMER_START; while( amt>0 && (wrote = write(id->h, pBuf, amt))>0 ){ amt -= wrote; diff --git a/src/test2.c b/src/test2.c index 28dc78c465..0ba0c2a7f6 100644 --- a/src/test2.c +++ b/src/test2.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test2.c,v 1.26 2004/10/01 02:00:31 drh Exp $ +** $Id: test2.c,v 1.27 2004/10/01 14:38:03 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -533,6 +533,7 @@ static int fake_big_file( */ int Sqlitetest2_Init(Tcl_Interp *interp){ extern int sqlite3_io_error_pending; + extern int sqlite3_diskfull_pending; static struct { char *zName; Tcl_CmdProc *xProc; @@ -560,6 +561,8 @@ int Sqlitetest2_Init(Tcl_Interp *interp){ } Tcl_LinkVar(interp, "sqlite_io_error_pending", (char*)&sqlite3_io_error_pending, TCL_LINK_INT); + Tcl_LinkVar(interp, "sqlite_diskfull_pending", + (char*)&sqlite3_diskfull_pending, TCL_LINK_INT); Tcl_LinkVar(interp, "pager_pagesize", (char*)&test_pagesize, TCL_LINK_INT); return TCL_OK; diff --git a/test/diskfull.test b/test/diskfull.test new file mode 100644 index 0000000000..6870e12d9d --- /dev/null +++ b/test/diskfull.test @@ -0,0 +1,40 @@ +# 2001 October 12 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing for correct handling of disk full +# errors. +# +# $Id: diskfull.test,v 1.1 2004/10/01 14:38:03 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test diskfull-1.1 { + execsql { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randstr(1000,1000)); + INSERT INTO t1 SELECT * FROM t1; + } +} {} +do_test diskfull-1.2 { + set sqlite_diskfull_pending 1 + catchsql { + INSERT INTO t1 SELECT * FROM t1; + } +} {1 {database is full}} +do_test diskfull-1.3 { + set sqlite_diskfull_pending 1 + catchsql { + DELETE FROM t1; + } +} {1 {database is full}} + +finish_test diff --git a/test/ioerr.test b/test/ioerr.test index 2e15841984..380de82bec 100644 --- a/test/ioerr.test +++ b/test/ioerr.test @@ -15,7 +15,7 @@ # The tests in this file use special facilities that are only # available in the SQLite test fixture. # -# $Id: ioerr.test,v 1.5 2004/06/19 00:16:31 drh Exp $ +# $Id: ioerr.test,v 1.6 2004/10/01 14:38:03 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -106,16 +106,9 @@ for {set n 1} {$go} {incr n} { set ::sqlite_io_error_pending $n }] $n do_test ioerr-2.$n.3 { -if {$n==41} { - # set sqlite_os_trace 1 - breakpoint -} set r [catch {db eval { VACUUM; }} msg] - # puts "error_pending=$::sqlite_io_error_pending" - # if {$r} {puts $msg} -set sqlite_os_trace 0 set ::go [expr {$::sqlite_io_error_pending<=0}] expr {$::sqlite_io_error_pending>0 || $r!=0} set ::sqlite_io_error_pending 0 -- 2.47.3