1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

If an IO error is encountered on a commit, close the journal so that it

persists and can (hopefully) rollback the failed transaction later. (CVS 3792)

FossilOrigin-Name: 22e10cc24e4407feb276abfa8cc9964f20c6e54a
This commit is contained in:
drh
2007-04-02 11:22:22 +00:00
parent 08d31a2a6d
commit 01fa4c349f
3 changed files with 12 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
C Correctly\shandle\sthe\sobscure\scase\sof\sa\sread-only\shot-journal\sfile.\s(CVS\s3791) C If\san\sIO\serror\sis\sencountered\son\sa\scommit,\sclose\sthe\sjournal\sso\sthat\sit\npersists\sand\scan\s(hopefully)\srollback\sthe\sfailed\stransaction\slater.\s(CVS\s3792)
D 2007-04-02T11:08:59 D 2007-04-02T11:22:22
F Makefile.in 2f2c3bf69faf0ae7b8e8af4f94f1986849034530 F Makefile.in 2f2c3bf69faf0ae7b8e8af4f94f1986849034530
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -86,7 +86,7 @@ F src/os_unix.c ccb003fb9fadc032924d3efb3fa8cc69fd9e176b
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c c9a99524d6b2bdec636264cad1b67553925e3309 F src/os_win.c c9a99524d6b2bdec636264cad1b67553925e3309
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 0583079cb746f96702b7351b0cda346be4c02da8 F src/pager.c 30e4a54e4ce9817839043eaa8968aace95f73ed9
F src/pager.h e79a24cf200b8771366217f5bca414f5b7823f42 F src/pager.h e79a24cf200b8771366217f5bca414f5b7823f42
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3 F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234 F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234
@@ -448,7 +448,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P ba0538a4977aefd6645554f1989f0a98b540b9cd P 4d8c6bf44ec00ec04e615983cb33425ca2c3998a
R fe59b9bdc90ed7270cae7cde15f7b2a0 R b60be37f8194d17dcc865a186ba19df6
U danielk1977 U drh
Z 614d37969660406bc4f5f28fc9575c7e Z 36541dd9060dc60ff27a9aed65ba02c4

View File

@@ -1 +1 @@
4d8c6bf44ec00ec04e615983cb33425ca2c3998a 22e10cc24e4407feb276abfa8cc9964f20c6e54a

View File

@@ -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.315 2007/04/02 11:08:59 danielk1977 Exp $ ** @(#) $Id: pager.c,v 1.316 2007/04/02 11:22:22 drh Exp $
*/ */
#ifndef SQLITE_OMIT_DISKIO #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -942,26 +942,15 @@ static int pager_end_transaction(Pager *pPager){
pPager->stmtOpen = 0; pPager->stmtOpen = 0;
} }
if( pPager->journalOpen ){ if( pPager->journalOpen ){
if( pPager->exclusiveMode ){ if( pPager->exclusiveMode
rc = sqlite3OsTruncate(pPager->jfd, 0); && (rc = sqlite3OsTruncate(pPager->jfd, 0))==SQLITE_OK ){;
sqlite3OsSeek(pPager->jfd, 0); sqlite3OsSeek(pPager->jfd, 0);
pPager->journalOff = 0; pPager->journalOff = 0;
pPager->journalStarted = 0; pPager->journalStarted = 0;
}else{ }else{
sqlite3OsClose(&pPager->jfd); sqlite3OsClose(&pPager->jfd);
pPager->journalOpen = 0; pPager->journalOpen = 0;
/* If this is a temporary pager file, then the journal file should if( rc==SQLITE_OK ){
** have been configured as delete-on-close. Otherwise, it should still
** be in the file system. This pager still holds a RESERVED or greater
** lock on the database file, so there is no chance another process
** could create or remove a journal file.
**
** These asserts are not valid for asynchronous I/O such as is found
** in async.test
*/
/*assert( sqlite3OsFileExists(pPager->zJournal) || pPager->tempFile );*/
/*assert( !sqlite3OsFileExists(pPager->zJournal) || !pPager->tempFile );*/
if( !pPager->tempFile ){
rc = sqlite3OsDelete(pPager->zJournal); rc = sqlite3OsDelete(pPager->zJournal);
} }
} }
@@ -3188,20 +3177,6 @@ static int pager_open_journal(Pager *pPager){
failed_to_open_journal: failed_to_open_journal:
sqliteFree(pPager->aInJournal); sqliteFree(pPager->aInJournal);
pPager->aInJournal = 0; pPager->aInJournal = 0;
#if 0
if( rc==SQLITE_NOMEM ){
/* If this was a malloc() failure, then we will not be closing the pager
** file. So delete any journal file we may have just created. Otherwise,
** the system will get confused, we have a read-lock on the file and a
** mysterious journal has appeared in the filesystem.
*/
/* sqlite3OsDelete(pPager->zJournal); */
}else{
/* If we reset the pager here, we will delete pages out from under
** various cursors and will ultimately segfault. */
/* pager_reset(pPager); */
}
#endif
return rc; return rc;
} }