diff --git a/source/libs/tdb/src/db/tdbPgFile.c b/source/libs/tdb/src/db/tdbPgFile.c index c6b761181802dcbd24fe927c473fbe2c037164a1..d6223a578858e187cb4a0e7c3b35214cfde7c725 100644 --- a/source/libs/tdb/src/db/tdbPgFile.c +++ b/source/libs/tdb/src/db/tdbPgFile.c @@ -15,6 +15,15 @@ #include "tdbInt.h" +typedef struct SPage1 { + char magic[64]; + pgno_t mdbRootPgno; // master DB root page number + pgno_t freePgno; // free list page number + uint32_t nFree; // number of free pages +} SPage1; + +TDB_STATIC_ASSERT(sizeof(SPage1) <= TDB_MIN_PGSIZE, "TDB Page1 definition too large"); + static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData); int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) { @@ -116,7 +125,7 @@ int pgFileAllocatePage(SPgFile *pPgFile, pgno_t *pPgno) { if (0) { // TODO: allocate from the free list } else { - pgno = ++pPgFile->dbNewSize; + pgno = ++(pPgFile->lsize); } *pPgno = pgno; diff --git a/source/libs/tdb/src/inc/tdbPgFile.h b/source/libs/tdb/src/inc/tdbPgFile.h index d4c97e0e0d88d8c4d6d74accdb3fbda20d4e619c..2a7116a0dd232b1933c030e72a4e95166af063ef 100644 --- a/source/libs/tdb/src/inc/tdbPgFile.h +++ b/source/libs/tdb/src/inc/tdbPgFile.h @@ -36,9 +36,9 @@ struct SPgFile { TENV * pEnv; // env containing this page file char * fname; // backend file name uint8_t fileid[TDB_FILE_ID_LEN]; // file id + pgno_t lsize; // page file logical size (for count) + pgno_t fsize; // real file size on disk (for rollback) int fd; - pgno_t dbSize; - pgno_t dbNewSize; SPgFileListNode envHash; SPgFileListNode envPgfList; }; @@ -46,7 +46,6 @@ struct SPgFile { int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv); int pgFileClose(SPgFile *pPgFile); - SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno); int pgFileRelease(SPage *pPage);