From 2bb7d6c799ecc4fe40e746abe546d4988e8afdf3 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 17 Mar 2023 14:38:03 +0800 Subject: [PATCH 1/3] fix: invalid write issue --- source/client/src/clientImpl.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 70185a1395..bef7da2c33 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1132,11 +1132,6 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM pRequest->body.queryFp(pRequest->body.param, pRequest, -1); break; } - - // TODO weired responding code? - if (TSDB_CODE_SUCCESS != code) { - pRequest->code = terrno; - } } int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { From 746174ea45dbfeb9df2f4db3f5a62ba95a7c01fd Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 17 Mar 2023 16:16:15 +0800 Subject: [PATCH 2/3] fix: remove count optimize --- source/libs/parser/src/parTranslater.c | 29 -------------------------- 1 file changed, 29 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ded40f7523..25e54fc5c4 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1331,32 +1331,6 @@ static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) return code; } -static bool isCountNotNullValue(SFunctionNode* pFunc) { - if (FUNCTION_TYPE_COUNT != pFunc->funcType || 1 != LIST_LENGTH(pFunc->pParameterList)) { - return false; - } - SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); - return (QUERY_NODE_VALUE == nodeType(pPara) && !((SValueNode*)pPara)->isNull); -} - -// count(1) is rewritten as count(ts) for scannning optimization -static int32_t rewriteCountNotNullValue(STranslateContext* pCxt, SFunctionNode* pCount) { - SValueNode* pValue = (SValueNode*)nodesListGetNode(pCount->pParameterList, 0); - STableNode* pTable = NULL; - int32_t code = findTable(pCxt, NULL, &pTable); - if (TSDB_CODE_SUCCESS == code) { - SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); - if (NULL == pCol) { - code = TSDB_CODE_OUT_OF_MEMORY; - } else { - setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, -1, pCol); - NODES_DESTORY_LIST(pCount->pParameterList); - code = nodesListMakeAppend(&pCount->pParameterList, (SNode*)pCol); - } - } - return code; -} - static bool isCountTbname(SFunctionNode* pFunc) { if (FUNCTION_TYPE_COUNT != pFunc->funcType || 1 != LIST_LENGTH(pFunc->pParameterList)) { return false; @@ -1422,9 +1396,6 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (isCountStar(pFunc)) { return rewriteCountStar(pCxt, pFunc); } - if (isCountNotNullValue(pFunc)) { - return rewriteCountNotNullValue(pCxt, pFunc); - } if (isCountTbname(pFunc)) { return rewriteCountTbname(pCxt, pFunc); } From 4685fb48704c2789b4ed00c95fb8ea9d77b9bb1e Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 17 Mar 2023 17:52:15 +0800 Subject: [PATCH 3/3] fix: no error passed issue --- source/client/src/clientImpl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index bef7da2c33..1b4292b943 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1085,6 +1085,10 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat tscDebug("0x%" PRIx64 " plan not executed, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); destorySqlCallbackWrapper(pWrapper); + if (TSDB_CODE_SUCCESS != code) { + pRequest->code = terrno; + } + pRequest->body.queryFp(pRequest->body.param, pRequest, code); }