fix: collection functions hash set distinct error
This commit is contained in:
parent
94b9d0f10a
commit
1aad905558
|
@ -2033,7 +2033,6 @@ typedef struct SCollectFuncsCxt {
|
||||||
char* tableAlias;
|
char* tableAlias;
|
||||||
FFuncClassifier classifier;
|
FFuncClassifier classifier;
|
||||||
SNodeList* pFuncs;
|
SNodeList* pFuncs;
|
||||||
SHashObj* pFuncsSet;
|
|
||||||
} SCollectFuncsCxt;
|
} SCollectFuncsCxt;
|
||||||
|
|
||||||
static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
||||||
|
@ -2048,9 +2047,15 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SExprNode* pExpr = (SExprNode*)pNode;
|
SExprNode* pExpr = (SExprNode*)pNode;
|
||||||
if (NULL == taosHashGet(pCxt->pFuncsSet, &pExpr, sizeof(SExprNode*))) {
|
bool bFound = false;
|
||||||
|
SNode* pn = NULL;
|
||||||
|
FOREACH(pn, pCxt->pFuncs) {
|
||||||
|
if (nodesEqualNode(pn, pNode)) {
|
||||||
|
bFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bFound) {
|
||||||
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
||||||
taosHashPut(pCxt->pFuncsSet, &pExpr, POINTER_BYTES, &pExpr, POINTER_BYTES);
|
|
||||||
}
|
}
|
||||||
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -2077,12 +2082,10 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAl
|
||||||
SCollectFuncsCxt cxt = {.errCode = TSDB_CODE_SUCCESS,
|
SCollectFuncsCxt cxt = {.errCode = TSDB_CODE_SUCCESS,
|
||||||
.classifier = classifier,
|
.classifier = classifier,
|
||||||
.tableAlias = tableAlias,
|
.tableAlias = tableAlias,
|
||||||
.pFuncs = (NULL == *pFuncs ? nodesMakeList() : *pFuncs),
|
.pFuncs = (NULL == *pFuncs ? nodesMakeList() : *pFuncs)};
|
||||||
.pFuncsSet = taosHashInit(4, funcNodeHash, false, false)};
|
if (NULL == cxt.pFuncs) {
|
||||||
if (NULL == cxt.pFuncs || NULL == cxt.pFuncsSet) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
taosHashSetEqualFp(cxt.pFuncsSet, funcNodeEqual);
|
|
||||||
*pFuncs = NULL;
|
*pFuncs = NULL;
|
||||||
nodesWalkSelectStmt(pSelect, clause, collectFuncs, &cxt);
|
nodesWalkSelectStmt(pSelect, clause, collectFuncs, &cxt);
|
||||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||||
|
@ -2094,7 +2097,6 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAl
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyList(cxt.pFuncs);
|
nodesDestroyList(cxt.pFuncs);
|
||||||
}
|
}
|
||||||
taosHashCleanup(cxt.pFuncsSet);
|
|
||||||
|
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue