From eb645838e6230a7a7fa1ace233cd503cdb42819b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 19 Jun 2020 15:51:06 +0800 Subject: [PATCH] [td-686] --- src/client/src/tscSQLParser.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 6164c005b9..2566e171f4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1482,7 +1482,8 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr const char* msg5 = "parameter is out of range [0, 100]"; const char* msg6 = "function applied to tags not allowed"; const char* msg7 = "normal table can not apply this function"; - + const char* msg8 = "multi-columns selection does not support alias column name"; + switch (optr) { case TK_COUNT: { if (pItem->pNode->pParam != NULL && pItem->pNode->pParam->nExpr != 1) { @@ -1689,6 +1690,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr return invalidSqlErrMsg(pQueryInfo->msg, msg3); } + if (pItem->pNode->pParam->nExpr > 1 && strlen(pItem->aliasName) > 0) { + return invalidSqlErrMsg(pQueryInfo->msg, msg8); + } + /* in first/last function, multiple columns can be add to resultset */ for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) { tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]); @@ -1755,6 +1760,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr } else { // select * from xxx int32_t numOfFields = 0; + // multicolumn selection does not support alias name + if (strlen(pItem->aliasName) != 0) { + return invalidSqlErrMsg(pQueryInfo->msg, msg8); + } + for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) { pTableMetaInfo = tscGetMetaInfo(pQueryInfo, j); SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); -- GitLab