This commit is contained in:
Hongze Cheng 2022-02-28 10:22:15 +00:00
parent 1d622b5a97
commit 8284bf65d5
2 changed files with 23 additions and 3 deletions

View File

@ -28,6 +28,7 @@ struct SPFile {
int nDirty;
SPage * pDirty;
SPage * pDirtyTail;
u8 inTran;
};
static int tdbPFileReadPage(SPFile *pFile, SPage *pPage);
@ -119,8 +120,23 @@ SPage *tdbPFileGet(SPFile *pFile, SPgno pgno) {
}
int tdbPFileWrite(SPFile *pFile, SPage *pPage) {
// TODO: if the page is not in journal, write to journal
// mark the page as dirty
int ret;
if (pFile->inTran == 0) {
ret = tdbPFileBegin(pFile);
if (ret < 0) {
return -1;
}
pFile->inTran;
}
if (pPage->isDirty == 0) {
pPage->isDirty = 1;
// TODO: add the page to the dirty list
// TODO: write the page to the journal
}
return 0;
}
@ -143,7 +159,10 @@ int tdbPFileAllocPage(SPFile *pFile, SPage **ppPage, SPgno *ppgno) {
}
int tdbPFileBegin(SPFile *pFile) {
// TODO
if (pFile->inTran) {
return 0;
}
/* TODO */
return 0;
}

View File

@ -30,6 +30,7 @@ struct SPage {
u8 isAnchor;
u8 isLocalPage;
u8 isLoad;
u8 isDirty;
i32 nRef;
SPCache *pCache;
SPage * pFreeNext;