fix: memory leak when alter json tag to NULL
This commit is contained in:
parent
a5f06114fd
commit
d02a125f34
|
@ -2820,6 +2820,7 @@ typedef struct {
|
|||
char* tagName;
|
||||
int8_t isNull;
|
||||
int8_t tagType;
|
||||
int8_t nullToken;
|
||||
uint32_t nTagVal;
|
||||
uint8_t* pTagVal;
|
||||
SArray* pTagArray;
|
||||
|
|
|
@ -922,7 +922,8 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
|
||||
if (!(pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal))) ||
|
||||
!(pTagName = taosArrayInit(pCxt->tags.numOfBound, TSDB_COL_NAME_LEN))) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int i = 0; TSDB_CODE_SUCCESS == code && i < pCxt->tags.numOfBound; ++i) {
|
||||
|
@ -967,6 +968,7 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
pTag = NULL;
|
||||
}
|
||||
|
||||
_exit:
|
||||
for (int32_t i = 0; i < TARRAY_SIZE(pTagVals); ++i) {
|
||||
STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagVals, i);
|
||||
if (IS_VAR_DATA_TYPE(p->type)) {
|
||||
|
|
|
@ -10442,6 +10442,9 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = parseTagValue(&pCxt->msgBuf, &tagStr, pTableMeta->tableInfo.precision, pSchema, &token, NULL,
|
||||
pReq->pTagArray, &pTag);
|
||||
if (pSchema->type == TSDB_DATA_TYPE_JSON && token.type == TK_NULL && code == TSDB_CODE_SUCCESS) {
|
||||
pReq->nullToken = true;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && tagStr) {
|
||||
NEXT_VALID_TOKEN(tagStr, token);
|
||||
|
@ -10703,6 +10706,7 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) {
|
|||
}
|
||||
}
|
||||
taosArrayDestroy(pReq->pTagArray);
|
||||
if(pReq->nullToken) tTagFree((STag*)pReq->pTagVal);
|
||||
}
|
||||
|
||||
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||
|
|
|
@ -395,7 +395,6 @@ sql alter table $tb set tag tgcol6='1'
|
|||
sql reset query cache
|
||||
|
||||
sql select * from $mt where tgcol5 = '5'
|
||||
print $mt
|
||||
print select * from $mt where tgcol5 = 5
|
||||
print $data01 $data02 $data03 $data04
|
||||
if $rows != 1 then
|
||||
|
|
Loading…
Reference in New Issue