diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 1a69c1d79d68438b1c56ba44332f1f2a44b02723..a3186b81898975a52dba2d918d963625b770e80c 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1363,6 +1363,8 @@ typedef struct SVCreateTbReq { } SVCreateTbReq, SVUpdateTbReq; typedef struct { + int32_t code; + SName tableName; } SVCreateTbRsp, SVUpdateTbRsp; int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 4a49c0f528089526ce6dcdbc1b28d8e45cc12cfd..bf2a530d611e89cd1e8419a1c98d92144a5caebc 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -36,9 +36,8 @@ extern "C" { #define CHECK_CODE_GOTO(expr, label) \ do { \ - int32_t code = expr; \ + code = expr; \ if (TSDB_CODE_SUCCESS != code) { \ - terrno = code; \ goto label; \ } \ } while (0) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 000c777231ed60eddaab0c9db8287b64c2540362..2192a1a52058c9a6639a5b6c1949a87507b6356d 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -250,9 +250,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList SRequestObj* execQueryImpl(STscObj* pTscObj, const char* sql, int sqlLen) { SRequestObj* pRequest = NULL; SQuery* pQuery = NULL; + int32_t code = 0; SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr)); - terrno = TSDB_CODE_SUCCESS; CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQuery), _return); @@ -261,13 +261,12 @@ SRequestObj* execQueryImpl(STscObj* pTscObj, const char* sql, int sqlLen) { } else { CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList), _return); CHECK_CODE_GOTO(scheduleQuery(pRequest, pRequest->body.pDag, pNodeList), _return); - pRequest->code = terrno; } _return: taosArrayDestroy(pNodeList); qDestroyQuery(pQuery); - if (NULL != pRequest && TSDB_CODE_SUCCESS != terrno) { + if (NULL != pRequest && TSDB_CODE_SUCCESS != code) { pRequest->code = terrno; } @@ -492,7 +491,6 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { assert(pRequest->self == pSendInfo->requestObjRefId); pRequest->metric.rsp = taosGetTimestampMs(); - pRequest->code = pMsg->code; STscObj* pTscObj = pRequest->pTscObj; if (pEpSet) { diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index c945b3644c01b0c9e6122eda1c6f36f57da71bdf..67f212c2736579f4c95c573ac344ba1ed31cc038 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -88,12 +88,14 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { SSchema *pTagSchema; SRpcMsg rpcMsg; int msgLen = 0; - int32_t code = TSDB_CODE_VND_APP_ERROR; + int32_t code = 0; char tableFName[TSDB_TABLE_FNAME_LEN]; + int32_t rspLen = 0; + void *pRsp = NULL; STableInfoReq infoReq = {0}; if (tDeserializeSTableInfoReq(pMsg->pCont, pMsg->contLen, &infoReq) != 0) { - terrno = TSDB_CODE_INVALID_MSG; + code = TSDB_CODE_INVALID_MSG; goto _exit; } @@ -161,22 +163,22 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { memcpy(POINTER_SHIFT(metaRsp.pSchemas, sizeof(SSchema) * pSW->nCols), pTagSchema, sizeof(SSchema) * nTagCols); } - int32_t rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); + +_exit: + + rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); if (rspLen < 0) { code = TSDB_CODE_INVALID_MSG; goto _exit; } - void *pRsp = rpcMallocCont(rspLen); + pRsp = rpcMallocCont(rspLen); if (pRsp == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp); - code = 0; - -_exit: tFreeSTableMetaRsp(&metaRsp); if (pSW != NULL) {