From 104f1fef2de9137c31d700406d792732bf2c3106 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Wed, 14 Jan 2009 17:45:57 +0000 Subject: [PATCH] Fix a problem with committing a transaction while there are other active statements. Sometimes, the database change counter was not being updated. (CVS 6176) FossilOrigin-Name: b7d2a477aa2c3dbbb81d18fba1faa6835711b5c3 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pager.c | 3 ++- test/lock.test | 42 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 9d70885499..c03bda915d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.6.9\s(CVS\s6175) -D 2009-01-14T04:09:36 +C Fix\sa\sproblem\swith\scommitting\sa\stransaction\swhile\sthere\sare\sother\sactive\sstatements.\sSometimes,\sthe\sdatabase\schange\scounter\swas\snot\sbeing\supdated.\s(CVS\s6176) +D 2009-01-14T17:45:58 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -142,7 +142,7 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c 7825c6178597713382d74adbf8c8c00ffcdc42d4 F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709 -F src/pager.c 5a95868f4fe0efd2ec51f89efce470e9d63d6fed +F src/pager.c add3461c2dedf56e56d8d18d3506b6cc322fa363 F src/pager.h 9870acb2d653848d90d765d7cbf163496d6c8111 F src/parse.y 4d0e33a702dc3ea7b69d8ae1914b3fbd32e46057 F src/pcache.c 16dc8da6e6ba6250f8dfd9ee46036db1cbceedc6 @@ -421,7 +421,7 @@ F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e F test/loadext.test 18db29c081380fdedcfbd8c633847712059ae104 F test/loadext2.test 0bcaeb4d81cd5b6e883fdfea3c1bdbe1f173cbca -F test/lock.test a280c87f86cfe25ac8899bd6cdfd23ffc5aca40a +F test/lock.test 3f03827e056946c4b81b74006e62ffa2a3219ab3 F test/lock2.test 018b846f6f3b3b695fad07e317b7988442b556f4 F test/lock3.test 8adfbf438b96316267611214d494ebc1311b8cda F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90 @@ -697,7 +697,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P f5f5ef646bef6de6a744b565e089219d4e47397d -R 4f97314454171316749f2eb51c07be84 -U drh -Z d65a6a30099596d50d6572a776a8f3b0 +P b6ce8199a9286eb2d0a590abc8ef080594d84f83 +R ca33b022189d9e81c917d579a0524de0 +U danielk1977 +Z 675d862fdbda95891d2940f72045246e diff --git a/manifest.uuid b/manifest.uuid index 7026e03c24..465f38b8c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b6ce8199a9286eb2d0a590abc8ef080594d84f83 \ No newline at end of file +b7d2a477aa2c3dbbb81d18fba1faa6835711b5c3 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 45a5d0ab30..55dc04bd5d 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.549 2009/01/13 16:03:44 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.550 2009/01/14 17:45:58 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -1105,6 +1105,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){ if( !pPager->exclusiveMode ){ rc2 = osUnlock(pPager->fd, SHARED_LOCK); pPager->state = PAGER_SHARED; + pPager->changeCountDone = 0; }else if( pPager->state==PAGER_SYNCED ){ pPager->state = PAGER_EXCLUSIVE; } diff --git a/test/lock.test b/test/lock.test index b20303adc0..30469d5b9d 100644 --- a/test/lock.test +++ b/test/lock.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: lock.test,v 1.34 2008/11/21 22:21:51 drh Exp $ +# $Id: lock.test,v 1.35 2009/01/14 17:45:58 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -350,6 +350,46 @@ ifcapable tempdb { } {9} } +do_test lock-6.1 { + execsql { + CREATE TABLE t4(a PRIMARY KEY, b); + INSERT INTO t4 VALUES(1, 'one'); + INSERT INTO t4 VALUES(2, 'two'); + INSERT INTO t4 VALUES(3, 'three'); + } + + set STMT [sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 TAIL] + sqlite3_step $STMT + + execsql { DELETE FROM t4 } + execsql { SELECT * FROM sqlite_master } db2 + execsql { SELECT * FROM t4 } db2 +} {} + +do_test lock-6.2 { + execsql { + BEGIN; + INSERT INTO t4 VALUES(1, 'one'); + INSERT INTO t4 VALUES(2, 'two'); + INSERT INTO t4 VALUES(3, 'three'); + COMMIT; + } + + execsql { SELECT * FROM t4 } db2 +} {1 one 2 two 3 three} + +do_test lock-6.3 { + execsql { SELECT a FROM t4 ORDER BY a } db2 +} {1 2 3} + +do_test lock-6.4 { + execsql { PRAGMA integrity_check } db2 +} {ok} + +do_test lock-6.5 { + sqlite3_finalize $STMT +} {SQLITE_OK} + do_test lock-999.1 { rename db2 {} } {}