diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index e70cd11fbe03b498d2caad93b086cfc33adf5669..99c03c65801a64eb6b913373603cfa9c48d36911 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -428,6 +428,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { } else { assert(code == TSDB_CODE_SUCCESS); } + // param already freed by other routine and pSql in tscCache when ctrl + c if (atomic_load_ptr(&pSql->param) == NULL) { return; @@ -441,6 +442,20 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { assert(pParObj->signature == pParObj && trs->subqueryIndex == pTableMetaInfo->vgroupIndex && pTableMetaInfo->vgroupIndex >= 0 && pTableMetaInfo->vgroupList != NULL); + // tscProcessSql can add error into async res + tscProcessSql(pSql); + return; + } else if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) { + tscDebug("%p update table meta in local cache, continue to process sql and send corresponding tid_tag query", pSql); + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + code = tscGetTableMeta(pSql, pTableMetaInfo); + if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + return; + } else { + assert(code == TSDB_CODE_SUCCESS); + } + + assert((tscGetNumOfTags(pTableMetaInfo->pTableMeta) != 0)); // tscProcessSql can add error into async res tscProcessSql(pSql); return; @@ -465,7 +480,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { tscResetSqlCmdObj(pCmd, false); code = tsParseSql(pSql, true); - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { return; } else if (code != TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 5e65126ef60c7db45ba33ca70fb4687c425c7571..f960beb5d9f3281c3a511d901e0a8b38b0547837 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1309,7 +1309,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) { if ((!pCmd->parseFinished) && (!initial)) { tscDebug("%p resume to parse sql: %s", pSql, pCmd->curSql); } - + ret = tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE); if (TSDB_CODE_SUCCESS != ret) { return ret; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index fd56001174208ffaa34eb2477e6bdf36e2a93916..b3d151ba2798b89f0ffffad33ed3b4f6a44483f8 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -523,7 +523,7 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { assert(pSqlObj->subState.numOfRemain > 0); if (atomic_sub_fetch_32(&pSqlObj->subState.numOfRemain, 1) <= 0) { - tscError("%p all subquery return and query failed, global code:%d", pSqlObj, pSqlObj->res.code); + tscError("%p all subquery return and query failed, global code:%s", pSqlObj, tstrerror(pSqlObj->res.code)); freeJoinSubqueryObj(pSqlObj); } } @@ -565,7 +565,7 @@ int32_t tagValCompar(const void* p1, const void* p2) { return (tag1->len > tag2->len)? 1: -1; } - return strncmp(tag1->data, tag2->data, tag1->len); + return memcmp(tag1->data, tag2->data, tag1->len); } void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArray* tables) { diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index 3bd4aad2766954709231f55ecdccfe03209a91bc..84ca78d82249b88d68176b0a350a83fb56b8fda9 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -149,7 +149,7 @@ typedef struct SResultRowCellInfo { int8_t hasResult; // result generated, not NULL value bool initialized; // output buffer has been initialized bool complete; // query has completed - uint16_t numOfRes; // num of output result in current buffer + uint32_t numOfRes; // num of output result in current buffer } SResultRowCellInfo; #define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo))) diff --git a/src/query/src/qAst.c b/src/query/src/qAst.c index 847a8b8eb601250866ed2e4f29b63941c3faa19d..bc2866fb6f3a1e6325f94d1f9c4d8ddd18abbbd1 100644 --- a/src/query/src/qAst.c +++ b/src/query/src/qAst.c @@ -32,7 +32,6 @@ #include "tstoken.h" #include "ttokendef.h" #include "tulog.h" -#include "tutil.h" /* * diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index b365dc4283ccab8d6440a5c479102353870aa616..b992a037ed6f37bb674a0d7755653abe491ed845 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1609,7 +1609,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order pRuntimeEnv->pCtx = (SQLFunctionCtx *)calloc(pQuery->numOfOutput, sizeof(SQLFunctionCtx)); pRuntimeEnv->rowCellInfoOffset = calloc(pQuery->numOfOutput, sizeof(int32_t)); - pRuntimeEnv->pResultRow = getNewResultRow(pRuntimeEnv->pool);//calloc(1, sizeof(SResultRow)); + pRuntimeEnv->pResultRow = getNewResultRow(pRuntimeEnv->pool); if (pRuntimeEnv->pResultRow == NULL || pRuntimeEnv->pCtx == NULL || pRuntimeEnv->rowCellInfoOffset == NULL) { goto _clean; @@ -1745,6 +1745,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { pRuntimeEnv->pTSBuf = tsBufDestroy(pRuntimeEnv->pTSBuf); taosTFree(pRuntimeEnv->keyBuf); + taosTFree(pRuntimeEnv->rowCellInfoOffset); taosHashCleanup(pRuntimeEnv->pResultRowHashTable); pRuntimeEnv->pResultRowHashTable = NULL; diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index a219bd6abd928866b93d00ab2ed162c1ae9bc3f3..788779b2bb28feb4547c0bb6dca970f705b185c4 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -170,7 +170,7 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows int32_t numOfRows = taosNumOfRemainRows(pFillInfo); TSKEY ekey1 = ekey; - if (pFillInfo->order != TSDB_ORDER_ASC) { + if (!FILL_IS_ASC_FILL(pFillInfo)) { pFillInfo->endKey = taosTimeTruncate(ekey, &pFillInfo->interval, pFillInfo->precision); } diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index fb984f67504fbf89630dc474278a513ab8d7a4f8..b63c1992d04b3bdaaac517b0c57944959cb0b283 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -332,7 +332,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) { } if (code != TSDB_CODE_SUCCESS) { - vDebug("vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p", pVnode->vgId, code, (void *)pRetrieve->qhandle); + vError("vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p", pVnode->vgId, code, (void *)pRetrieve->qhandle); vnodeBuildNoResultQueryRsp(pRet); return code; }