From f79bcf1d5fa2ffe887cbfebad264b13920ddd6b3 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 13 Sep 2021 13:20:20 +0800 Subject: [PATCH] [TD-6616]:check the right side of match to be a node value of binary type --- src/client/src/tscSQLParser.c | 4 ++++ tests/script/general/parser/regex.sim | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 35d6d23a83..9746f79d9a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4531,6 +4531,10 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_ return invalidOperationMsg(msgBuf, msg2); } + if (!(pRight->type == SQL_NODE_VALUE && pRight->value.nType == TSDB_DATA_TYPE_BINARY)) { + return invalidOperationMsg(msgBuf, msg3); + } + int errCode = 0; regex_t regex; char regErrBuf[256] = {0}; diff --git a/tests/script/general/parser/regex.sim b/tests/script/general/parser/regex.sim index 36b7ce9984..eed36018d4 100644 --- a/tests/script/general/parser/regex.sim +++ b/tests/script/general/parser/regex.sim @@ -79,6 +79,9 @@ if $rows != 1 then return -1 endi +sql_error select c1b from $st_name where c1b match e; +sql_error select c1b from $st_name where c1b nmatch e; + sql create table wrong_type(ts timestamp, c0 tinyint, c1 smallint, c2 int, c3 bigint, c4 float, c5 double, c6 bool, c7 nchar(20)) tags(t0 tinyint, t1 smallint, t2 int, t3 bigint, t4 float, t5 double, t6 bool, t7 nchar(10)) sql insert into wrong_type_1 using wrong_type tags(1, 2, 3, 4, 5, 6, true, 'notsupport') values(now, 1, 2, 3, 4, 5, 6, false, 'notsupport') sql_error select * from wrong_type where ts match '.*' -- GitLab