From c9adad624d14ba6421eeccde323e4f8fee3b9452 Mon Sep 17 00:00:00 2001 From: tickduan <417921451@qq.com> Date: Mon, 7 Jun 2021 17:04:22 +0800 Subject: [PATCH] restore, fix build error --- src/client/src/tscSQLParser.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index a5b1675170..a04bfa0482 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6675,7 +6675,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg6 = "from missing in subclause"; const char* msg7 = "time interval is required"; const char* msg8 = "the first column should be primary timestamp column"; - + SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); assert(pQueryInfo->numOfTables == 1); @@ -6732,15 +6732,26 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } + // project query primary column must be timestamp type if (tscIsProjectionQuery(pQueryInfo)) { - SExprInfo* pExpr = tscExprGet(pQueryInfo, 0); - if (pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { + size_t size = tscSqlExprNumOfExprs(pQueryInfo); + // check zero + if(size == 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + + // check primary column is timestamp + SSqlExpr* pSqlExpr = tscSqlExprGet(pQueryInfo, 0); + if(pSqlExpr == NULL) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + if( pSqlExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); } } else { if (pQueryInfo->interval.interval == 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); - } + } } // set the created table[stream] name