提交 dfedc1c9 编写于 作者: S shenglian zhou

set colId of scalar expr to first column column ID so that order by operator function correctly

上级 76977bf3
...@@ -1849,8 +1849,6 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 ...@@ -1849,8 +1849,6 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32
} }
} }
// expr string is set as the parameter of function
SColumnIndex index = {.tableIndex = tableIndex};
tExprNode* pNode = NULL; tExprNode* pNode = NULL;
SArray* colList = taosArrayInit(10, sizeof(SColIndex)); SArray* colList = taosArrayInit(10, sizeof(SColIndex));
...@@ -1889,9 +1887,20 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 ...@@ -1889,9 +1887,20 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
//set the columnIndex to first column Index so that column Id
SColumnIndex index = {.tableIndex = tableIndex};
size_t numOfCols = taosArrayGetSize(colList);
if (numOfCols > 0) {
SColIndex* pIndex = taosArrayGet(colList, 0);
index.columnIndex = pIndex->colIndex;
}
SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_SCALAR_EXPR, &index, pNode->resultType, pNode->resultBytes, SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_SCALAR_EXPR, &index, pNode->resultType, pNode->resultBytes,
getNewResColId(pCmd), 0, false); getNewResColId(pCmd), 0, false);
// if there are no columns, set the colId to the result column id
if (numOfCols == 0) {
pExpr->base.colInfo.colId = pExpr->base.resColId;
}
char* name = (pItem->aliasName != NULL)? pItem->aliasName:pItem->pNode->exprToken.z; char* name = (pItem->aliasName != NULL)? pItem->aliasName:pItem->pNode->exprToken.z;
size_t len = MIN(sizeof(pExpr->base.aliasName), pItem->pNode->exprToken.n + 1); size_t len = MIN(sizeof(pExpr->base.aliasName), pItem->pNode->exprToken.n + 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册