diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index a62cfbdf59ecefe8a4b9d35601045d221d66301e..84010b28ccd1825aacf640abfbc9fedc76b39495 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -120,7 +120,10 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN } if (pPage || !alcNewPage) { - if (pPage) tdbPCachePinPage(pPage); + if (pPage) { + ASSERT(pPage->isLoad == 1); + tdbPCachePinPage(pPage); + } return pPage; } @@ -147,7 +150,7 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN if (pPage) { memcpy(&(pPage->pgid), pPgid, sizeof(*pPgid)); pPage->pLruNext = NULL; - // *(void **)pPage->page.pExtra = 0; (TODO) + pPage->isLoad = 0; tdbPCacheAddPageToHash(pPage); } diff --git a/source/libs/tdb/src/db/tdbPFile.c b/source/libs/tdb/src/db/tdbPFile.c index db64ea2fe0be29795ced9f31d91e64aa35642cf9..e9d037ec02d1a496426b3350e006fb982a0a161a 100644 --- a/source/libs/tdb/src/db/tdbPFile.c +++ b/source/libs/tdb/src/db/tdbPFile.c @@ -84,12 +84,14 @@ SPgHdr *tdbPFileGet(SPFile *pFile, SPgno pgno) { } tdbPCacheFetchFinish(pFile->pCache, pPage); - if (pgno > pFile->dbFileSize /*TODO*/) { - memset(pPage->pData, 0, pFile->pageSize); - } else { - if (tdbPFileReadPage(pFile, pPage) < 0) { - // TODO: handle error - return NULL; + if (!(pPage->isLoad)) { + if (pgno > pFile->dbFileSize /*TODO*/) { + memset(pPage->pData, 0, pFile->pageSize); + } else { + if (tdbPFileReadPage(pFile, pPage) < 0) { + // TODO: handle error + return NULL; + } } } diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index db936dad8cff8b800ab131631af23f0f56808003..dcc4ecfd3ad725fca906eb5307b9d45c0da3e173 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -29,6 +29,7 @@ struct SPgHdr { SPgid pgid; u8 isAnchor; u8 isLocalPage; + u8 isLoad; i32 nRef; SPCache *pCache; SPgHdr * pFreeNext;