From 019860111d12856047e84e51e973d3f2c492002d Mon Sep 17 00:00:00 2001 From: lichuang Date: Tue, 15 Jun 2021 20:32:59 +0800 Subject: [PATCH] [TD-4394]fix core when select data after modify tag width --- src/inc/tsdb.h | 2 +- src/mnode/src/mnodeTable.c | 2 ++ src/query/src/qExecutor.c | 6 +++--- src/tsdb/src/tsdbMeta.c | 14 +++----------- src/util/src/tskiplist.c | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 7575951246..79d9029dbc 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -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)) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a225c0d938..032c6ee94b 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1475,6 +1475,7 @@ static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg) { SSchema *schema = (SSchema *) (pStable->schema + col); ASSERT(schema->type == TSDB_DATA_TYPE_BINARY || schema->type == TSDB_DATA_TYPE_NCHAR); schema->bytes = pAlter->schema[0].bytes; + pStable->sversion++; mInfo("msg:%p, app:%p stable %s, start to modify column %s len to %d", pMsg, pMsg->rpcMsg.ahandle, pStable->info.tableId, name, schema->bytes); @@ -1504,6 +1505,7 @@ static int32_t mnodeChangeSuperTableTag(SMnodeMsg *pMsg) { SSchema *schema = (SSchema *) (pStable->schema + col + pStable->numOfColumns); ASSERT(schema->type == TSDB_DATA_TYPE_BINARY || schema->type == TSDB_DATA_TYPE_NCHAR); schema->bytes = pAlter->schema[0].bytes; + pStable->tversion++; mInfo("msg:%p, app:%p stable %s, start to modify tag len %s to %d", pMsg, pMsg->rpcMsg.ahandle, pStable->info.tableId, name, schema->bytes); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 4a5dc4f506..77ceabbd63 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -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; diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 52ba3dfb4e..86e3aea4b5 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -148,7 +148,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) { return 0; _err: - tsdbFreeTable(super); + //tsdbFreeTable(super); tsdbFreeTable(table); return -1; } @@ -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,16 +211,8 @@ void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_ } char *val = tdGetKVRowValOfCol(((STable*)pTable)->tagVal, colId); - 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))); + assert(type == pCol->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); // } diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 842ded19a6..0a394c15c9 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -85,7 +85,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _ } void tSkipListDestroy(SSkipList *pSkipList) { - if (pSkipList == NULL) return; + if (pSkipList == NULL || pSkipList->pHead == NULL) return; tSkipListWLock(pSkipList);