From 4af2ab3d1d831c9f7225d6e06747bc92657863e8 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 5 Aug 2021 18:08:29 +0800 Subject: [PATCH 1/3] [TD-5822] optimize invalidate operation tips --- src/client/src/tscSQLParser.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 5739333886..f534140be9 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7556,6 +7556,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"; + const char* msg9 = "Continuous query do not support sub query"; SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); @@ -7576,7 +7577,11 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { if (pFromInfo == NULL || taosArrayGetSize(pFromInfo->list) == 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } - + + if (pFromInfo->type == SQL_NODE_FROM_SUBQUERY){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); + } + SRelElementPair* p1 = taosArrayGet(pFromInfo->list, 0); SStrToken srcToken = {.z = p1->tableName.z, .n = p1->tableName.n, .type = TK_STRING}; if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) { From 8da778c5050e366a31a6fe5fcb4ce0c36a025180 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 5 Aug 2021 19:19:07 +0800 Subject: [PATCH 2/3] [TD-5833] fix 1 column error when create table use select _c0 from.. --- src/client/src/tscSQLParser.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f534140be9..4154335bb4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7557,6 +7557,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg7 = "time interval is required"; const char* msg8 = "the first column should be primary timestamp column"; const char* msg9 = "Continuous query do not support sub query"; + const char* msg10 = "illegal number of columns"; SSqlCmd* pCmd = &pSql->cmd; SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); @@ -7598,6 +7599,10 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return code; } + if (taosArrayGetSize(pSqlNode->pSelNodeList) <= 1) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } + if (validateSelectNodeList(&pSql->cmd, pQueryInfo, pSqlNode->pSelNodeList, false, false, false) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } From bc7ffbbb7e12ec9d657c48d1c1fa9ade712a6178 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 6 Aug 2021 15:09:45 +0800 Subject: [PATCH 3/3] [TD-5833] fix 1 column error when create table use select _c0 from.. --- src/client/src/tscSQLParser.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4154335bb4..cd92b4f507 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7599,10 +7599,6 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return code; } - if (taosArrayGetSize(pSqlNode->pSelNodeList) <= 1) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); - } - if (validateSelectNodeList(&pSql->cmd, pQueryInfo, pSqlNode->pSelNodeList, false, false, false) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -7648,7 +7644,9 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return TSDB_CODE_TSC_INVALID_OPERATION; } - pCmd->numOfCols = pQueryInfo->fieldsInfo.numOfOutput; + if (pQueryInfo->fieldsInfo.numOfOutput <= 1) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } if (validateSqlFunctionInStreamSql(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION;