This commit is contained in:
Hongze Cheng 2022-03-28 09:14:50 +00:00
parent 387936e437
commit 71e04b29ec
1 changed files with 4 additions and 1 deletions

View File

@ -84,6 +84,8 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, S
SBTree *pBt; SBTree *pBt;
int ret; int ret;
ASSERT(keyLen != 0);
*ppBt = NULL; *ppBt = NULL;
pBt = (SBTree *)tdbOsCalloc(1, sizeof(*pBt)); pBt = (SBTree *)tdbOsCalloc(1, sizeof(*pBt));
@ -921,7 +923,7 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
} }
// 2. Encode payload part // 2. Encode payload part
if (leaf) { if (leaf && vLen > 0) {
ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, pVal, vLen, &nPayload); ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, pVal, vLen, &nPayload);
} else { } else {
ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, NULL, 0, &nPayload); ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, NULL, 0, &nPayload);
@ -960,6 +962,7 @@ static int tdbBtreeDecodePayload(SPage *pPage, const u8 *pPayload, SCellDecoder
return 0; return 0;
} }
// TODO: here has problem
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder) { static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder) {
u8 flags; u8 flags;
u8 leaf; u8 leaf;