From 1eb62ce38ca0653d5a09d50352a8a05c2a446bb3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 Jul 2020 15:51:06 +0800 Subject: [PATCH 1/2] [td-225] fix bugs in error handling. --- src/client/src/tscSubquery.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 6c3580bad4..dbb3c90a0e 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); From 9e0ac1ebef3138007f239d02d07e767b69c02136 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 Jul 2020 17:01:35 +0800 Subject: [PATCH 2/2] [td-225] fix compiler error. --- src/client/inc/tsclient.h | 2 +- src/util/inc/tarray.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index f8ca288a13..be82eb64a8 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/util/inc/tarray.h b/src/util/inc/tarray.h index c05e2757d6..71838af150 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; /**