From b94bf855b2e6fc5866034729ff545492e7eee14e Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Mon, 19 Mar 2007 13:53:37 +0000 Subject: [PATCH] Fix some problems with test cases in shared_err.test. Also a real bug causing a segfault after an IO error in pager.c. (CVS 3703) FossilOrigin-Name: 9f62ef1ec385d9f1a1913439dc4c2d710373f12a --- manifest | 16 +++++++-------- manifest.uuid | 2 +- src/pager.c | 3 ++- test/shared_err.test | 49 ++++++++++++++++++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 86986efb67..b170f0e40b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scomment\sin\sbtree.c\s(CVS\s3702) -D 2007-03-19T11:54:10 +C Fix\ssome\sproblems\swith\stest\scases\sin\sshared_err.test.\sAlso\sa\sreal\sbug\scausing\sa\ssegfault\safter\san\sIO\serror\sin\spager.c.\s(CVS\s3703) +D 2007-03-19T13:53:38 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -86,7 +86,7 @@ F src/os_unix.c 33ee7c1483fbd4d67cf5638c87622c277442b744 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c f3ca3e08167eb3382781b840e787809eccb626dc F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c c276e9de4e77d1c3d72367a7e207fa82e0e74af3 +F src/pager.c 3688e882a10a693cbdc9303426d3a52b8f48ccd5 F src/pager.h 8881591ca23d1e5fd83c95fa8317245fbcf64227 F src/parse.y bcfe366c1fd61cfc40e5344eb69a31997a821af0 F src/pragma.c b52dcf2fbb46f3266f9d00b88054c684df3af2e7 @@ -296,7 +296,7 @@ F test/server1.test e328b8e641ba8fe9273132cfef497383185dc1f5 F test/shared.test 0ed247941236788c255b3b29b5a82d5ca71b6432 F test/shared2.test 8b48f8d33494413ef4cf250110d89403e2bf6b23 F test/shared3.test 01e3e124dbb3859788aabc7cfb82f7ea04421749 -F test/shared_err.test 299a9180a6376b2089e8e0d469f383fe91bfa4ff +F test/shared_err.test 841f7341eb07ed97c713bf89960a4e9199717193 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 F test/speed1.test 4d6719b252fe90dc52f663a6b2a24cf6472ceac9 F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797 @@ -437,7 +437,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 3a3e8eb25d8e04cfccc5c0513ed04efcc25d3dbf -R a297b1419430310b47806366b750440a -U drh -Z 55992e8d0ba687290ede6e38f8418c27 +P 05700c11a9e5177a437d2240e72fb61ea47b973b +R 5b98dd2b31d3223324e5610c7e38647f +U danielk1977 +Z e38c1767e7ac582db2f50d60881eead5 diff --git a/manifest.uuid b/manifest.uuid index 200fd54ba3..e066da992a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05700c11a9e5177a437d2240e72fb61ea47b973b \ No newline at end of file +9f62ef1ec385d9f1a1913439dc4c2d710373f12a \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index b2ada00419..68c06947a5 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.290 2007/03/19 11:25:20 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.291 2007/03/19 13:53:38 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -880,6 +880,7 @@ static void pager_reset(Pager *pPager){ pNext = pPg->pNextAll; sqliteFree(pPg); } + pPager->pStmt = 0; pPager->pFirst = 0; pPager->pFirstSynced = 0; pPager->pLast = 0; diff --git a/test/shared_err.test b/test/shared_err.test index 0fe0220eac..e4ba31c3ae 100644 --- a/test/shared_err.test +++ b/test/shared_err.test @@ -13,7 +13,7 @@ # cache context. What happens to connection B if one connection A encounters # an IO-error whilst reading or writing the file-system? # -# $Id: shared_err.test,v 1.9 2006/01/24 16:37:59 danielk1977 Exp $ +# $Id: shared_err.test,v 1.10 2007/03/19 13:53:38 danielk1977 Exp $ proc skip {args} {} @@ -28,7 +28,6 @@ ifcapable !shared_cache||!subquery { } set ::enable_shared_cache [sqlite3_enable_shared_cache 1] - # Todo: This is a copy of the [do_malloc_test] proc in malloc.test # It would be better if these were consolidated. @@ -256,15 +255,49 @@ do_ioerr_test shared_ioerr-3 -tclprep { COMMIT; } } -cleanup { + set ::steprc [sqlite3_step $::STMT] + set ::column [sqlite3_column_text $::STMT 0] + set ::finalrc [sqlite3_finalize $::STMT] + + # There are three possible outcomes here (assuming persistent IO errors): + # + # 1. If the [sqlite3_step] did not require any IO (required pages in + # the cache), then the next row ("002...") may be retrieved + # successfully. + # + # 2. If the [sqlite3_step] does require IO, then [sqlite3_step] returns + # SQLITE_ERROR and [sqlite3_finalize] returns IOERR. + # + # 3. If, after the initial IO error, SQLite tried to rollback the + # active transaction and a second IO error was encountered, then + # statement $::STMT will have been aborted. This means [sqlite3_stmt] + # returns SQLITE_ABORT, and the statement cursor does not move. i.e. + # [sqlite3_column] still returns the current row ("001...") and + # [sqlite3_finalize] returns SQLITE_OK. + # + do_test shared_ioerr-3.$n.cleanup.1 { - sqlite3_step $::STMT - } {SQLITE_ROW} + expr { + $::steprc eq "SQLITE_ROW" || + $::steprc eq "SQLITE_ERROR" || + $::steprc eq "SQLITE_ABORT" + } + } {1} do_test shared_ioerr-3.$n.cleanup.2 { - sqlite3_column_text $::STMT 0 - } {002.002.002.002.002} + expr { + ($::steprc eq "SQLITE_ROW" && $::column eq "002.002.002.002.002") || + ($::steprc eq "SQLITE_ERROR" && $::column eq "") || + ($::steprc eq "SQLITE_ABORT" && $::column eq "001.001.001.001.001") + } + } {1} do_test shared_ioerr-3.$n.cleanup.3 { - sqlite3_finalize $::STMT - } {SQLITE_OK} + expr { + ($::steprc eq "SQLITE_ROW" && $::finalrc eq "SQLITE_OK") || + ($::steprc eq "SQLITE_ERROR" && $::finalrc eq "SQLITE_IOERR") || + ($::steprc eq "SQLITE_ABORT" && $::finalrc eq "SQLITE_OK") + } + } {1} + # db2 eval {select * from sqlite_master} db2 close }