Merge pull request #19503 from taosdata/fix/TD-21888

fix(tdb/ofp): upgrade large key ofp case
This commit is contained in:
Shengliang Guan 2023-01-11 15:57:47 +08:00 committed by GitHub
commit 6fccf849a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -1063,11 +1063,11 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
} else {
int nLeftKey = kLen;
// pack partial key and nextPgno
memcpy(pCell + nHeader, pKey, nLocal - 4);
nLeft -= nLocal - 4;
nLeftKey -= nLocal - 4;
memcpy(pCell + nHeader, pKey, nLocal - nHeader - sizeof(pgno));
nLeft -= nLocal - nHeader - sizeof(pgno);
nLeftKey -= nLocal - nHeader - sizeof(pgno);
memcpy(pCell + nHeader + nLocal - 4, &pgno, sizeof(pgno));
memcpy(pCell + nLocal - sizeof(pgno), &pgno, sizeof(pgno));
int lastKeyPageSpace = 0;
// pack left key & val to ovpages
@ -1087,9 +1087,12 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
if (lastKeyPage) {
if (lastKeyPageSpace >= vLen) {
if (vLen > 0) {
memcpy(pBuf + kLen - nLeftKey, pVal, vLen);
nLeft -= vLen;
}
pgno = 0;
} else {
memcpy(pBuf + kLen - nLeftKey, pVal, lastKeyPageSpace);
@ -1111,7 +1114,7 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
}
}
memcpy(pBuf + kLen - nLeft, &pgno, sizeof(pgno));
memcpy(pBuf + bytes, &pgno, sizeof(pgno));
ret = tdbPageInsertCell(ofp, 0, pBuf, bytes + sizeof(pgno), 0);
if (ret < 0) {