From 2e050c4714a646a3059596b51dc271048823b5fb Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 2 Aug 2021 13:21:26 +0800 Subject: [PATCH] [TD-5579] give tips for 3 level'select --- src/client/src/tscSQLParser.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 819f1af4f0..ed7c2eeb19 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -900,6 +900,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { SSqlNode* pSqlNode = taosArrayGetP(pInfo->list, i); tscTrace("0x%"PRIx64" start to parse the %dth subclause, total:%"PRIzu, pSql->self, i, size); + // normalizeSqlNode(pSqlNode); // normalize the column name in each function if ((code = validateSqlNode(pSql, pSqlNode, pQueryInfo)) != TSDB_CODE_SUCCESS) { return code; @@ -2028,7 +2029,6 @@ static SUdfInfo* isValidUdf(SArray* pUdfInfo, const char* name, int32_t len) { tscError("udfinfo is null"); return NULL; } - size_t t = taosArrayGetSize(pUdfInfo); for(int32_t i = 0; i < t; ++i) { SUdfInfo* pUdf = taosArrayGet(pUdfInfo, i); @@ -8455,6 +8455,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf const char* msg6 = "not support stddev/percentile/interp in the outer query yet"; const char* msg7 = "derivative/twa/irate requires timestamp column exists in subquery"; const char* msg8 = "condition missing for join query"; + const char* msg9 = "not support 3 level select"; int32_t code = TSDB_CODE_SUCCESS; @@ -8485,6 +8486,13 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf // parse the subquery in the first place int32_t numOfSub = (int32_t)taosArrayGetSize(pSqlNode->from->list); for (int32_t i = 0; i < numOfSub; ++i) { + // check if there is 3 level select + SRelElementPair* subInfo = taosArrayGet(pSqlNode->from->list, i); + SSqlNode* p = taosArrayGetP(subInfo->pSubquery, 0); + if (p->from->type == SQL_NODE_FROM_SUBQUERY){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); + } + code = doValidateSubquery(pSqlNode, i, pSql, pQueryInfo, tscGetErrorMsgPayload(pCmd)); if (code != TSDB_CODE_SUCCESS) { return code; -- GitLab