Commit 94ad392f authored by unknown's avatar unknown

MDEV-5143: update of a joined table with a nested subquery with a syntax error...

MDEV-5143: update of a joined table with a nested subquery with a syntax error crashes mysqld with signal 11

Added check of SELECT_LEX::handle_derived() result.
parent 046fe911
......@@ -438,5 +438,32 @@ CALL p();
id
drop procedure p;
drop temporary table t1;
#
# MDEV-5143: update of a joined table with a nested subquery with
# a syntax error crashes mysqld with signal 11
#
create table t1 (id int(11) not null auto_increment, val varchar(100) null,primary key (id));
create table t2 (id int(11) not null auto_increment, val varchar(100) null,primary key (id));
insert into t1 (val) values('a');
insert into t2 (val) values('1');
update
(
select
val
from
(
select
v.val
from
t2 wrong_table_alias
) t4
) t3
inner join t1 on
t1.id=t3.val
set
t1.val=t3.val
;
ERROR 42S22: Unknown column 'v.val' in 'field list'
drop table t1, t2;
# End of 5.3 tests
set optimizer_switch=@save_derived_optimizer_switch;
......@@ -350,6 +350,40 @@ drop procedure p;
drop temporary table t1;
--echo #
--echo # MDEV-5143: update of a joined table with a nested subquery with
--echo # a syntax error crashes mysqld with signal 11
--echo #
create table t1 (id int(11) not null auto_increment, val varchar(100) null,primary key (id));
create table t2 (id int(11) not null auto_increment, val varchar(100) null,primary key (id));
insert into t1 (val) values('a');
insert into t2 (val) values('1');
--error ER_BAD_FIELD_ERROR
update
(
select
val
from
(
select
v.val
from
t2 wrong_table_alias
) t4
) t3
inner join t1 on
t1.id=t3.val
set
t1.val=t3.val
;
drop table t1, t2;
--echo # End of 5.3 tests
set optimizer_switch=@save_derived_optimizer_switch;
......@@ -619,7 +619,8 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
{
sl->context.outer_context= 0;
// Prepare underlying views/DT first.
sl->handle_derived(lex, DT_PREPARE);
if ((res= sl->handle_derived(lex, DT_PREPARE)))
goto exit;
if (derived->outer_join)
{
......
......@@ -2485,7 +2485,13 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
/* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
sl->handle_derived(lex, DT_REINIT);
{
#ifndef DBUG_OFF
bool res=
#endif
sl->handle_derived(lex, DT_REINIT);
DBUG_ASSERT(res == 0);
}
}
{
SELECT_LEX_UNIT *unit= sl->master_unit();
......
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