From e3d9054f462968a07e093faf6a3339960c217c1e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 22 Oct 2020 23:14:01 +0800 Subject: [PATCH] [td-1373] --- src/client/inc/tscUtil.h | 1 + src/client/src/tscFunctionImpl.c | 2 +- src/client/src/tscSubquery.c | 10 +++++++++- src/client/src/tscUtil.c | 13 ++++++------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 42096f058a..d86e1aa0fb 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -82,6 +82,7 @@ typedef struct SJoinSupporter { char* pIdTagList; // result of first stage tags int32_t totalLen; int32_t num; + SArray* pVgroupTables; } SJoinSupporter; typedef struct SVgroupTableInfo { diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 81893841f7..7a668e85bf 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -4048,7 +4048,7 @@ static void ts_comp_function_f(SQLFunctionCtx *pCtx, int32_t index) { STSBuf *pTSbuf = pInfo->pTSBuf; - tsBufAppend(pTSbuf, 0, &pCtx->tag, pData, TSDB_KEYSIZE); + tsBufAppend(pTSbuf, pCtx->param[0].i64Key, &pCtx->tag, pData, TSDB_KEYSIZE); SET_VAL(pCtx, pCtx->size, 1); pResInfo->hasResult = DATA_SET_FLAG; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 7262fdd9f2..b58bca26ef 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -324,7 +324,8 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { tscFieldInfoUpdateOffset(pNewQueryInfo); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0); - + pTableMetaInfo->pVgroupTables = pSupporter->pVgroupTables; + /* * When handling the projection query, the offset value will be modified for table-table join, which is changed * during the timestamp intersection. @@ -384,6 +385,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { } assert(taosArrayGetSize(pTableMetaInfo->pVgroupTables) > 0); + TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY); } else { // TODO remove unnecessarily accessed vnode // pTableMetaInfo->vgroupList-> // for(int32_t k = 0; k < taosArrayGetSize(pTableMetaInfo->pVgroupTables);) { @@ -750,6 +752,12 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow STableMetaInfo* pTableMetaInfo2 = tscGetMetaInfo(pQueryInfo2, 0); tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2); + SSqlObj* psub1 = pParentSql->pSubs[0]; + ((SJoinSupporter*)psub1->param)->pVgroupTables = tscCloneVgroupTableInfo(pTableMetaInfo1->pVgroupTables); + + SSqlObj* psub2 = pParentSql->pSubs[1]; + ((SJoinSupporter*)psub2->param)->pVgroupTables = tscCloneVgroupTableInfo(pTableMetaInfo2->pVgroupTables); + pParentSql->subState.numOfSub = 2; pParentSql->subState.numOfRemain = pParentSql->subState.numOfSub; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index eb3ad31235..accb20d74f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1710,8 +1710,6 @@ void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) { } taosArrayDestroy(pInfo->itemList); - - taosArrayRemove(pVgroupTable, index); } @@ -1726,14 +1724,15 @@ SArray* tscCloneVgroupTableInfo(SArray* pVgroupTables) { for (size_t i = 0; i < num; i++) { SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i); - for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) { - taosTFree(pInfo->vgInfo.epAddr[j].fqdn); - } - SVgroupTableInfo info = {0}; info.vgInfo = pInfo->vgInfo; - info.itemList = taosArrayClone(pInfo->itemList); + for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) { + info.vgInfo.epAddr[j].fqdn = strdup(pInfo->vgInfo.epAddr[j].fqdn); + } + + + info.itemList = taosArrayClone(pInfo->itemList); taosArrayPush(pa, &info); }