From 7bd970f044146a5a6a30c331a9a00430e6ad38e7 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 18 Aug 2021 19:40:34 +0800 Subject: [PATCH] [TD-5939] fix long where condition error. add length limit --- src/client/src/tscSQLParser.c | 16 ++++++++++++++-- src/inc/taosdef.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 612a3d4798..66eb5bca11 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3994,7 +3994,13 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx UNUSED(code); // TODO: more error handling } END_TRY - + + if (tbufTell(&bw) >= TSDB_MAX_WHERE_LEN ) { + char tmp[64] = {0}; + sprintf(tmp, "where condition string should be less than %d characters", TSDB_MAX_WHERE_LEN); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), tmp); + } + // add to required table column list STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i); int64_t uid = pTableMetaInfo->pTableMeta->id.uid; @@ -5238,7 +5244,13 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE UNUSED(code); // TODO: more error handling } END_TRY - + + if (tbufTell(&bw) >= TSDB_MAX_WHERE_LEN ) { + char tmp[64] = {0}; + sprintf(tmp, "where condition string should be less than %d characters", TSDB_MAX_WHERE_LEN); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), tmp); + } + // add to required table column list STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i); int64_t uid = pTableMetaInfo->pTableMeta->id.uid; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index fceeaea0ae..2983be90e0 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -210,6 +210,7 @@ do { \ #define TSDB_MAX_TAGS_LEN 16384 #define TSDB_MAX_TAGS 128 #define TSDB_MAX_TAG_CONDITIONS 1024 +#define TSDB_MAX_WHERE_LEN 65535 #define TSDB_AUTH_LEN 16 #define TSDB_KEY_LEN 16 -- GitLab