diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 69294a1c1f1ef6ef0f38ac5f7fc7e3d803347b64..b309fce1b54852509f2ccf63ef3e0b0f7a7a7a5d 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -294,10 +294,10 @@ static int tdbBtreeOpenImpl(SBTree *pBt) { } // Try to create a new database - ret = tdbPagerNewPage(pBt->pPager, &pgno, &pPage); - if (ret < 0) { - return -1; - } + // ret = tdbPagerNewPage(pBt->pPager, &pgno, &pPage); + // if (ret < 0) { + // return -1; + // } ASSERT(pgno != 0); pBt->root = pgno; diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 0a5a8abe82a4c2166e97031aae9a112d00468a0e..5046ba26024e0e199853abcda421126b87e9c4be 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -227,7 +227,7 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) { int tdbPagerGetPageSize(SPager *pPager) { return pPager->pageSize; } -int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage) { +int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg) { SPage *pPage; SPgid pgid; int ret; @@ -251,10 +251,10 @@ int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage) { return -1; } - // ret = (*initPage)(pPage); - // if (ret < 0) { - // return -1; - // } + ret = (*initPage)(pPage, arg); + if (ret < 0) { + return -1; + } pPage->pPager = pPager; } @@ -268,7 +268,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage) { return 0; } -int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage) { +int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg) { int ret; SPage *pPage; SPgid pgid; @@ -296,7 +296,7 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage) { // tdbWLockPage(pPage); // TODO: zero init the new page - // (*initNewPage)(pPage, arg); + (*initPage)(pPage, arg); pPage->pPager = NULL; diff --git a/source/libs/tdb/src/inc/tdbPager.h b/source/libs/tdb/src/inc/tdbPager.h index a32439f30f21ec977ad1d44ca8e481688b90e81e..1122ed8e4e02830826bc045c0ee30e2d662fa816 100644 --- a/source/libs/tdb/src/inc/tdbPager.h +++ b/source/libs/tdb/src/inc/tdbPager.h @@ -28,8 +28,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage); int tdbPagerBegin(SPager *pPager); int tdbPagerCommit(SPager *pPager); int tdbPagerGetPageSize(SPager *pPager); -int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage); -int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage); +int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg); +int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg); #ifdef __cplusplus }