diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c1268079ab0a9452316760e97a8dbf13dd7a79ec..9be971303dc742cb6d05aabb47980774caea8b50 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -10275,7 +10275,8 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS if (pLeft->_node.optr == TSDB_RELATION_ARROW){ pLeft = pLeft->_node.pLeft; } - if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && (pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL || pLeft->pSchema->type == TSDB_DATA_TYPE_JSON)) { + if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && pLeft->nodeType == TSQL_NODE_COL && + (pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL || pLeft->pSchema->type == TSDB_DATA_TYPE_JSON)) { return TSDB_CODE_TSC_INVALID_OPERATION; } } diff --git a/tests/develop-test/2-query/TD-13414.py b/tests/develop-test/2-query/TD-13414.py new file mode 100644 index 0000000000000000000000000000000000000000..6ff2dbe73f0106fbc5e8fdf117490edc543e7cbd --- /dev/null +++ b/tests/develop-test/2-query/TD-13414.py @@ -0,0 +1,89 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-13414] taos shell coredump when scalar function arithmetic operation has bool operands + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db") + tdSql.execute('use db') + + tdSql.execute('create stable stb(ts timestamp, c0 int) tags (t0 int)') + tdSql.execute('create table ctb using stb tags (1)') + tdSql.execute('create table tb (ts timestamp, c0 int)') + + tdSql.execute('insert into ctb values(now, 1)') + tdSql.execute('insert into tb values(now, 1)') + + tdSql.error('select ceil(1.5) + true from stb') + tdSql.error('select ceil(1.5) + true from ctb') + tdSql.error('select ceil(1.5) + true from tb') + + tdSql.error('select round(c0) + false from stb') + tdSql.error('select round(c0) + false from ctb') + tdSql.error('select round(c0) + false from tb') + + tdSql.error('select cos(1) + true from stb') + tdSql.error('select cos(1) + true from ctb') + tdSql.error('select cos(1) + true from tb') + + tdSql.error('select true - ceil(1.5) from stb') + tdSql.error('select true - ceil(1.5) from ctb') + tdSql.error('select true - ceil(1.5) from tb') + + tdSql.error('select false - round(c0) from stb') + tdSql.error('select false - round(c0) from ctb') + tdSql.error('select false - round(c0) from tb') + + tdSql.error('select true - cos(1) from stb') + tdSql.error('select true - cos(1) from ctb') + tdSql.error('select true - cos(1) from tb') + + tdSql.error('select true + ceil(1.5) - false from stb') + tdSql.error('select true + ceil(1.5) - false from ctb') + tdSql.error('select true + ceil(1.5) - false from tb') + + tdSql.error('select false - round(c0) - false from stb') + tdSql.error('select false - round(c0) - false from ctb') + tdSql.error('select false - round(c0) - false from tb') + + tdSql.error('select true - cos(1) - false from stb') + tdSql.error('select true - cos(1) - false from ctb') + tdSql.error('select true - cos(1) - false from tb') + + tdSql.execute('drop database db') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c2b1a2fa9789cd61fd82e25c86b0aedc2e726518..89716f7a98dc0a4b10a2a331c0459d677cd1e5af 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -745,5 +745,6 @@ 3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py 3,,develop-test,python3 ./test.py -f 1-insert/uppercase_in_stmt.py 3,,develop-test,python3 ./test.py -f 2-query/ts_shortcut.py +3,,develop-test,python3 ./test.py -f 2-query/TD-13414.py 8,,pytest,python3 test.py -f update/update2.py 4,,pytest,python3 test.py -f insert/line_insert.py