mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix some problems with multi-file transaction rollback. (CVS 1751)
FossilOrigin-Name: 06e8e30b249c10512a225d6c7a5fcb5c666595e6
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C A\sfew\smore\swarning\sfixes.\s(CVS\s1750)
|
C Fix\ssome\sproblems\swith\smulti-file\stransaction\srollback.\s(CVS\s1751)
|
||||||
D 2004-06-28T01:16:46
|
D 2004-06-28T04:52:30
|
||||||
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
|
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
|
||||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@@ -50,7 +50,7 @@ F src/os_unix.c bd62e20d3abfb96c41fe737715b328d1dbb52bf7
|
|||||||
F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a
|
F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a
|
||||||
F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96
|
F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96
|
||||||
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
|
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
|
||||||
F src/pager.c 1156c264f314142fd73eedf5ad27e42b279227b0
|
F src/pager.c c1d5212e7cac86bc1a29d01a30d9dbbdb545dfd8
|
||||||
F src/pager.h fe818866f6d1adcffeed88705e8df7e588cbaf13
|
F src/pager.h fe818866f6d1adcffeed88705e8df7e588cbaf13
|
||||||
F src/parse.y e19e066e726a31d7b2d3e6475bdf55f7e339f8a3
|
F src/parse.y e19e066e726a31d7b2d3e6475bdf55f7e339f8a3
|
||||||
F src/pragma.c 2ca5ef7e27916f191a3b1201ad576ef6f8a8d72d
|
F src/pragma.c 2ca5ef7e27916f191a3b1201ad576ef6f8a8d72d
|
||||||
@@ -104,7 +104,7 @@ F test/collate4.test 0e9fc08ffcf6eddf72e354a15de06688fa86db31
|
|||||||
F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5
|
F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5
|
||||||
F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675
|
F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675
|
||||||
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
|
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
|
||||||
F test/crash.test 886d531d4057fe1bf3fae57166127a1ac82c39cb
|
F test/crash.test 3ea432ce624369c04ba1a23a5288115e40f5daa2
|
||||||
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
|
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
|
||||||
F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d
|
F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d
|
||||||
F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07
|
F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07
|
||||||
@@ -229,7 +229,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
|||||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||||
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
|
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
|
||||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||||
P fae7c6e004aa4752fd3db09a42bfdb900861b3c0
|
P 81e4994045697470bcfd692a794731c8291a8a30
|
||||||
R a3cbd2e575e2da580062b00616263b99
|
R 720c8ecc08d420175dd5d527a0298db7
|
||||||
U danielk1977
|
U danielk1977
|
||||||
Z 263ce207f2792f2dd2bd1a2e796f4361
|
Z 4b192e4a8c202247fb9d2a51a2cec3ca
|
||||||
|
@@ -1 +1 @@
|
|||||||
81e4994045697470bcfd692a794731c8291a8a30
|
06e8e30b249c10512a225d6c7a5fcb5c666595e6
|
24
src/pager.c
24
src/pager.c
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.146 2004/06/28 01:16:46 danielk1977 Exp $
|
** @(#) $Id: pager.c,v 1.147 2004/06/28 04:52:30 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "os.h" /* Must be first to enable large file support */
|
#include "os.h" /* Must be first to enable large file support */
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -424,10 +424,10 @@ static int readMasterJournal(OsFile *pJrnl, char **pzMaster){
|
|||||||
rc = sqlite3OsRead(pJrnl, aMagic, 8);
|
rc = sqlite3OsRead(pJrnl, aMagic, 8);
|
||||||
if( rc!=SQLITE_OK || memcmp(aMagic, aJournalMagic, 8) ) return rc;
|
if( rc!=SQLITE_OK || memcmp(aMagic, aJournalMagic, 8) ) return rc;
|
||||||
|
|
||||||
rc = sqlite3OsSeek(pJrnl, szJ-12-len);
|
rc = sqlite3OsSeek(pJrnl, szJ-16-len);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
|
|
||||||
*pzMaster = (char *)sqliteMalloc(len);
|
*pzMaster = (char *)sqliteMalloc(len+1);
|
||||||
if( !*pzMaster ){
|
if( !*pzMaster ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
@@ -440,12 +440,18 @@ static int readMasterJournal(OsFile *pJrnl, char **pzMaster){
|
|||||||
|
|
||||||
/* See if the checksum matches the master journal name */
|
/* See if the checksum matches the master journal name */
|
||||||
for(i=0; i<len; i++){
|
for(i=0; i<len; i++){
|
||||||
cksum -= *pzMaster[i];
|
cksum -= (*pzMaster)[i];
|
||||||
}
|
}
|
||||||
if( !cksum ){
|
if( cksum ){
|
||||||
|
/* If the checksum doesn't add up, then one or more of the disk sectors
|
||||||
|
** containing the master journal filename is corrupted. This means
|
||||||
|
** definitely roll back, so just return SQLITE_OK and report a (nul)
|
||||||
|
** master-journal filename.
|
||||||
|
*/
|
||||||
sqliteFree(*pzMaster);
|
sqliteFree(*pzMaster);
|
||||||
*pzMaster = 0;
|
*pzMaster = 0;
|
||||||
}
|
}
|
||||||
|
(*pzMaster)[len] = '\0';
|
||||||
|
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
@@ -913,7 +919,7 @@ static int pager_delmaster(const char *zMaster){
|
|||||||
** is running this routine also. Not that it makes too much difference.
|
** is running this routine also. Not that it makes too much difference.
|
||||||
*/
|
*/
|
||||||
memset(&master, 0, sizeof(master));
|
memset(&master, 0, sizeof(master));
|
||||||
rc = sqlite3OsOpenExclusive(zMaster, &master, 0);
|
rc = sqlite3OsOpenReadOnly(zMaster, &master);
|
||||||
if( rc!=SQLITE_OK ) goto delmaster_out;
|
if( rc!=SQLITE_OK ) goto delmaster_out;
|
||||||
master_open = 1;
|
master_open = 1;
|
||||||
rc = sqlite3OsFileSize(&master, &nMasterJournal);
|
rc = sqlite3OsFileSize(&master, &nMasterJournal);
|
||||||
@@ -1166,6 +1172,9 @@ static int pager_playback(Pager *pPager){
|
|||||||
pager_reload_cache(pPager);
|
pager_reload_cache(pPager);
|
||||||
|
|
||||||
end_playback:
|
end_playback:
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
rc = pager_unwritelock(pPager);
|
||||||
|
}
|
||||||
if( zMaster ){
|
if( zMaster ){
|
||||||
/* If there was a master journal and this routine will return true,
|
/* If there was a master journal and this routine will return true,
|
||||||
** see if it is possible to delete the master journal. If errors
|
** see if it is possible to delete the master journal. If errors
|
||||||
@@ -1176,9 +1185,6 @@ end_playback:
|
|||||||
}
|
}
|
||||||
sqliteFree(zMaster);
|
sqliteFree(zMaster);
|
||||||
}
|
}
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
rc = pager_unwritelock(pPager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The Pager.sectorSize variable may have been updated while rolling
|
/* The Pager.sectorSize variable may have been updated while rolling
|
||||||
** back a journal created by a process with a different PAGER_SECTOR_SIZE
|
** back a journal created by a process with a different PAGER_SECTOR_SIZE
|
||||||
|
@@ -20,13 +20,13 @@
|
|||||||
# The special crash-test module with its os_test.c backend only works
|
# The special crash-test module with its os_test.c backend only works
|
||||||
# on Unix.
|
# on Unix.
|
||||||
#
|
#
|
||||||
# $Id: crash.test,v 1.6 2004/06/26 19:35:30 drh Exp $
|
# $Id: crash.test,v 1.7 2004/06/28 04:52:31 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
set repeats 100
|
# set repeats 100
|
||||||
# set repeats 10
|
set repeats 10
|
||||||
|
|
||||||
# This proc execs a seperate process that crashes midway through executing
|
# This proc execs a seperate process that crashes midway through executing
|
||||||
# the SQL script $sql on database test.db.
|
# the SQL script $sql on database test.db.
|
||||||
@@ -249,11 +249,11 @@ do_test crash-4.0 {
|
|||||||
expr [file size test2.db] / 1024
|
expr [file size test2.db] / 1024
|
||||||
} {559}
|
} {559}
|
||||||
|
|
||||||
for {set i 1} {$i < $repeats} {incr i} {
|
for {set i 1} {$i<$repeats} {incr i} {
|
||||||
set sig [signature]
|
set sig [signature]
|
||||||
set sig2 [signature2]
|
set sig2 [signature2]
|
||||||
do_test crash-4.1.$i.1 {
|
do_test crash-4.1.$i.1 {
|
||||||
crashsql [expr $i%5 + 1] test.db-journal "
|
set c [crashsql $i test.db-journal "
|
||||||
ATTACH 'test2.db' AS aux;
|
ATTACH 'test2.db' AS aux;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT random() FROM abc LIMIT $i;
|
SELECT random() FROM abc LIMIT $i;
|
||||||
@@ -262,7 +262,8 @@ for {set i 1} {$i < $repeats} {incr i} {
|
|||||||
INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
|
INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
|
||||||
DELETE FROM abc2 WHERE random()%10!=0;
|
DELETE FROM abc2 WHERE random()%10!=0;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
"
|
"]
|
||||||
|
set c
|
||||||
} {1 {child process exited abnormally}}
|
} {1 {child process exited abnormally}}
|
||||||
do_test crash-4.1.$i.2 {
|
do_test crash-4.1.$i.2 {
|
||||||
signature
|
signature
|
||||||
@@ -271,11 +272,13 @@ for {set i 1} {$i < $repeats} {incr i} {
|
|||||||
signature2
|
signature2
|
||||||
} $sig2
|
} $sig2
|
||||||
}
|
}
|
||||||
for {set i 1} {$i < $repeats} {incr i} {
|
set i 0
|
||||||
|
while {[incr i]} {
|
||||||
set sig [signature]
|
set sig [signature]
|
||||||
set sig2 [signature2]
|
set sig2 [signature2]
|
||||||
|
set ::fin 0
|
||||||
do_test crash-4.2.$i.1 {
|
do_test crash-4.2.$i.1 {
|
||||||
crashsql [expr $i%5 + 1] test2.db-journal "
|
set c [crashsql $i test2.db-journal "
|
||||||
ATTACH 'test2.db' AS aux;
|
ATTACH 'test2.db' AS aux;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT random() FROM abc LIMIT $i;
|
SELECT random() FROM abc LIMIT $i;
|
||||||
@@ -284,8 +287,14 @@ for {set i 1} {$i < $repeats} {incr i} {
|
|||||||
INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
|
INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);
|
||||||
DELETE FROM abc2 WHERE random()%10!=0;
|
DELETE FROM abc2 WHERE random()%10!=0;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
"
|
"]
|
||||||
|
if { $c == {0 {}} } {
|
||||||
|
set ::fin 1
|
||||||
|
set c {1 {child process exited abnormally}}
|
||||||
|
}
|
||||||
|
set c
|
||||||
} {1 {child process exited abnormally}}
|
} {1 {child process exited abnormally}}
|
||||||
|
if { $::fin } break
|
||||||
do_test crash-4.2.$i.2 {
|
do_test crash-4.2.$i.2 {
|
||||||
signature
|
signature
|
||||||
} $sig
|
} $sig
|
||||||
|
Reference in New Issue
Block a user