From e25a1bb3c946a0b518679b6c1997565a4cdef6c6 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 14 Jan 2022 14:34:40 +0800 Subject: [PATCH] [TD-12945](query): taos shell crash when constant comparison cause crash --- .../develop-test/2-query/constant_compare.py | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/tests/develop-test/2-query/constant_compare.py b/tests/develop-test/2-query/constant_compare.py index e2a67e323c..7ac3933022 100644 --- a/tests/develop-test/2-query/constant_compare.py +++ b/tests/develop-test/2-query/constant_compare.py @@ -95,6 +95,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1 = true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 = false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 = false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0 = true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: != tdSql.query('select 1 != 1 from tb;') tdSql.checkRows(1) @@ -136,6 +152,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 1 != true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0 != false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 1 != false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 != true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: <> tdSql.query('select 1 <> 1 from tb;') tdSql.checkRows(1) @@ -177,6 +209,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 1 <> true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0 <> false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 1 <> false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 <> true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: < tdSql.query('select 1 < 1 from tb;') tdSql.checkRows(1) @@ -218,6 +266,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 0 < true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 < false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select false < true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true < false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: > tdSql.query('select 1 > 1 from tb;') tdSql.checkRows(1) @@ -259,6 +323,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 1 > false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 > true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select false > true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true > false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: <= tdSql.query('select 1 <= 2 from tb;') tdSql.checkRows(1) @@ -312,6 +392,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 0 <= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 <= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select false <= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true <= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select false >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: >= tdSql.query('select 1 >= 2 from tb;') tdSql.checkRows(1) @@ -365,6 +469,29 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1 >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select false >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select false >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) ##operator: between and tdSql.query('select 1 between 2 and 4 from tb;') @@ -448,6 +575,38 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select false between 0 and 1 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select false between 1 and 2 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true between 0 and 1 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true between -1 and 0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0 between false and true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 between false and true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 between false and 10 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 between true and 10 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: and tdSql.query('select 10 and 10 from tb;') tdSql.checkRows(1) @@ -481,6 +640,10 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select true and 10 and false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.query('select 1 and 2 and 3 and 10.1 and -20.02 and 22.03 from tb;') tdSql.checkRows(1) tdSql.checkData(0, 0, 1) @@ -526,6 +689,10 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select true or 10 or false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: multiple operations tdSql.query('select 1 and 1 != 2 and 1 < 2 and 2 between 1 and 3 from tb;') tdSql.checkRows(1) @@ -563,6 +730,14 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1 != 2 and 1 < 2 or 1 >= 2 or 2 between 4 and 5 or true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 != 2 and 1 < 2 or 1 >= 2 or 2 between 4 and 5 and false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + tdSql.execute('drop database db') def stop(self): tdSql.close() -- GitLab