diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index ed76f8fd84ca6650a0d3963b732ee5ac54ba3db0..dcd2d1e50951ecb412daec100383aa2888f125f8 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4812,7 +4812,7 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq int32_t type = 0; if ((ret = getQueryCondExpr(&pSql->cmd, pQueryInfo, pExpr, &condExpr, &type, (*pExpr)->tokenId)) != TSDB_CODE_SUCCESS) { - return ret; + goto PARSE_WHERE_EXIT; } tSqlExprCompact(pExpr); @@ -4822,17 +4822,17 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq // 1. check if it is a join query if ((ret = validateJoinExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) { - return ret; + goto PARSE_WHERE_EXIT; } // 2. get the query time range if ((ret = getTimeRangeFromExpr(&pSql->cmd, pQueryInfo, condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) { - return ret; + goto PARSE_WHERE_EXIT; } // 3. get the tag query condition if ((ret = getTagQueryCondExpr(&pSql->cmd, pQueryInfo, &condExpr, pExpr)) != TSDB_CODE_SUCCESS) { - return ret; + goto PARSE_WHERE_EXIT; } // 4. get the table name query condition @@ -7707,11 +7707,18 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { taosArrayPush(pVgroupList, &t); } - STableMeta* pMeta = tscTableMetaDup(pTableMeta); - STableMetaVgroupInfo p = { .pTableMeta = pMeta }; + //STableMeta* pMeta = tscTableMetaDup(pTableMeta); + //STableMetaVgroupInfo p = { .pTableMeta = pMeta }; + //const char* px = tNameGetTableName(pname); + //taosHashPut(pCmd->pTableMetaMap, px, strlen(px), &p, sizeof(STableMetaVgroupInfo)); + // avoid mem leak, may should update pTableMeta const char* px = tNameGetTableName(pname); - taosHashPut(pCmd->pTableMetaMap, px, strlen(px), &p, sizeof(STableMetaVgroupInfo)); + if (taosHashGet(pCmd->pTableMetaMap, px, strlen(px)) == NULL) { + STableMeta* pMeta = tscTableMetaDup(pTableMeta); + STableMetaVgroupInfo p = { .pTableMeta = pMeta, .pVgroupInfo = NULL}; + taosHashPut(pCmd->pTableMetaMap, px, strlen(px), &p, sizeof(STableMetaVgroupInfo)); + } } else { // add to the retrieve table meta array list. char* t = strdup(name); taosArrayPush(plist, &t); @@ -8161,7 +8168,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf // in case of join query, time range is required. if (QUERY_IS_JOIN_QUERY(pQueryInfo->type)) { - int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey); + uint64_t timeRange = (uint64_t)pQueryInfo->window.ekey - pQueryInfo->window.skey; if (timeRange == 0 && pQueryInfo->window.skey == 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index d30ee32d67c2a9294b3a3aa0b2bc9144829a364c..953dfb186a614a10bd63a643d4e23e70db7c0243 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2064,6 +2064,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) { STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg); if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) { tscError("0x%"PRIx64" invalid table meta from mnode, name:%s", pSql->self, pMetaMsg->tableFname); + tfree(pTableMeta); taosHashCleanup(pSet); taosReleaseRef(tscObjRef, pParentSql->self); return TSDB_CODE_TSC_INVALID_VALUE; @@ -2105,6 +2106,10 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) { assert(p != NULL); int32_t size = 0; + if (p->pVgroupInfo!= NULL) { + tscVgroupInfoClear(p->pVgroupInfo); + //tfree(p->pTableMeta); + } p->pVgroupInfo = createVgroupInfoFromMsg(pMsg, &size, pSql->self); pMsg += size; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 55f42516603d03064dcfef1c8ec1c6767e0230b2..2fa8767eecb26afae43fc0bd3f5c3990649dc56c 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -419,7 +419,9 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) { } // tscFieldInfoClear(&pSupporter->fieldsInfo); - + if (pSupporter->fieldsInfo.internalField != NULL) { + taosArrayDestroy(pSupporter->fieldsInfo.internalField); + } if (pSupporter->pTSBuf != NULL) { tsBufDestroy(pSupporter->pTSBuf); pSupporter->pTSBuf = NULL; @@ -433,7 +435,8 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) { } if (pSupporter->pVgroupTables != NULL) { - taosArrayDestroy(pSupporter->pVgroupTables); + //taosArrayDestroy(pSupporter->pVgroupTables); + tscFreeVgroupTableInfo(pSupporter->pVgroupTables); pSupporter->pVgroupTables = NULL; } @@ -892,7 +895,9 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar tscDebug("Join %d - num:%d", i, p->num); // sort according to the tag valu - qsort(p->pIdTagList, p->num, p->tagSize, tagValCompar); + if (p->pIdTagList != NULL) { + qsort(p->pIdTagList, p->num, p->tagSize, tagValCompar); + } if (!checkForDuplicateTagVal(pColSchema, p, pParentSql)) { for (int32_t j = 0; j <= i; j++) {