1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Revert "MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP querying from a view [fixes #436]"

This reverts commit 7069071d7d

And add a test to show that optimization steps that
a) are repeated for every execution
b) create new items
cannot be done on the statement arena
This commit is contained in:
Sergei Golubchik
2018-01-14 12:37:55 +01:00
parent edb6375910
commit 1ea2b2956b
3 changed files with 62 additions and 11 deletions

View File

@ -1,5 +1,3 @@
drop procedure if exists test.longprocedure;
drop table if exists t1;
create table t1 (a int); create table t1 (a int);
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
length length
@ -60,3 +58,30 @@ f1
This is a test case for for Bug#9819 This is a test case for for Bug#9819
drop procedure p1; drop procedure p1;
drop table t1, t2; drop table t1, t2;
create table t1 (
`id1` int unsigned not null default '0',
`id2` int unsigned not null default '0',
`link_type` int unsigned not null default '0',
`visibility` tinyint not null default '0',
`data` varchar(255) not null default '',
`time` int unsigned not null default '0',
`version` int unsigned not null default '0',
primary key (id1, link_type, visibility, id2)
) default collate=latin1_bin;
create procedure select_test()
begin
declare id1_cond int;
set id1_cond = 1;
while id1_cond <= 10000 do
select count(*) as cnt from (select id1 from t1 force index (primary) where id1 = id1_cond and link_type = 1 and visibility = 1 order by id2 desc) as t into @cnt;
set id1_cond = id1_cond + 1;
end while;
end//
insert t1 select seq, seq, 1, 1, seq, seq, seq from seq_1_to_2000;
set @before=unix_timestamp();
call select_test();
select unix_timestamp() - @before < 60;
unix_timestamp() - @before < 60
1
drop procedure select_test;
drop table t1;

View File

@ -1,11 +1,7 @@
# #
# Bug #11602: SP with very large body not handled well # Bug #11602: SP with very large body not handled well
# #
source include/have_sequence.inc;
--disable_warnings
drop procedure if exists test.longprocedure;
drop table if exists t1;
--enable_warnings
create table t1 (a int); create table t1 (a int);
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
@ -85,3 +81,37 @@ select f1 from t1 limit 1;
select f1 from t2 limit 1; select f1 from t2 limit 1;
drop procedure p1; drop procedure p1;
drop table t1, t2; drop table t1, t2;
#
# Loops with many iterations
# (Item_equal must be created in the execution arena)
#
create table t1 (
`id1` int unsigned not null default '0',
`id2` int unsigned not null default '0',
`link_type` int unsigned not null default '0',
`visibility` tinyint not null default '0',
`data` varchar(255) not null default '',
`time` int unsigned not null default '0',
`version` int unsigned not null default '0',
primary key (id1, link_type, visibility, id2)
) default collate=latin1_bin;
delimiter //;
create procedure select_test()
begin
declare id1_cond int;
set id1_cond = 1;
while id1_cond <= 10000 do
select count(*) as cnt from (select id1 from t1 force index (primary) where id1 = id1_cond and link_type = 1 and visibility = 1 order by id2 desc) as t into @cnt;
set id1_cond = id1_cond + 1;
end while;
end//
delimiter ;//
insert t1 select seq, seq, 1, 1, seq, seq, seq from seq_1_to_2000;
set @before=unix_timestamp();
call select_test();
select unix_timestamp() - @before < 60;
drop procedure select_test;
drop table t1;

View File

@ -14677,8 +14677,6 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
Item_equal *item_equal; Item_equal *item_equal;
COND *org_cond= cond; // Return this in case of fatal error COND *org_cond= cond; // Return this in case of fatal error
Query_arena_stmt on_stmt_arena(thd);
if (cond->type() == Item::COND_ITEM) if (cond->type() == Item::COND_ITEM)
{ {
List<Item> *cond_list= ((Item_cond*) cond)->argument_list(); List<Item> *cond_list= ((Item_cond*) cond)->argument_list();
@ -15800,8 +15798,6 @@ optimize_cond(JOIN *join, COND *conds,
THD *thd= join->thd; THD *thd= join->thd;
DBUG_ENTER("optimize_cond"); DBUG_ENTER("optimize_cond");
Query_arena_stmt on_stmt_arena(thd);
if (!conds) if (!conds)
{ {
*cond_value= Item::COND_TRUE; *cond_value= Item::COND_TRUE;