Skip to content
Permalink
Browse files
Fixed mdev-14237 Server crash on query with regexp_substr
It's better to prohibit pushdown of conditions that involve
regexp_substr() and regexp_replace() into materialized derived
tables / views until proper implementations of the get_copy()
virtual method are provided for those functions.
  • Loading branch information
igorbabaev committed Nov 6, 2017
1 parent e0cd6f4 commit 343bcb1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
@@ -8766,3 +8766,44 @@ EXPLAIN
}
DROP VIEW v2;
DROP TABLE t1,t2;
#
# MDEV-14237: derived with regexp_substr() in select list
#
create table t1 (a char(8));
insert into t1 values ('b'), ('a'), ('xx');
select *
from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
where t.f = 'a' or t.f = 'b';
f
b
a
explain format=json select *
from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
where t.f = 'a' or t.f = 'b';
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived2>",
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "t.f = 'a' or t.f = 'b'",
"materialized": {
"query_block": {
"select_id": 2,
"temporary_table": {
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 3,
"filtered": 100
}
}
}
}
}
}
}
drop table t1;
@@ -1548,3 +1548,20 @@ eval explain format=json $q;

DROP VIEW v2;
DROP TABLE t1,t2;

--echo #
--echo # MDEV-14237: derived with regexp_substr() in select list
--echo #

create table t1 (a char(8));
insert into t1 values ('b'), ('a'), ('xx');

let $q=
select *
from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
where t.f = 'a' or t.f = 'b';

eval $q;
eval explain format=json $q;

drop table t1;
@@ -333,8 +333,7 @@ class Item_func_regexp_replace :public Item_str_func
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_replace"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_regexp_replace>(thd, mem_root, this); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0;}
};


@@ -356,8 +355,7 @@ class Item_func_regexp_substr :public Item_str_func
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_substr"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_regexp_substr>(thd, mem_root, this); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0; }
};


0 comments on commit 343bcb1

Please sign in to comment.