This commit is contained in:
Hongze Cheng 2022-02-16 06:30:17 +00:00
parent 6e995780b5
commit 4b5f00ca3b
2 changed files with 12 additions and 4 deletions

View File

@ -15,6 +15,15 @@
#include "tdbInt.h" #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); static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData);
int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) { int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) {
@ -116,7 +125,7 @@ int pgFileAllocatePage(SPgFile *pPgFile, pgno_t *pPgno) {
if (0) { if (0) {
// TODO: allocate from the free list // TODO: allocate from the free list
} else { } else {
pgno = ++pPgFile->dbNewSize; pgno = ++(pPgFile->lsize);
} }
*pPgno = pgno; *pPgno = pgno;

View File

@ -36,9 +36,9 @@ struct SPgFile {
TENV * pEnv; // env containing this page file TENV * pEnv; // env containing this page file
char * fname; // backend file name char * fname; // backend file name
uint8_t fileid[TDB_FILE_ID_LEN]; // file id 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; int fd;
pgno_t dbSize;
pgno_t dbNewSize;
SPgFileListNode envHash; SPgFileListNode envHash;
SPgFileListNode envPgfList; SPgFileListNode envPgfList;
}; };
@ -46,7 +46,6 @@ struct SPgFile {
int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv); int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv);
int pgFileClose(SPgFile *pPgFile); int pgFileClose(SPgFile *pPgFile);
SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno); SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno);
int pgFileRelease(SPage *pPage); int pgFileRelease(SPage *pPage);