diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 0a4b7e9f787dbd01685c2913e513250e46136b4a..b854fd65700a72261a9d7b2fba914562ec55d99d 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -368,19 +368,28 @@ static int32_t handlePassword(SSqlCmd* pCmd, SStrToken* pPwd) { // validate the out put field type for "UNION ALL" subclause static int32_t normalizeVarDataTypeLength(SSqlCmd* pCmd) { const char* msg1 = "columns in select clause not identical"; + const char* msg2 = "too many select clause siblings, at most 100 allowed"; + int32_t siblings = 0; int32_t diffSize = 0; // if there is only one element, the limit of clause is the limit of global result. SQueryInfo* pQueryInfo1 = pCmd->pQueryInfo; SQueryInfo* pSibling = pQueryInfo1->sibling; + // pQueryInfo1 itself + ++siblings; + while(pSibling != NULL) { int32_t ret = tscFieldInfoCompare(&pQueryInfo1->fieldsInfo, &pSibling->fieldsInfo, &diffSize); if (ret != 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } + if (++siblings > 100) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + pSibling = pSibling->sibling; } diff --git a/tests/pytest/query/unionAllTest.py b/tests/pytest/query/unionAllTest.py index cfa7fe568f1a9634b012726984c61bad366f43a7..9a7aedc763db05ebb11da33dc65fa74b2ba8daa3 100644 --- a/tests/pytest/query/unionAllTest.py +++ b/tests/pytest/query/unionAllTest.py @@ -109,7 +109,7 @@ class TDTestCase: tdSql.execute("create table st2(ts timestamp, c1 int, c2 int, c3 int) tags(loc nchar(20))") - for i in range(7000): + for i in range(101): if i == 0: sql = "select last(*) from sub0 " else: @@ -118,13 +118,7 @@ class TDTestCase: tdSql.execute("create table sub%d using st2 tags('nchar%d')" % (i, i)) tdSql.execute("insert into sub%d values(%d, %d, %d, %d)" % (i, self.ts + i, i, i, i)) - exception = "Exception(\"ProgrammingError('Result set too large to be output', -2147483097)\")" - try: - tdSql.query(sql) - except Exception as e: - if {exception} != {repr(e)}: - tdLog.info(f"sql: {sql}, {exception} expected, actually raises {repr(e)}") - raise e + tdSql.error(sql) def stop(self): tdSql.close()