diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index ed937bb68a67847deb8c2a9d7af6ad439479551e..3805d0c43f010ec8280d2348554cc18818c09052 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -710,15 +710,21 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu int doProcessSql(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; + int32_t code; void *asyncFp = pSql->fp; if (pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_RETRIEVE || pCmd->command == TSDB_SQL_INSERT || pCmd->command == TSDB_SQL_CONNECT || pCmd->command == TSDB_SQL_HB || pCmd->command == TSDB_SQL_META || pCmd->command == TSDB_SQL_METRIC) { - tscBuildMsg[pCmd->command](pSql, NULL); + code = tscBuildMsg[pCmd->command](pSql, NULL); } - int32_t code = tscSendMsgToServer(pSql); + if (code != TSDB_CODE_SUCCESS) { + pRes->code = code; + return code; + } + + code = tscSendMsgToServer(pSql); if (asyncFp) { if (code != TSDB_CODE_SUCCESS) { @@ -994,7 +1000,13 @@ int tscLaunchSTableSubqueries(SSqlObj *pSql) { SRetrieveSupport* pSupport = pSub->param; tscTrace("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex); - tscProcessSql(pSub); + int code = tscProcessSql(pSub); + if (code != TSDB_CODE_SUCCESS) { + tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, numOfSubQueries); + doCleanupSubqueries(pSql, i, pState); + pRes->code = code; + return pRes->code; + } } return TSDB_CODE_SUCCESS;