Skip to content

Commit c73417c

Browse files
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.
1 parent 96e49c7 commit c73417c

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# MDEV-32907
3+
#
4+
for master_1
5+
for child2
6+
for child3
7+
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
8+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
9+
create table t2 (c varchar(16));
10+
create table t1 (c varchar(16)) ENGINE=Spider
11+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
12+
insert into t1 values ('TestSpiderRegex');
13+
select c from t1 where c regexp '(Test|Spider|Regex)';
14+
c
15+
TestSpiderRegex
16+
drop table t1, t2;
17+
drop server srv;
18+
for master_1
19+
for child2
20+
for child3
21+
#
22+
# end of test mdev_32907
23+
#
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--echo #
2+
--echo # MDEV-32907
3+
--echo #
4+
--disable_query_log
5+
--disable_result_log
6+
--source ../../t/test_init.inc
7+
--enable_result_log
8+
--enable_query_log
9+
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
10+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
11+
12+
create table t2 (c varchar(16));
13+
create table t1 (c varchar(16)) ENGINE=Spider
14+
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
15+
16+
insert into t1 values ('TestSpiderRegex');
17+
select c from t1 where c regexp '(Test|Spider|Regex)';
18+
drop table t1, t2;
19+
drop server srv;
20+
21+
--disable_query_log
22+
--disable_result_log
23+
--source ../../t/test_deinit.inc
24+
--enable_result_log
25+
--enable_query_log
26+
--echo #
27+
--echo # end of test mdev_32907
28+
--echo #

storage/spider/spd_db_mysql.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,12 +5856,17 @@ int spider_db_mbase_util::print_item_func(
58565856
item_count -= 2;
58575857
break;
58585858
}
5859-
} else if (func_name_length == 6 &&
5860-
!strncasecmp("istrue", func_name, func_name_length)
5861-
) {
5862-
last_str = SPIDER_SQL_IS_TRUE_STR;
5863-
last_str_length = SPIDER_SQL_IS_TRUE_LEN;
5864-
break;
5859+
} else if (func_name_length == 6)
5860+
{
5861+
if (!strncasecmp("istrue", func_name, func_name_length))
5862+
{
5863+
last_str= SPIDER_SQL_IS_TRUE_STR;
5864+
last_str_length= SPIDER_SQL_IS_TRUE_LEN;
5865+
break;
5866+
}
5867+
else if (!strncasecmp("regexp", func_name, func_name_length))
5868+
/* Keep the infix expression */
5869+
break;
58655870
} else if (func_name_length == 7)
58665871
{
58675872
if (!strncasecmp("isfalse", func_name, func_name_length))

0 commit comments

Comments
 (0)