From d89f396dc7b07d3c3a6f8deabf63f34953b607ef Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 15 Feb 2022 18:17:18 +0800 Subject: [PATCH] serialize stb msg --- include/common/tmsg.h | 13 +- source/common/src/tmsg.c | 153 ++++++++++++++-------- source/dnode/mnode/impl/src/mndConsumer.c | 14 +- source/dnode/mnode/impl/src/mndStb.c | 9 +- source/dnode/mnode/impl/test/stb/stb.cpp | 47 +++---- source/libs/parser/src/astToMsg.c | 10 +- 6 files changed, 140 insertions(+), 106 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 80a81ff143..be37fb9e9c 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -272,8 +272,8 @@ typedef struct { char comment[TSDB_STB_COMMENT_LEN]; } SMCreateStbReq; -int32_t tSerializeSMCreateStbReq(void** buf, SMCreateStbReq* pReq); -void* tDeserializeSMCreateStbReq(void* buf, SMCreateStbReq* pReq); +int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); +int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); void tFreeSMCreateStbReq(SMCreateStbReq* pReq); typedef struct { @@ -281,8 +281,8 @@ typedef struct { int8_t igNotExists; } SMDropStbReq; -int32_t tSerializeSMDropStbReq(void** buf, SMDropStbReq* pReq); -void* tDeserializeSMDropStbReq(void* buf, SMDropStbReq* pReq); +int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq); +int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq); typedef struct { char name[TSDB_TABLE_FNAME_LEN]; @@ -291,8 +291,9 @@ typedef struct { SArray* pFields; } SMAltertbReq; -int32_t tSerializeSMAlterStbReq(void** buf, SMAltertbReq* pReq); -void* tDeserializeSMAlterStbReq(void* buf, SMAltertbReq* pReq); +int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAltertbReq* pReq); +int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAltertbReq* pReq); +void tFreeSMAltertbReq(SMAltertbReq* pReq); typedef struct { int32_t pid; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index acbefc6bea..411acbfcfd 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -375,132 +375,171 @@ void *tDeserializeSVDropTbReq(void *buf, SVDropTbReq *pReq) { return buf; } -int32_t tSerializeSMCreateStbReq(void **buf, SMCreateStbReq *pReq) { - int32_t tlen = 0; +int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); - tlen += taosEncodeString(buf, pReq->name); - tlen += taosEncodeFixedI8(buf, pReq->igExists); - tlen += taosEncodeFixedI32(buf, pReq->numOfColumns); - tlen += taosEncodeFixedI32(buf, pReq->numOfTags); + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1; for (int32_t i = 0; i < pReq->numOfColumns; ++i) { SField *pField = taosArrayGet(pReq->pColumns, i); - tlen += taosEncodeFixedI8(buf, pField->type); - tlen += taosEncodeFixedI32(buf, pField->bytes); - tlen += taosEncodeString(buf, pField->name); + if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; + if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField *pField = taosArrayGet(pReq->pTags, i); - tlen += taosEncodeFixedI8(buf, pField->type); - tlen += taosEncodeFixedI32(buf, pField->bytes); - tlen += taosEncodeString(buf, pField->name); + if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; + if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } - tlen += taosEncodeString(buf, pReq->comment); + if (tEncodeCStr(&encoder, pReq->comment) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); return tlen; } -void *tDeserializeSMCreateStbReq(void *buf, SMCreateStbReq *pReq) { - buf = taosDecodeStringTo(buf, pReq->name); - buf = taosDecodeFixedI8(buf, &pReq->igExists); - buf = taosDecodeFixedI32(buf, &pReq->numOfColumns); - buf = taosDecodeFixedI32(buf, &pReq->numOfTags); +int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1; pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField)); pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField)); if (pReq->pColumns == NULL || pReq->pTags == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return -1; } for (int32_t i = 0; i < pReq->numOfColumns; ++i) { SField field = {0}; - buf = taosDecodeFixedI8(buf, &field.type); - buf = taosDecodeFixedI32(buf, &field.bytes); - buf = taosDecodeStringTo(buf, field.name); + if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; + if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; if (taosArrayPush(pReq->pColumns, &field) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return -1; } } for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField field = {0}; - buf = taosDecodeFixedI8(buf, &field.type); - buf = taosDecodeFixedI32(buf, &field.bytes); - buf = taosDecodeStringTo(buf, field.name); + if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; + if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; if (taosArrayPush(pReq->pTags, &field) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return -1; } } - buf = taosDecodeStringTo(buf, pReq->comment); - return buf; + if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; } void tFreeSMCreateStbReq(SMCreateStbReq *pReq) { taosArrayDestroy(pReq->pColumns); taosArrayDestroy(pReq->pTags); + pReq->pColumns = NULL; + pReq->pTags = NULL; } -int32_t tSerializeSMDropStbReq(void **buf, SMDropStbReq *pReq) { - int32_t tlen = 0; +int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); - tlen += taosEncodeString(buf, pReq->name); - tlen += taosEncodeFixedI8(buf, pReq->igNotExists); + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; + tEndEncode(&encoder); + int32_t tlen = encoder.pos; + tCoderClear(&encoder); return tlen; } -void *tDeserializeSMDropStbReq(void *buf, SMDropStbReq *pReq) { - buf = taosDecodeStringTo(buf, pReq->name); - buf = taosDecodeFixedI8(buf, &pReq->igNotExists); +int32_t tDeserializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); - return buf; -} + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; + tEndDecode(&decoder); -int32_t tSerializeSMAlterStbReq(void **buf, SMAltertbReq *pReq) { - int32_t tlen = 0; + tCoderClear(&decoder); + return 0; +} - tlen += taosEncodeString(buf, pReq->name); - tlen += taosEncodeFixedI8(buf, pReq->alterType); - tlen += taosEncodeFixedI32(buf, pReq->numOfFields); +int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAltertbReq *pReq) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfFields) < 0) return -1; for (int32_t i = 0; i < pReq->numOfFields; ++i) { SField *pField = taosArrayGet(pReq->pFields, i); - tlen += taosEncodeFixedU8(buf, pField->type); - tlen += taosEncodeFixedI32(buf, pField->bytes); - tlen += taosEncodeString(buf, pField->name); + if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; + if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } + tEndEncode(&encoder); + int32_t tlen = encoder.pos; + tCoderClear(&encoder); return tlen; } -void *tDeserializeSMAlterStbReq(void *buf, SMAltertbReq *pReq) { - buf = taosDecodeStringTo(buf, pReq->name); - buf = taosDecodeFixedI8(buf, &pReq->alterType); - buf = taosDecodeFixedI32(buf, &pReq->numOfFields); +int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAltertbReq *pReq) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numOfFields) < 0) return -1; pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField)); if (pReq->pFields == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return -1; } - for (int32_t i = 0; i < pReq->numOfFields; ++i) { SField field = {0}; - buf = taosDecodeFixedU8(buf, &field.type); - buf = taosDecodeFixedI32(buf, &field.bytes); - buf = taosDecodeStringTo(buf, field.name); + if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; + if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; if (taosArrayPush(pReq->pFields, &field) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return -1; } } - return buf; + tEndDecode(&decoder); + tCoderClear(&decoder); + return 0; +} + +void tFreeSMAltertbReq(SMAltertbReq *pReq) { + taosArrayDestroy(pReq->pFields); + pReq->pFields = NULL; } int32_t tSerializeSStatusReq(void **buf, SStatusReq *pReq) { diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 21ebea258d..0f4b538cde 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -14,8 +14,8 @@ */ #define _DEFAULT_SOURCE - #include "mndConsumer.h" +#include "mndAuth.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" @@ -53,13 +53,14 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} -SMqConsumerObj* mndCreateConsumer(int64_t consumerId, const char* cgroup) { - SMqConsumerObj* pConsumer = malloc(sizeof(SMqConsumerObj)); +SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup) { + SMqConsumerObj *pConsumer = calloc(1, sizeof(SMqConsumerObj)); if (pConsumer == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pConsumer->recentRemovedTopics = taosArrayInit(0, sizeof(char*)); + + pConsumer->recentRemovedTopics = taosArrayInit(1, sizeof(char *)); pConsumer->epoch = 1; pConsumer->consumerId = consumerId; atomic_store_32(&pConsumer->status, MQ_CONSUMER_STATUS__INIT); @@ -70,7 +71,8 @@ SMqConsumerObj* mndCreateConsumer(int64_t consumerId, const char* cgroup) { SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { terrno = TSDB_CODE_OUT_OF_MEMORY; - void* buf = NULL; + + void *buf = NULL; int32_t tlen = tEncodeSMqConsumerObj(NULL, pConsumer); int32_t size = sizeof(int32_t) + tlen + MND_CONSUMER_RESERVE_SIZE; @@ -105,7 +107,7 @@ CM_ENCODE_OVER: SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; - void* buf = NULL; + void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto CM_DECODE_OVER; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 31e2d35c01..1fc1b25776 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -552,7 +552,10 @@ static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq) { SUserObj *pUser = NULL; SMCreateStbReq createReq = {0}; - if (tDeserializeSMCreateStbReq(pReq->rpcMsg.pCont, &createReq) == NULL) goto CREATE_STB_OVER; + if (tDeserializeSMCreateStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto CREATE_STB_OVER; + } mDebug("stb:%s, start to create", createReq.name); if (mndCheckCreateStbReq(&createReq) != 0) { @@ -1036,7 +1039,7 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) { SUserObj *pUser = NULL; SMAltertbReq alterReq = {0}; - if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, &alterReq) == NULL) { + if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto ALTER_STB_OVER; } @@ -1169,7 +1172,7 @@ static int32_t mndProcessMDropStbReq(SMnodeMsg *pReq) { SStbObj *pStb = NULL; SMDropStbReq dropReq = {0}; - if (tDeserializeSMDropStbReq(pReq->rpcMsg.pCont, &dropReq) != 0) { + if (tDeserializeSMDropStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto DROP_STB_OVER; } diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index 573c1f4846..c551097e72 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -129,11 +129,10 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) { taosArrayPush(createReq.pTags, &field); } - int32_t tlen = tSerializeSMCreateStbReq(NULL, &createReq); + int32_t tlen = tSerializeSMCreateStbReq(NULL, 0, &createReq); void* pHead = rpcMallocCont(tlen); - - void* pBuf = pHead; - tSerializeSMCreateStbReq(&pBuf, &createReq); + tSerializeSMCreateStbReq(pHead, tlen, &createReq); + tFreeSMCreateStbReq(&createReq); *pContLen = tlen; return pHead; } @@ -151,10 +150,9 @@ void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagnam strcpy(field.name, tagname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -173,10 +171,9 @@ void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagna strcpy(field.name, tagname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -202,10 +199,9 @@ void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* strcpy(field2.name, newtagname); taosArrayPush(req.pFields, &field2); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -225,10 +221,9 @@ void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char strcpy(field.name, tagname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -247,10 +242,9 @@ void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* col strcpy(field.name, colname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -269,10 +263,9 @@ void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* co strcpy(field.name, colname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -292,10 +285,9 @@ void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const c strcpy(field.name, colname); taosArrayPush(req.pFields, &field); - int32_t contLen = tSerializeSMAlterStbReq(NULL, &req); + int32_t contLen = tSerializeSMAlterStbReq(NULL, 0, &req); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMAlterStbReq(&pBuf, &req); + tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; return pHead; @@ -430,10 +422,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SMDropStbReq dropReq = {0}; strcpy(dropReq.name, stbname); - int32_t contLen = tSerializeSMDropStbReq(NULL, &dropReq); + int32_t contLen = tSerializeSMDropStbReq(NULL, 0, &dropReq); void* pHead = rpcMallocCont(contLen); - void* pBuf = pHead; - tSerializeSMDropStbReq(&pBuf, &dropReq); + tSerializeSMDropStbReq(pHead, contLen, &dropReq); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pHead, contLen); ASSERT_NE(pRsp, nullptr); diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 2bbf9116c2..0b4867de03 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -404,15 +404,14 @@ char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* outputLen, SP return NULL; } - int32_t tlen = tSerializeSMCreateStbReq(NULL, &createReq); + int32_t tlen = tSerializeSMCreateStbReq(NULL, 0, &createReq); void* pReq = malloc(tlen); if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - void* pBuf = pReq; - tSerializeSMCreateStbReq(&pBuf, &createReq); + tSerializeSMCreateStbReq(pReq, tlen, &createReq); *outputLen = tlen; return pReq; } @@ -433,15 +432,14 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* outputLen, SParseContext* pPa assert(code == TSDB_CODE_SUCCESS && name.type == TSDB_TABLE_NAME_T); dropReq.igNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0; - int32_t tlen = tSerializeSMDropStbReq(NULL, &dropReq); + int32_t tlen = tSerializeSMDropStbReq(NULL, 0, &dropReq); void* pReq = malloc(tlen); if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - void* pBuf = pReq; - tSerializeSMDropStbReq(&pBuf, &dropReq); + tSerializeSMDropStbReq(pReq, tlen, &dropReq); *outputLen = tlen; return pReq; } -- GitLab