fix: (compatibility) SLastCol field change cause 'last' crash

This commit is contained in:
Shungang Li 2024-05-08 14:59:08 +08:00
parent b26656fd1c
commit 733c8f8f9a
2 changed files with 26 additions and 6 deletions

View File

@ -901,10 +901,27 @@ typedef struct {
SColVal colVal;
} SLastCol;
typedef struct {
union {
int64_t val;
struct {
uint8_t *pData;
uint32_t nData;
};
};
} SValueV1;
typedef struct {
TSKEY ts;
int8_t dirty;
SColVal colVal;
int16_t cid;
int8_t type;
int8_t flag;
SValueV1 value;
} SColValV1;
typedef struct {
TSKEY ts;
int8_t dirty;
SColValV1 colVal;
} SLastColV1;
int32_t tsdbOpenCache(STsdb *pTsdb);

View File

@ -343,7 +343,10 @@ static SLastCol *tsdbCacheConvertLastColV1(SLastColV1 *pLastColV1) {
pLastCol->rowKey.ts = pLastColV1->ts;
pLastCol->rowKey.numOfPKs = 0;
pLastCol->dirty = pLastColV1->dirty;
pLastCol->colVal = pLastColV1->colVal;
pLastCol->colVal.cid = pLastColV1->colVal.cid;
pLastCol->colVal.flag = pLastColV1->colVal.flag;
pLastCol->colVal.value.type = pLastColV1->colVal.type;
pLastCol->colVal.value.val = pLastColV1->colVal.value.val;
return pLastCol;
}
@ -354,8 +357,8 @@ static SLastCol *tsdbCacheDeserializeV1(char const *value) {
}
SLastColV1 *pLastColV1 = (SLastColV1 *)value;
SColVal *pColVal = &pLastColV1->colVal;
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
SColValV1 *pColVal = &pLastColV1->colVal;
if (IS_VAR_DATA_TYPE(pColVal->type)) {
if (pColVal->value.nData > 0) {
pColVal->value.pData = (char *)value + sizeof(*pLastColV1);
} else {