Hello Jon Olav!
* Jon Olav Hauglid <jon.hauglid@stripped> [10/09/27 19:38]:
> #At file:///export/home/x/mysql-5.5-runtime-bug51099/ based on
> revid:jon.hauglid@stripped
>
> 3146 Jon Olav Hauglid 2010-09-27
> Bug #51099 Assertion in mysql_multi_delete_prepare()
>
> This assert was triggered if DELETE was done on a view that
> referenced another view which in turn (directly or indirectly)
> referenced more than one table.
>
> Delete from a view referencing more than one table (a join view)
> is not supported and is supposed to give ER_VIEW_DELETE_MERGE_VIEW
> error. Before this error was reported from the multi table
> delete code, an assert verified that the view from the DELETE statement
> had more than one underlying table. However, this assert did not take
> into account that the view could refer to another view which in turn
> referenced the actual tables.
>
> This patch fixes the problem by adjusting the assert to only verify
> that we are trying to insert into a view, rather than also try to verify
> there are more than one underlying table.
>
> This problem was only noticeable on debug builds of the server.
> On release builds, ER_VIEW_DELETE_MERGE_VIEW was correctly reported.
...
> === modified file 'sql/sql_delete.cc'
> --- a/sql/sql_delete.cc 2010-07-28 11:17:19 +0000
> +++ b/sql/sql_delete.cc 2010-09-27 15:25:26 +0000
> @@ -524,10 +524,7 @@ int mysql_multi_delete_prepare(THD *thd)
> {
> if (!(target_tbl->table= target_tbl->correspondent_table->table))
> {
> - DBUG_ASSERT(target_tbl->correspondent_table->view &&
> - target_tbl->correspondent_table->merge_underlying_list
> &&
> - target_tbl->correspondent_table->merge_underlying_list->
> - next_local);
> + DBUG_ASSERT(target_tbl->correspondent_table->view);
Maybe it makes sense to preserve original intent behind the assert by
adjusting it in the following way:
DBUG_ASSERT(target_tbl->correspondent_table->view &&
target_tbl->correspondent_table->multitable_view);
What do you think?
> my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
> target_tbl->correspondent_table->view_db.str,
> target_tbl->correspondent_table->view_name.str);
>
I think it is OK to push this fix after considering the above suggestion.
--
Dmitry Lenev, Software Developer
Oracle Development SPB/MySQL, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification