From 2eb18e101c4a74d1cf0b508d75bbd0cf1d91d5b2 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 26 May 2021 10:05:09 +0800 Subject: [PATCH] [td-225] add test cases. --- src/client/src/tscSQLParser.c | 1 - src/client/src/tscServer.c | 2 ++ src/client/src/tscUtil.c | 5 +++ tests/script/general/parser/nestquery.sim | 39 ++++++++++++++++++++++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e33f9d6c22..d92cae4c92 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7370,7 +7370,6 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS SSqlNode* p = taosArrayGetP(subInfo->pSubquery, 0); SQueryInfo* pSub = calloc(1, sizeof(SQueryInfo)); - printf("-------------queryinfo:%p\n", pSub); tscInitQueryInfo(pSub); int32_t code = validateSqlNode(pSql, p, pSub); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 513b85b2a6..9222dc5d57 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1614,6 +1614,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) { taosArrayPush(group, &tableKeyInfo); taosArrayPush(tableGroupInfo.pGroupList, &group); + // todo remove it SExprInfo* list = calloc(tscNumOfExprs(pQueryInfo), sizeof(SExprInfo)); for(int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) { SExprInfo* pExprInfo = tscExprGet(pQueryInfo, i); @@ -1621,6 +1622,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) { } pQueryInfo->pQInfo = createQInfoFromQueryNode(pQueryInfo, list, &tableGroupInfo, NULL, NULL, pRes->pLocalMerger, MERGE_STAGE); + tfree(list); } uint64_t localQueryId = 0; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 1b36e3cb00..0907961145 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1010,6 +1010,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue pSourceOperator = createJoinOperator(p, px->numOfTables, schema, num); tfree(p); + } else { + int32_t num = taosArrayGetSize(px->colList); + + schema = calloc(num, sizeof(SSchema)); + memcpy(schema, pSchema, numOfCol1*sizeof(SSchema)); } SExprInfo* exprInfo = NULL; diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/general/parser/nestquery.sim index 082457438f..d6fde199dc 100644 --- a/tests/script/general/parser/nestquery.sim +++ b/tests/script/general/parser/nestquery.sim @@ -61,6 +61,43 @@ sleep 100 $i = 1 $tb = $tbPrefix . $i -sql select count(*) from (select + +print simple nest query test +sql select count(*) from (select count(*) from nest_mt0)) +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +sql select count(*) from (select count(*) from nest_mt0 group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 10 then + return -1 +endi + +sql select count(*) from (select count(*) from nest_mt0 interval(10h) group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 10 then + return -1 +endi + +print =================> alias name test +sql select count(a) from (select count(*) a from nest_tb0 interval(1h)) +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file -- GitLab