more
This commit is contained in:
parent
1d622b5a97
commit
8284bf65d5
|
@ -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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue