From e43f419a6fdf9cc66270b28297a698cf2f4c6776 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 13 Aug 2020 22:40:49 +0300 Subject: [PATCH] Patch SQLite ftruncate call only on Android. GitOrigin-RevId: 930b58281ba5eab7d4f560e56b129d8b043fa455 --- sqlite/sqlite/sqlite3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlite/sqlite/sqlite3.c b/sqlite/sqlite/sqlite3.c index e558fd1c7..85c45ac0d 100644 --- a/sqlite/sqlite/sqlite3.c +++ b/sqlite/sqlite/sqlite3.c @@ -42840,8 +42840,12 @@ static int unixLockSharedMemory(unixFile *pDbFd, unixShmNode *pShmNode){ ** -shm header size) rather than 0 as a system debugging aid, to ** help detect if a -shm file truncation is legitimate or is the work ** or a rogue process. */ - /* Fix SQLite DB corruption on some Samsung devices (3 changed to 0) */ +#ifdef __ANDROID__ + /* Fix SQLite DB corruption on some Samsung devices */ if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 0) ){ +#else + if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 3) ){ +#endif rc = unixLogError(SQLITE_IOERR_SHMOPEN,"ftruncate",pShmNode->zFilename); } }