Commit d3157e23 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4665 crash when referencing missing function in a subquery

don't ignore the return value fix_fields()
parent 782d86af
create table t (a int);
create or replace view v as select 1 from t where a;
delete from v where (select g());
ERROR 42000: FUNCTION test.g does not exist
drop view v;
drop table t;
#
# MDEV-4665 crash when referencing missing function in a subquery
#
create table t (a int);
create or replace view v as select 1 from t where a;
--error ER_SP_DOES_NOT_EXIST
delete from v where (select g());
drop view v;
drop table t;
...@@ -3683,6 +3683,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, ...@@ -3683,6 +3683,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
bool no_where_clause) bool no_where_clause)
{ {
DBUG_ENTER("TABLE_LIST::prep_where"); DBUG_ENTER("TABLE_LIST::prep_where");
bool res= FALSE;
for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local) for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
{ {
...@@ -3731,10 +3732,11 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, ...@@ -3731,10 +3732,11 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
if (tbl == 0) if (tbl == 0)
{ {
if (*conds && !(*conds)->fixed) if (*conds && !(*conds)->fixed)
(*conds)->fix_fields(thd, conds); res= (*conds)->fix_fields(thd, conds);
*conds= and_conds(*conds, where->copy_andor_structure(thd)); if (!res)
if (*conds && !(*conds)->fixed) *conds= and_conds(*conds, where->copy_andor_structure(thd));
(*conds)->fix_fields(thd, conds); if (*conds && !(*conds)->fixed && !res)
res= (*conds)->fix_fields(thd, conds);
} }
if (arena) if (arena)
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);
...@@ -3742,7 +3744,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, ...@@ -3742,7 +3744,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
} }
} }
DBUG_RETURN(FALSE); DBUG_RETURN(res);
} }
/** /**
......
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