Merge pull request #26877 from taosdata/fix/3.0/TD-31133
fix:[TD-31133] Fix crash when using partition by with having clause.
This commit is contained in:
commit
4e62fda958
|
@ -873,7 +873,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr(code));
|
||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||
} else {
|
||||
mDebug("stream:%s create stream completed", createReq.name);
|
||||
}
|
||||
|
|
|
@ -3439,7 +3439,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
|||
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||
return pCxt->currClause == SQL_CLAUSE_HAVING ? DEAL_RES_IGNORE_CHILD : rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||
}
|
||||
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||
|
@ -3658,6 +3658,7 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect)
|
|||
return code;
|
||||
}
|
||||
if (NULL != pSelect->pHaving) {
|
||||
pCxt->currClause = SQL_CLAUSE_HAVING;
|
||||
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -80,6 +80,12 @@ class TDTestCase:
|
|||
if nonempty_tb_num > 0:
|
||||
num = self.row_nums
|
||||
tdSql.checkRows(num)
|
||||
|
||||
tdSql.query(f"select c1, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by c1 having c1 >= 0")
|
||||
num = 0
|
||||
if nonempty_tb_num > 0:
|
||||
num = self.row_nums
|
||||
tdSql.checkRows(num)
|
||||
|
||||
tdSql.query(f"select ts, count(*) from {self.dbname}.{self.stable} {keyword} by ts ")
|
||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||
|
|
Loading…
Reference in New Issue