fix: columanRefNode illegal type conversion
This commit is contained in:
parent
039aef3471
commit
34e62d7fc0
|
@ -88,6 +88,7 @@ typedef struct SColumnNode {
|
||||||
} SColumnNode;
|
} SColumnNode;
|
||||||
|
|
||||||
typedef struct SColumnRefNode {
|
typedef struct SColumnRefNode {
|
||||||
|
SExprNode node; // QUERY_NODE_COLUMN
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char colName[TSDB_COL_NAME_LEN];
|
char colName[TSDB_COL_NAME_LEN];
|
||||||
} SColumnRefNode;
|
} SColumnRefNode;
|
||||||
|
|
|
@ -1094,6 +1094,7 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
strcpy(pColRef->colName, pExpr->aliasName);
|
strcpy(pColRef->colName, pExpr->aliasName);
|
||||||
|
pColRef->node = *pExpr;
|
||||||
nodesDestroyNode(*(SNode**)pCol);
|
nodesDestroyNode(*(SNode**)pCol);
|
||||||
*(SNode**)pCol = (SNode*)pColRef;
|
*(SNode**)pCol = (SNode*)pColRef;
|
||||||
*pFound = true;
|
*pFound = true;
|
||||||
|
@ -3431,6 +3432,24 @@ static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkOrderByAggForGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect, SNodeList* pOrderByList) {
|
||||||
|
if (NULL != getGroupByList(pCxt) || NULL != pSelect->pWindow) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
SNode* pNode = NULL;
|
||||||
|
WHERE_EACH(pNode, pOrderByList) {
|
||||||
|
SNode* pExpr = ((SOrderByExprNode*)pNode)->pExpr;
|
||||||
|
if ((QUERY_NODE_FUNCTION == nodeType(pExpr))) {
|
||||||
|
SFunctionNode* pFunc = (SFunctionNode*)pExpr;
|
||||||
|
if (fmIsAggFunc(pFunc->funcId)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WHERE_NEXT;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
||||||
bool* pOther) {
|
bool* pOther) {
|
||||||
*pOther = false;
|
*pOther = false;
|
||||||
|
@ -3482,6 +3501,9 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||||
}
|
}
|
||||||
|
if (other && TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkOrderByAggForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue