提交 a015dd52 编写于 作者: H Hongze Cheng

more

上级 3c4237af
...@@ -120,7 +120,10 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN ...@@ -120,7 +120,10 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN
} }
if (pPage || !alcNewPage) { if (pPage || !alcNewPage) {
if (pPage) tdbPCachePinPage(pPage); if (pPage) {
ASSERT(pPage->isLoad == 1);
tdbPCachePinPage(pPage);
}
return pPage; return pPage;
} }
...@@ -147,7 +150,7 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN ...@@ -147,7 +150,7 @@ static SPgHdr *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcN
if (pPage) { if (pPage) {
memcpy(&(pPage->pgid), pPgid, sizeof(*pPgid)); memcpy(&(pPage->pgid), pPgid, sizeof(*pPgid));
pPage->pLruNext = NULL; pPage->pLruNext = NULL;
// *(void **)pPage->page.pExtra = 0; (TODO) pPage->isLoad = 0;
tdbPCacheAddPageToHash(pPage); tdbPCacheAddPageToHash(pPage);
} }
......
...@@ -84,12 +84,14 @@ SPgHdr *tdbPFileGet(SPFile *pFile, SPgno pgno) { ...@@ -84,12 +84,14 @@ SPgHdr *tdbPFileGet(SPFile *pFile, SPgno pgno) {
} }
tdbPCacheFetchFinish(pFile->pCache, pPage); tdbPCacheFetchFinish(pFile->pCache, pPage);
if (pgno > pFile->dbFileSize /*TODO*/) { if (!(pPage->isLoad)) {
memset(pPage->pData, 0, pFile->pageSize); if (pgno > pFile->dbFileSize /*TODO*/) {
} else { memset(pPage->pData, 0, pFile->pageSize);
if (tdbPFileReadPage(pFile, pPage) < 0) { } else {
// TODO: handle error if (tdbPFileReadPage(pFile, pPage) < 0) {
return NULL; // TODO: handle error
return NULL;
}
} }
} }
......
...@@ -29,6 +29,7 @@ struct SPgHdr { ...@@ -29,6 +29,7 @@ struct SPgHdr {
SPgid pgid; SPgid pgid;
u8 isAnchor; u8 isAnchor;
u8 isLocalPage; u8 isLocalPage;
u8 isLoad;
i32 nRef; i32 nRef;
SPCache *pCache; SPCache *pCache;
SPgHdr * pFreeNext; SPgHdr * pFreeNext;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册