From 9c04da10a0046d2ed72e55467e4a354bd8372878 Mon Sep 17 00:00:00 2001 From: wpan Date: Fri, 20 Aug 2021 09:43:36 +0800 Subject: [PATCH 1/2] block union for nested query --- 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 30a46ccc48..f1349d7d41 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -888,6 +888,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } case TSDB_SQL_SELECT: { + const char * msg1 = "no nested query supported in union clause"; code = loadAllTableMeta(pSql, pInfo); if (code != TSDB_CODE_SUCCESS) { return code; @@ -901,6 +902,10 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { tscTrace("0x%"PRIx64" start to parse the %dth subclause, total:%"PRIzu, pSql->self, i, size); + if (size > 1 && pSqlNode->from->type == SQL_NODE_FROM_SUBQUERY) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + // normalizeSqlNode(pSqlNode); // normalize the column name in each function if ((code = validateSqlNode(pSql, pSqlNode, pQueryInfo)) != TSDB_CODE_SUCCESS) { return code; From c26d34a6847c483db6769c1f27ffea1ba09f19f2 Mon Sep 17 00:00:00 2001 From: wpan Date: Fri, 20 Aug 2021 18:15:59 +0800 Subject: [PATCH 2/2] fix bug --- src/client/src/tscSQLParser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f1349d7d41..c6614d0054 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -902,7 +902,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { tscTrace("0x%"PRIx64" start to parse the %dth subclause, total:%"PRIzu, pSql->self, i, size); - if (size > 1 && pSqlNode->from->type == SQL_NODE_FROM_SUBQUERY) { + if (size > 1 && pSqlNode->from && pSqlNode->from->type == SQL_NODE_FROM_SUBQUERY) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); }