1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Merged 5.3 changes into the mwl #248 tree.

This commit is contained in:
Igor Babaev
2012-03-09 19:04:59 -08:00
255 changed files with 8334 additions and 1951 deletions

View File

@ -1707,11 +1707,12 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
t_name= table->table_name;
t_alias= table->alias;
retry:
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
for (;;)
for (TABLE_LIST *tl= table_list;;)
{
if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) &&
(! (res= mysql_lock_have_duplicate(thd, table, table_list)))) ||
if (((! (res= find_table_in_global_list(tl, d_name, t_name))) &&
(! (res= mysql_lock_have_duplicate(thd, table, tl)))) ||
((!res->table || res->table != table->table) &&
(!check_alias || !(lower_case_table_names ?
my_strcasecmp(files_charset_info, t_alias, res->alias) :
@ -1724,10 +1725,23 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
processed in derived table or top select of multi-update/multi-delete
(exclude_from_table_unique_test) or prelocking placeholder.
*/
table_list= res->next_global;
tl= res->next_global;
DBUG_PRINT("info",
("found same copy of table or table which we should skip"));
}
if (res && res->belong_to_derived)
{
/* Try to fix */
TABLE_LIST *derived= res->belong_to_derived;
if (derived->is_merged_derived())
{
DBUG_PRINT("info",
("convert merged to materialization to resolve the conflict"));
derived->change_refs_to_fields();
derived->set_materialized_derived();
}
goto retry;
}
DBUG_RETURN(res);
}
@ -2971,7 +2985,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
}
error= open_unireg_entry(thd, table, table_list, alias, key, key_length,
mem_root, (flags & OPEN_VIEW_NO_PARSE));
mem_root,
(flags & (OPEN_VIEW_NO_PARSE |
MYSQL_LOCK_IGNORE_FLUSH)));
if (error > 0)
{
my_free((uchar*)table, MYF(0));
@ -4060,8 +4076,11 @@ retry:
HA_GET_INDEX | HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD |
(flags & OPEN_VIEW_NO_PARSE),
thd->open_options, entry, table_list,
mem_root);
thd->open_options |
(thd->version == 0 &&
(flags & MYSQL_LOCK_IGNORE_FLUSH) ?
HA_OPEN_FOR_STATUS : 0),
entry, table_list, mem_root);
if (error)
goto err;
/* TODO: Don't free this */
@ -4099,7 +4118,11 @@ retry:
HA_TRY_READ_ONLY),
(READ_KEYINFO | COMPUTE_TYPES |
EXTRA_RECORD),
thd->open_options, entry, FALSE)))
thd->open_options |
(thd->version == 0 &&
(flags & MYSQL_LOCK_IGNORE_FLUSH) ?
HA_OPEN_FOR_STATUS : 0),
entry, FALSE)))
{
if (error == 7) // Table def changed
{
@ -7204,11 +7227,16 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
if (!(eq_cond= new Item_func_eq(item_ident_1, item_ident_2)))
goto err; /* Out of memory. */
if (field_1 && field_1->vcol_info)
field_1->table->mark_virtual_col(field_1);
if (field_2 && field_2->vcol_info)
field_2->table->mark_virtual_col(field_2);
/*
Add the new equi-join condition to the ON clause. Notice that
fix_fields() is applied to all ON conditions in setup_conds()
so we don't do it here.
*/
*/
add_join_on((table_ref_1->outer_join & JOIN_TYPE_RIGHT ?
table_ref_1 : table_ref_2),
eq_cond);
@ -7929,7 +7957,8 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
while ((table_list= ti++))
{
TABLE *table= table_list->table;
table->pos_in_table_list= table_list;
if (table)
table->pos_in_table_list= table_list;
if (first_select_table &&
table_list->top_table() == first_select_table)
{
@ -7942,7 +7971,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
{
table_list->jtbm_table_no= tablenr;
}
else
else if (table)
{
table->pos_in_table_list= table_list;
setup_table_map(table, table_list, tablenr);
@ -9659,13 +9688,12 @@ open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
else
{
/*
If error in mysql_lock_tables(), open_ltable doesn't close the
table. Thread kill during mysql_lock_tables() is such error. But
open tables cannot be accepted when restoring the open tables
state.
This can happen during a thd->kill or while we are trying to log
data for a stored procedure/trigger and someone causes the table
to be flushed (for example by creating a new trigger for the
table)
*/
if (thd->killed)
close_thread_tables(thd);
close_thread_tables(thd);
thd->restore_backup_open_tables_state(backup);
}