提交 8284bf65 编写于 作者: H Hongze Cheng

more

上级 1d622b5a
...@@ -28,6 +28,7 @@ struct SPFile { ...@@ -28,6 +28,7 @@ struct SPFile {
int nDirty; int nDirty;
SPage * pDirty; SPage * pDirty;
SPage * pDirtyTail; SPage * pDirtyTail;
u8 inTran;
}; };
static int tdbPFileReadPage(SPFile *pFile, SPage *pPage); static int tdbPFileReadPage(SPFile *pFile, SPage *pPage);
...@@ -119,8 +120,23 @@ SPage *tdbPFileGet(SPFile *pFile, SPgno pgno) { ...@@ -119,8 +120,23 @@ SPage *tdbPFileGet(SPFile *pFile, SPgno pgno) {
} }
int tdbPFileWrite(SPFile *pFile, SPage *pPage) { int tdbPFileWrite(SPFile *pFile, SPage *pPage) {
// TODO: if the page is not in journal, write to journal int ret;
// mark the page as dirty
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; return 0;
} }
...@@ -143,7 +159,10 @@ int tdbPFileAllocPage(SPFile *pFile, SPage **ppPage, SPgno *ppgno) { ...@@ -143,7 +159,10 @@ int tdbPFileAllocPage(SPFile *pFile, SPage **ppPage, SPgno *ppgno) {
} }
int tdbPFileBegin(SPFile *pFile) { int tdbPFileBegin(SPFile *pFile) {
// TODO if (pFile->inTran) {
return 0;
}
/* TODO */
return 0; return 0;
} }
......
...@@ -30,6 +30,7 @@ struct SPage { ...@@ -30,6 +30,7 @@ struct SPage {
u8 isAnchor; u8 isAnchor;
u8 isLocalPage; u8 isLocalPage;
u8 isLoad; u8 isLoad;
u8 isDirty;
i32 nRef; i32 nRef;
SPCache *pCache; SPCache *pCache;
SPage * pFreeNext; SPage * pFreeNext;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册