From 5f3fce3577a9ccf1e5ee2a067c72004b9d2210c3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 24 May 2020 22:44:21 +0800 Subject: [PATCH] [td-225]fix crash in parsing the following sql: create table t1 as select count(*); --- src/client/src/tscSQLParser.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f338bbc644..d23d0e1860 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5337,13 +5337,6 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) { } } - SColumnIndex ind = {0}; - SSqlExpr* pExpr1 = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG_DUMMY, &ind, TSDB_DATA_TYPE_INT, - tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, false); - - const char* name = (pExprList->a[0].aliasName != NULL)? pExprList->a[0].aliasName:functionsInfo[index].name; - strncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName)); - switch (index) { case 0: pQueryInfo->command = TSDB_SQL_CURRENT_DB; @@ -5362,6 +5355,13 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) { return TSDB_CODE_SUCCESS; default: { return invalidSqlErrMsg(pQueryInfo->msg, msg3); } } + + SColumnIndex ind = {0}; + SSqlExpr* pExpr1 = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG_DUMMY, &ind, TSDB_DATA_TYPE_INT, + tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, false); + + const char* name = (pExprList->a[0].aliasName != NULL)? pExprList->a[0].aliasName:functionsInfo[index].name; + strncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName)); } // can only perform the parameters based on the macro definitation -- GitLab