[TD-4394]fix core when select data after modify tag width

This commit is contained in:
lichuang 2021-06-15 16:29:43 +08:00
parent c8a42e1182
commit 800a112f2a
3 changed files with 14 additions and 6 deletions

View File

@ -117,7 +117,7 @@ typedef struct {
void tsdbClearTableCfg(STableCfg *config);
void *tsdbGetTableTagVal(const void *pTable, int32_t colId, int16_t type, int16_t bytes);
void *tsdbGetTableTagVal(const void *pTable, int32_t colId, int16_t type, int16_t* bytes);
char *tsdbGetTableName(void *pTable);
#define TSDB_TABLEID(_table) ((STableId*) (_table))

View File

@ -2819,7 +2819,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag,
val = tsdbGetTableName(pTable);
assert(val != NULL);
} else {
val = tsdbGetTableTagVal(pTable, tagColId, type, bytes);
val = tsdbGetTableTagVal(pTable, tagColId, type, &bytes);
}
if (val == NULL || isNull(val, type)) {
@ -6011,7 +6011,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
if (pExprInfo->base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
data = tsdbGetTableName(item->pTable);
} else {
data = tsdbGetTableTagVal(item->pTable, pExprInfo->base.colInfo.colId, type, bytes);
data = tsdbGetTableTagVal(item->pTable, pExprInfo->base.colInfo.colId, type, &bytes);
}
doSetTagValueToResultBuf(output, data, type, bytes);
@ -6050,7 +6050,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
data = tsdbGetTableName(item->pTable);
} else {
data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type, bytes);
data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type, &bytes);
}
dst = pColInfo->pData + count * pExprInfo[j].base.resBytes;

View File

@ -201,7 +201,7 @@ _err:
return -1;
}
void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_t bytes) {
void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_t* bytes) {
// TODO: this function should be changed also
STSchema *pSchema = tsdbGetTableTagSchema((STable*) pTable);
@ -211,8 +211,16 @@ void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_
}
char *val = tdGetKVRowValOfCol(((STable*)pTable)->tagVal, colId);
assert(type == pCol->type && bytes == pCol->bytes);
assert(type == pCol->type &&
// if var data type,bytes may >= col bytes,in case of tag width has beed modified
((IS_VAR_DATA_TYPE(type) && *bytes >= pCol->bytes) ||
// otherwise, bytes must be equal to colomn bytes
(!IS_VAR_DATA_TYPE(type) && *bytes == pCol->bytes)));
// in case tag width has been modified bigger but vnode has not been notified
if (val != NULL && IS_VAR_DATA_TYPE(type) && *bytes > pCol->bytes) {
*bytes = pCol->bytes;
}
// if (val != NULL && IS_VAR_DATA_TYPE(type)) {
// assert(varDataLen(val) < pCol->bytes);
// }