Commit c73417c6 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-32986 Make regexp operator work in spider group by handler

In spider_db_mbase_util::print_item_func(), if the sql item_func has
an UNKNOWN_FUNC type, by default the spider group by handler (gbh)
transform infix to prefix. But regexp should remain infix, so we add
an if condition to account for this.
parent 96e49c76
#
# MDEV-32907
#
for master_1
for child2
for child3
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c varchar(16));
create table t1 (c varchar(16)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values ('TestSpiderRegex');
select c from t1 where c regexp '(Test|Spider|Regex)';
c
TestSpiderRegex
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
#
# end of test mdev_32907
#
--echo #
--echo # MDEV-32907
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c varchar(16));
create table t1 (c varchar(16)) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values ('TestSpiderRegex');
select c from t1 where c regexp '(Test|Spider|Regex)';
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
--echo #
--echo # end of test mdev_32907
--echo #
......@@ -5856,12 +5856,17 @@ int spider_db_mbase_util::print_item_func(
item_count -= 2;
break;
}
} else if (func_name_length == 6 &&
!strncasecmp("istrue", func_name, func_name_length)
) {
last_str = SPIDER_SQL_IS_TRUE_STR;
last_str_length = SPIDER_SQL_IS_TRUE_LEN;
break;
} else if (func_name_length == 6)
{
if (!strncasecmp("istrue", func_name, func_name_length))
{
last_str= SPIDER_SQL_IS_TRUE_STR;
last_str_length= SPIDER_SQL_IS_TRUE_LEN;
break;
}
else if (!strncasecmp("regexp", func_name, func_name_length))
/* Keep the infix expression */
break;
} else if (func_name_length == 7)
{
if (!strncasecmp("isfalse", func_name, func_name_length))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment