1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

fixed mechanism of detection selection from table wich we update

(BUG##9398, BUG#8703)
fixed wrong join view detection in multi-delete which lead to server crash


mysql-test/r/lowercase_view.result:
  added new tests of updation and selection from the same table
mysql-test/r/view.result:
  added new tests of updation and selection from the same table
  added test of multidelete command over join view which lead to server crash
  test suite from bugs #9398 and #8703
mysql-test/t/lowercase_view.test:
  added new tests of updation and selection from the same table
mysql-test/t/view.test:
  added new tests of updation and selection from the same table
  added test of multidelete command over join view which lead to server crash
  test suite from bugs #9398 and #8703
sql/sql_base.cc:
  changed procedure of finding tables
sql/sql_class.cc:
  added derived table procession detection
sql/sql_class.h:
  added derived table procession detection
sql/sql_delete.cc:
  fixed detection of selection from table which update for multidelete
sql/sql_derived.cc:
  added derived table procession detection
sql/sql_lex.cc:
  added detection os SELECTs processed inside derived tables
  removed old mechanism of multidelete/multiupdate table duplication detection (which can't work with views)
sql/sql_lex.h:
  added detection os SELECTs processed inside derived tables
  removed old mechanism of multidelete/multiupdate table duplication detection (which can't work with views)
sql/sql_parse.cc:
  removed wrong test of join view (for multidelete in can be not only first table)
sql/sql_prepare.cc:
  added detection os SELECTs processed inside derived tables (reset it for reusing in PS/SP)
sql/sql_select.cc:
  added detection os SELECTs processed inside derived tables
sql/sql_update.cc:
  fixed detection of selection from table which update for multiupdate
This commit is contained in:
unknown
2005-03-28 15:13:31 +03:00
parent 7ff83a3f7f
commit daddf263e5
15 changed files with 561 additions and 165 deletions

View File

@@ -356,12 +356,28 @@ bool mysql_multi_delete_prepare(THD *thd)
&lex->select_lex.leaf_tables, FALSE, FALSE))
DBUG_RETURN(TRUE);
/*
Multi-delete can't be constructed over-union => we always have
single SELECT on top and have to check underlying SELECTs of it
*/
lex->select_lex.exclude_from_table_unique_test= TRUE;
/* Fix tables-to-be-deleted-from list to point at opened tables */
for (target_tbl= (TABLE_LIST*) aux_tables;
target_tbl;
target_tbl= target_tbl->next_local)
{
target_tbl->table= target_tbl->correspondent_table->table;
if (!(target_tbl->table= target_tbl->correspondent_table->table))
{
DBUG_ASSERT(target_tbl->correspondent_table->view &&
target_tbl->correspondent_table->ancestor &&
target_tbl->correspondent_table->ancestor->next_local);
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
target_tbl->correspondent_table->view_db.str,
target_tbl->correspondent_table->view_name.str);
DBUG_RETURN(TRUE);
}
if (!target_tbl->correspondent_table->updatable ||
check_key_in_view(thd, target_tbl->correspondent_table))
{
@@ -370,23 +386,14 @@ bool mysql_multi_delete_prepare(THD *thd)
DBUG_RETURN(TRUE);
}
/*
Check are deleted table used somewhere inside subqueries.
Multi-delete can't be constructed over-union => we always have
single SELECT on top and have to check underlying SELECTs of it
Check that table from which we delete is not used somewhere
inside subqueries/view.
*/
for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit();
un;
un= un->next_unit())
if (unique_table(target_tbl->correspondent_table, lex->query_tables))
{
if (un->first_select()->linkage != DERIVED_TABLE_TYPE &&
un->check_updateable(target_tbl->correspondent_table->db,
target_tbl->correspondent_table->table_name))
{
my_error(ER_UPDATE_TABLE_USED, MYF(0),
target_tbl->correspondent_table->table_name);
DBUG_RETURN(TRUE);
}
my_error(ER_UPDATE_TABLE_USED, MYF(0),
target_tbl->correspondent_table->table_name);
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);