diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index f8ca288a13797f5f77336761703beb30f6a335f0..be82eb64a881460d2f8dc751ce99d793dc6cb0db 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -415,7 +415,7 @@ int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); //void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column); static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t columnIndex) { - SFieldSupInfo* pInfo = TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, columnIndex); + SFieldSupInfo* pInfo = (SFieldSupInfo*) TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, columnIndex); assert(pInfo->pSqlExpr != NULL); int32_t type = pInfo->pSqlExpr->resType; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index cf9670d3d254f8056cd8c4ab3cb6de24e8db5780..5e2ba46fbcca85f4e9e758ce0f655cc0b3accddf 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -550,7 +550,7 @@ static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1, return true; } -static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) { +static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) { tscDebug("%p all subqueries retrieve complete, do tags match", pParentSql); SJoinSupporter* p1 = pParentSql->pSubs[0]->param; @@ -568,10 +568,7 @@ static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParent *s2 = taosArrayInit(p2->num, p2->tagSize); if (!(checkForDuplicateTagVal(pQueryInfo, p1, pParentSql) && checkForDuplicateTagVal(pQueryInfo, p2, pParentSql))) { - freeJoinSubqueryObj(pParentSql); - pParentSql->res.code = TSDB_CODE_QRY_DUP_JOIN_KEY; - tscQueueAsyncRes(pParentSql); - return; + return TSDB_CODE_QRY_DUP_JOIN_KEY; } int32_t i = 0, j = 0; @@ -594,6 +591,8 @@ static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParent i++; } } + + return TSDB_CODE_SUCCESS; } static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRows) { @@ -680,7 +679,14 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow } SArray *s1 = NULL, *s2 = NULL; - getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2); + int32_t code = getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2); + if (code != TSDB_CODE_SUCCESS) { + freeJoinSubqueryObj(pParentSql); + pParentSql->res.code = code; + tscQueueAsyncRes(pParentSql); + return; + } + if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return. tscDebug("%p tag intersect does not generated qualified tables for join, free all sub SqlObj and quit", pParentSql); freeJoinSubqueryObj(pParentSql); diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h index c05e2757d60b08cc12d1a470480f7daf94fa61d1..71838af15064ec3d84662dff031d40d2156924eb 100644 --- a/src/util/inc/tarray.h +++ b/src/util/inc/tarray.h @@ -23,14 +23,13 @@ extern "C" { #include "os.h" #define TARRAY_MIN_SIZE 8 -#define TARRAY_GET_ELEM(array, index) ((void*)((array)->pData + (index) * (array)->elemSize)) +#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize)) typedef struct SArray { size_t size; size_t capacity; size_t elemSize; - - void* pData; + void* pData; } SArray; /**