1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#25122: Views based on a self-joined table aren't insertable.

When INSERT is done over a view the table being inserted into is 
checked to be unique among all views tables. But if the view contains
self-joined table an error will be thrown even if all tables are used under
different aliases.

The unique_table() function now also checks tables' aliases when needed.
This commit is contained in:
evgen@moonbone.local
2007-03-02 00:09:22 +03:00
parent 8f52c5b207
commit 11588e5e4a
7 changed files with 19 additions and 13 deletions

View File

@ -1044,7 +1044,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
{
Item *fake_conds= 0;
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, table_list, table_list->next_global)))
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 1)))
{
update_non_unique_table_error(table_list, "INSERT", duplicate);
DBUG_RETURN(TRUE);
@ -2424,7 +2424,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
query
*/
if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
unique_table(thd, table_list, table_list->next_global))
unique_table(thd, table_list, table_list->next_global, 0))
{
/* Using same table for INSERT and SELECT */
lex->current_select->options|= OPTION_BUFFER_RESULT;