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

bugfix: multi-UPDATE, vcols, const tables

multi-update was setting up read_set/vcol_set in
multi_update::initialize_tables() that is invoked after
the optimizer (JOIN::optimize_inner()). But some rows - if they're from
const tables - will be read already in the optimizer, and these rows
will not have all necessary column/vcol values.

* multi_update::initialize_tables() uses results from the optimizer
  and cannot be moved to be called earlier.
* multi_update::prepare() is called before the optimizer, but
  it cannot set up read_set/vcol_set, because the optimizer
  might reset them (see SELECT_LEX::update_used_tables()).

As a fix I've added a new method, select_result::prepare_to_read_rows(),
it's called from inside the optimizer just before make_join_statistics().
This commit is contained in:
Sergei Golubchik
2016-11-23 12:54:59 +01:00
parent 0e401bf7bf
commit aebb1038aa
8 changed files with 63 additions and 17 deletions

View File

@@ -1800,6 +1800,21 @@ void multi_update::update_used_tables()
}
}
void multi_update::prepare_to_read_rows()
{
/*
update column maps now. it cannot be done in ::prepare() before the
optimizer, because the optimize might reset them (in
SELECT_LEX::update_used_tables()), it cannot be done in
::initialize_tables() after the optimizer, because the optimizer
might read rows from const tables
*/
for (TABLE_LIST *tl= update_tables; tl; tl= tl->next_local)
tl->table->mark_columns_needed_for_update();
}
/*
Check if table is safe to update on fly
@@ -1916,12 +1931,10 @@ multi_update::initialize_tables(JOIN *join)
{
if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables))
{
table->mark_columns_needed_for_update();
table_to_update= table; // Update table on the fly
continue;
}
}
table->mark_columns_needed_for_update();
table->prepare_for_position();
/*