diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 59676fc7cb2df19c67b7a585adee9c486bbf702c..496af6d88151d3244580f7383b27076b72e4a7ee 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -679,15 +679,16 @@ int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq); typedef struct { - int8_t alterType; - int8_t superUser; - int8_t sysInfo; - int8_t enable; - char user[TSDB_USER_LEN]; - char pass[TSDB_USET_PASSWORD_LEN]; - char objname[TSDB_DB_FNAME_LEN]; // db or topic - char tabName[TSDB_TABLE_NAME_LEN]; - char* tagCond; + int8_t alterType; + int8_t superUser; + int8_t sysInfo; + int8_t enable; + char user[TSDB_USER_LEN]; + char pass[TSDB_USET_PASSWORD_LEN]; + char objname[TSDB_DB_FNAME_LEN]; // db or topic + char tabName[TSDB_TABLE_NAME_LEN]; + char* tagCond; + int32_t tagCondLen; } SAlterUserReq; int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f6c2aaa5a40b686ad0d0a62c7713c4bdc436c0de..a2c3919b1c1a9fc62c8c2a7c73b617f0e619af96 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1373,11 +1373,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) if (len > 0) { if (tEncodeCStr(&encoder, pReq->tabName) < 0) return -1; } - len = (NULL == pReq->tagCond ? 0 : strlen(pReq->tagCond)); - if (tEncodeI32(&encoder, len) < 0) return -1; - if (len > 0) { - if (tEncodeCStr(&encoder, pReq->tagCond) < 0) return -1; - } + if (tEncodeBinary(&encoder, pReq->tagCond, pReq->tagCondLen) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1403,10 +1399,9 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq if (len > 0) { if (tDecodeCStrTo(&decoder, pReq->tabName) < 0) return -1; } - if (tDecodeI32(&decoder, &len) < 0) return -1; - if (len > 0) { - if (tDecodeCStrAlloc(&decoder, &pReq->tagCond) < 0) return -1; - } + uint64_t tagCondLen = 0; + if (tDecodeBinaryAlloc(&decoder, (void **)&pReq->tagCond, &tagCondLen) < 0) return -1; + pReq->tagCondLen = tagCondLen; } tEndDecode(&decoder); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 1c88899dcf0b300255985e233f58a8ea97d6aa25..06bd666609268686859968b60b5d09c136f91701 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6467,7 +6467,7 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) { sprintf(req.tabName, "%s", pStmt->tabName); int32_t code = TSDB_CODE_SUCCESS; if (NULL != pStmt->pTagCond) { - code = nodesNodeToString(pStmt->pTagCond, false, &req.tagCond, NULL); + code = nodesNodeToString(pStmt->pTagCond, false, &req.tagCond, &req.tagCondLen); } if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);