Merge pull request #20814 from taosdata/fix/TS-3085

fix: fix nullbitmap shift error when trimming data blocks.
This commit is contained in:
dapan1121 2023-04-08 11:53:25 +08:00 committed by GitHub
commit a560d10761
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1590,12 +1590,13 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
i += 1; i += 1;
} }
} else if (n > 8) { } else if (n > 8) {
int32_t gap = len - newLen; int32_t remain = (total % 8 != 0 && total % 8 <= tail) ? 1 : 0;
int32_t gap = len - newLen - remain;
while (i < newLen) { while (i < newLen) {
uint8_t v = p[i + gap]; uint8_t v = p[i + gap];
p[i] = (v << tail); p[i] = (v << tail);
if (i < newLen - 1) { if (i < newLen - 1 + remain) {
uint8_t next = p[i + gap + 1]; uint8_t next = p[i + gap + 1];
p[i] |= (next >> (8 - tail)); p[i] |= (next >> (8 - tail));
} }