diff --git a/patch/0012-Bugfix-on-current-version.patch b/patch/0012-Bugfix-on-current-version.patch index 74fe3d62a81ab703d644346ea3ff55a9b2b6e5ab..f889edce179e59943d46623f0eb4ff3e006961b0 100644 --- a/patch/0012-Bugfix-on-current-version.patch +++ b/patch/0012-Bugfix-on-current-version.patch @@ -1,12 +1,12 @@ -From d57fc37e8a853b509ebfe493c5cb63fbc9938367 Mon Sep 17 00:00:00 2001 +From 38bf4462af6ab92813d377c1031b7bb485e0b240 Mon Sep 17 00:00:00 2001 From: MartinChoo <214582617@qq.com> -Date: Wed, 30 Jul 2025 19:15:32 +0800 +Date: Fri, 1 Aug 2025 16:35:50 +0800 Subject: [PATCH] Bugfix on current version --- ext/misc/cksumvfs.c | 13 +- - src/sqlite3.c | 289 ++++++++++++++++++++++++++++++++++++-------- - 2 files changed, 242 insertions(+), 60 deletions(-) + src/sqlite3.c | 290 ++++++++++++++++++++++++++++++++++++-------- + 2 files changed, 243 insertions(+), 60 deletions(-) diff --git a/ext/misc/cksumvfs.c b/ext/misc/cksumvfs.c index c6ac60f..8705751 100644 @@ -61,7 +61,7 @@ index c6ac60f..8705751 100644 rc = sqlite3_auto_extension((void(*)(void))cksmRegisterFunc); } diff --git a/src/sqlite3.c b/src/sqlite3.c -index 2953517..d3540ff 100644 +index 2953517..ea15c53 100644 --- a/src/sqlite3.c +++ b/src/sqlite3.c @@ -15050,6 +15050,14 @@ typedef INT16_TYPE LogEst; @@ -389,7 +389,7 @@ index 2953517..d3540ff 100644 u32 checkSum; u8 *zones; Pgno *pages; -@@ -256991,6 +257088,87 @@ static inline u64 CaculateMetaDwrWriteOffset(int pageSz, u32 idx, u8 zone) { +@@ -256991,6 +257088,88 @@ static inline u64 CaculateMetaDwrWriteOffset(int pageSz, u32 idx, u8 zone) { return META_DWR_HEADER_PAGE_SIZE + pageSz * (idx * 2 + zone); } @@ -415,7 +415,7 @@ index 2953517..d3540ff 100644 + if (hdr == NULL || !hdr->checkFileId) { + return; + } -+ unixFile *fd = (unixFile *)pPager->fd; ++ unixFile *fd = Sqlite3GetUnixFile(pPager->fd, hdr->checkFileId); + if (fd == NULL || fd->pInode == NULL) { + sqlite3_log(SQLITE_WARNING_DUMP, "MetaDwr dump invalid db fd"); + return; @@ -459,6 +459,7 @@ index 2953517..d3540ff 100644 + if (!hdr->checkFileId) { + return; + } ++ unixFile *fd = Sqlite3GetUnixFile(pPager->fd, hdr->checkFileId); + if (fd == NULL || fd->pShm == NULL || fd->pShm->pShmNode == NULL || fd->pShm->pShmNode->hShm < 0) { + sqlite3_log(SQLITE_WARNING_DUMP, "update meta header invalid shm fd"); + return; @@ -477,7 +478,7 @@ index 2953517..d3540ff 100644 static void MetaDwrUpdateHeaderDbInfo(BtShared *pBt) { MetaDwrHdr *hdr = pBt->pPager->metaHdr; // 28 offset: dbSize, freelist pageNo, freelist pages count, schema cookie -@@ -257211,11 +257389,12 @@ static int MetaDwrOpenFile(Pager *pPager, u8 openCreate) { +@@ -257211,11 +257390,12 @@ static int MetaDwrOpenFile(Pager *pPager, u8 openCreate) { if (pPager->metaMapPage == NULL) { sqlite3_int64 sz = META_DWR_HEADER_PAGE_SIZE; sqlite3OsFileControlHint(metaFd, SQLITE_FCNTL_CHUNK_SIZE, &sz); @@ -495,7 +496,7 @@ index 2953517..d3540ff 100644 } } #endif /* SQLITE_OS_UNIX */ -@@ -257589,7 +257768,7 @@ CHK_RESTORE_OUT: +@@ -257589,7 +257769,7 @@ CHK_RESTORE_OUT: return rc; } @@ -504,7 +505,7 @@ index 2953517..d3540ff 100644 { #if SQLITE_OS_UNIX u8 checkFileId = Sqlite3GetCheckFileId(pPager->pVfs); -@@ -257597,10 +257776,18 @@ static inline u8 IsConnectionValidForCheck(Pager *pPager) +@@ -257597,10 +257777,18 @@ static inline u8 IsConnectionValidForCheck(Pager *pPager) return 0; } unixFile *fd = Sqlite3GetUnixFile(pPager->fd, checkFileId); @@ -524,7 +525,7 @@ index 2953517..d3540ff 100644 return 1; #else return 0; -@@ -257610,7 +257797,7 @@ static inline u8 IsConnectionValidForCheck(Pager *pPager) +@@ -257610,7 +257798,7 @@ static inline u8 IsConnectionValidForCheck(Pager *pPager) static int MetaDwrOpenAndCheck(Btree *pBt) { Pager *pPager = pBt->pBt->pPager; @@ -533,7 +534,7 @@ index 2953517..d3540ff 100644 return SQLITE_OK; } #ifdef SQLITE_HAS_CODEC -@@ -257655,7 +257842,7 @@ DWR_OPEN_OUT: +@@ -257655,7 +257843,7 @@ DWR_OPEN_OUT: static void MetaDwrDisable(Btree *pBt) { Pager *pPager = pBt->pBt->pPager; @@ -542,7 +543,7 @@ index 2953517..d3540ff 100644 return; } #ifdef SQLITE_HAS_CODEC -@@ -257681,19 +257868,6 @@ static void MetaDwrDisable(Btree *pBt) +@@ -257681,19 +257869,6 @@ static void MetaDwrDisable(Btree *pBt) #endif /* SQLITE_META_DWR */ #if SQLITE_OS_UNIX @@ -562,7 +563,7 @@ index 2953517..d3540ff 100644 static void ResetLockStatus(void) { (void)memset(&g_lockStatus, 0, sizeof(g_lockStatus)); -@@ -257797,8 +257971,13 @@ static inline const char *FlockToName(int l_type) +@@ -257797,8 +257972,13 @@ static inline const char *FlockToName(int l_type) static int DumpProcessLocks(int fd, struct flock *lock, const char *lockName, char *dumpBuf, int bufLen) { @@ -577,7 +578,7 @@ index 2953517..d3540ff 100644 sqlite3_log(SQLITE_ERROR, "[SQLite]Get wal file lock ofs %u failed, errno: %d", lock->l_start, errno); return 0; } -@@ -259041,7 +259220,11 @@ struct sqlite3_api_routines_hw { +@@ -259041,7 +259221,11 @@ struct sqlite3_api_routines_hw { int (*rekey_v2)(sqlite3*,const char*,const void*,int); int (*is_support_binlog)(void); int (*replay_binlog)(sqlite3*, sqlite3*);