aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2012-12-18 11:59:39 +0000
committerdan <dan@noemail.net>2012-12-18 11:59:39 +0000
commit985cd59c488254e8ec1bc83a7537d030922e2d88 (patch)
treee8d7f895fa9f8b73d6eae35f1bab723af652d30a /src
parent6d42097622974cf463e08e0ddab4cc50f5de2cb7 (diff)
downloadsqlite-985cd59c488254e8ec1bc83a7537d030922e2d88.tar.gz
sqlite-985cd59c488254e8ec1bc83a7537d030922e2d88.zip
On atomic-write capable systems, if copying the contents of an in-memory journal to disk fails, close the (on disk) journal file before returning the error to the caller. This causes the subsequent rollback operation to use the in-memory journal. Fix for [df678d738adb].
FossilOrigin-Name: 8183d8d7ae1ff4bad2fcc01adb923b966b347832
Diffstat (limited to 'src')
-rw-r--r--src/journal.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/journal.c b/src/journal.c
index 06605cc95..fed27be3e 100644
--- a/src/journal.c
+++ b/src/journal.c
@@ -59,6 +59,14 @@ static int createFile(JournalFile *p){
assert(p->iSize<=p->nBuf);
rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0);
}
+ if( rc!=SQLITE_OK ){
+ /* If an error occurred while writing to the file, close it before
+ ** returning. This way, SQLite uses the in-memory journal data to
+ ** roll back changes made to the internal page-cache before this
+ ** function was called. */
+ sqlite3OsClose(pReal);
+ p->pReal = 0;
+ }
}
}
return rc;