Commit 1ea2b295 authored by Sergei Golubchik's avatar Sergei Golubchik

Revert "MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of...

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

This reverts commit 7069071d

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
parent edb63759
drop procedure if exists test.longprocedure;
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
length
......@@ -60,3 +58,30 @@ f1
This is a test case for for Bug#9819
drop procedure p1;
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;
#
# Bug #11602: SP with very large body not handled well
#
--disable_warnings
drop procedure if exists test.longprocedure;
drop table if exists t1;
--enable_warnings
source include/have_sequence.inc;
create table t1 (a int);
insert into t1 values (1),(2),(3);
......@@ -85,3 +81,37 @@ select f1 from t1 limit 1;
select f1 from t2 limit 1;
drop procedure p1;
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;
......@@ -14677,8 +14677,6 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
Item_equal *item_equal;
COND *org_cond= cond; // Return this in case of fatal error
Query_arena_stmt on_stmt_arena(thd);
if (cond->type() == Item::COND_ITEM)
{
List<Item> *cond_list= ((Item_cond*) cond)->argument_list();
......@@ -15800,8 +15798,6 @@ optimize_cond(JOIN *join, COND *conds,
THD *thd= join->thd;
DBUG_ENTER("optimize_cond");
Query_arena_stmt on_stmt_arena(thd);
if (!conds)
{
*cond_value= Item::COND_TRUE;
......
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