Commit 343bcb15 authored by Igor Babaev's avatar Igor Babaev

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.
parent e0cd6f4b
...@@ -8766,3 +8766,44 @@ EXPLAIN ...@@ -8766,3 +8766,44 @@ EXPLAIN
} }
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; 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; ...@@ -1548,3 +1548,20 @@ eval explain format=json $q;
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; 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 ...@@ -333,8 +333,7 @@ class Item_func_regexp_replace :public Item_str_func
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "regexp_replace"; } const char *func_name() const { return "regexp_replace"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0;}
{ return get_item_copy<Item_func_regexp_replace>(thd, mem_root, this); }
}; };
...@@ -356,8 +355,7 @@ class Item_func_regexp_substr :public Item_str_func ...@@ -356,8 +355,7 @@ class Item_func_regexp_substr :public Item_str_func
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "regexp_substr"; } const char *func_name() const { return "regexp_substr"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0; }
{ return get_item_copy<Item_func_regexp_substr>(thd, mem_root, this); }
}; };
......
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