summaryrefslogtreecommitdiff
path: root/dist/sqlite3.c
diff options
context:
space:
mode:
authorYongil Jang <yi.jang@lge.com>2012-12-27 11:12:43 +0900
committergit-lg-database.lge.com <lg-database@lge.com>2012-12-27 11:36:16 +0900
commit6ab557bdc070f11db30ede0696888efd19800475 (patch)
tree88d0fa0d8e4ce5f77b2ad72670aa53d32d43beac /dist/sqlite3.c
parent1eb051da2d460037a748d574b128cdd33b6d8b28 (diff)
Fix bugs of database corruption following IO error on systems supporting atomic-write
SQLite on Android uses AUTO_VACUUM option. When the disk space is critically low and atomic-write option is enabled, SQLite writes transactions that modify a single database page on disk without creating a journal file. Due to a bug, if an IO or disk full error occurs while transferring the contents to disk, the single page that was modified in the cache is not being rolled back - cache corruption. As a result, applications get a database corruption exception for next database transactions. This patch changes createFile() to close pReal in case of IO error. Therefore, cache is being rolled back. This patch is originated from www.sqlite.org. (URL: http://www.sqlite.org/src/tktview?name=df678d738a) Change-Id: Ieecda65d8458cb591bd4d89d8b423a4479f50ea8
Diffstat (limited to 'dist/sqlite3.c')
-rw-r--r--dist/sqlite3.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/dist/sqlite3.c b/dist/sqlite3.c
index 9d01a51..11e6528 100644
--- a/dist/sqlite3.c
+++ b/dist/sqlite3.c
@@ -72614,6 +72614,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;