mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
5.5 merge
This commit is contained in:
@ -255,6 +255,7 @@ static void check_unused(THD *thd)
|
||||
uint count= 0, open_files= 0, idx= 0;
|
||||
TABLE *cur_link, *start_link, *entry;
|
||||
TABLE_SHARE *share;
|
||||
DBUG_ENTER("check_unused");
|
||||
|
||||
if ((start_link=cur_link=unused_tables))
|
||||
{
|
||||
@ -263,7 +264,7 @@ static void check_unused(THD *thd)
|
||||
if (cur_link != cur_link->next->prev || cur_link != cur_link->prev->next)
|
||||
{
|
||||
DBUG_PRINT("error",("Unused_links aren't linked properly")); /* purecov: inspected */
|
||||
return; /* purecov: inspected */
|
||||
DBUG_VOID_RETURN; /* purecov: inspected */
|
||||
}
|
||||
} while (count++ < table_cache_count &&
|
||||
(cur_link=cur_link->next) != start_link);
|
||||
@ -311,6 +312,7 @@ static void check_unused(THD *thd)
|
||||
DBUG_PRINT("error",("Unused_links doesn't match open_cache: diff: %d", /* purecov: inspected */
|
||||
count)); /* purecov: inspected */
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#else
|
||||
#define check_unused(A)
|
||||
@ -3038,6 +3040,7 @@ retry_share:
|
||||
MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);
|
||||
bool wait_result;
|
||||
|
||||
DBUG_PRINT("info", ("old version of table share found"));
|
||||
release_table_share(share);
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
|
||||
@ -3062,6 +3065,7 @@ retry_share:
|
||||
and try to reopen them. Note: refresh_version is currently
|
||||
changed only during FLUSH TABLES.
|
||||
*/
|
||||
DBUG_PRINT("info", ("share version differs between tables"));
|
||||
release_table_share(share);
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
(void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES,
|
||||
@ -3075,6 +3079,7 @@ retry_share:
|
||||
table= share->free_tables.front();
|
||||
table_def_use_table(thd, table);
|
||||
/* Release the share as we hold an extra reference to it */
|
||||
DBUG_PRINT("info", ("release temporarily acquired table share"));
|
||||
release_table_share(share);
|
||||
}
|
||||
else
|
||||
@ -3153,6 +3158,7 @@ err_lock:
|
||||
release_table_share(share);
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
|
||||
DBUG_PRINT("exit", ("failed"));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
@ -6907,7 +6913,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
|
||||
*/
|
||||
if (db)
|
||||
return cur_field;
|
||||
|
||||
|
||||
if (found)
|
||||
{
|
||||
if (report_error == REPORT_ALL_ERRORS ||
|
||||
@ -6922,7 +6928,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
|
||||
|
||||
if (found)
|
||||
return found;
|
||||
|
||||
|
||||
/*
|
||||
If the field was qualified and there were no tables to search, issue
|
||||
an error that an unknown table was given. The situation is detected
|
||||
@ -7849,10 +7855,16 @@ err:
|
||||
order, thus when we iterate over it, we are moving from the right
|
||||
to the left in the FROM clause.
|
||||
|
||||
NOTES
|
||||
We can't run this many times as the first_name_resolution_table would
|
||||
be different for subsequent runs when sub queries has been optimized
|
||||
away.
|
||||
|
||||
RETURN
|
||||
TRUE Error
|
||||
FALSE OK
|
||||
*/
|
||||
|
||||
static bool setup_natural_join_row_types(THD *thd,
|
||||
List<TABLE_LIST> *from_clause,
|
||||
Name_resolution_context *context)
|
||||
@ -7862,6 +7874,19 @@ static bool setup_natural_join_row_types(THD *thd,
|
||||
if (from_clause->elements == 0)
|
||||
DBUG_RETURN(false); /* We come here in the case of UNIONs. */
|
||||
|
||||
/*
|
||||
Do not redo work if already done:
|
||||
1) for stored procedures,
|
||||
2) for multitable update after lock failure and table reopening.
|
||||
*/
|
||||
if (!context->select_lex->first_natural_join_processing)
|
||||
{
|
||||
context->first_name_resolution_table= context->natural_join_first_table;
|
||||
DBUG_PRINT("info", ("using cached setup_natural_join_row_types"));
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
context->select_lex->first_natural_join_processing= false;
|
||||
|
||||
List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);
|
||||
TABLE_LIST *table_ref; /* Current table reference. */
|
||||
/* Table reference to the left of the current. */
|
||||
@ -7878,22 +7903,15 @@ static bool setup_natural_join_row_types(THD *thd,
|
||||
left_neighbor= table_ref_it++;
|
||||
}
|
||||
while (left_neighbor && left_neighbor->sj_subq_pred);
|
||||
/*
|
||||
Do not redo work if already done:
|
||||
1) for stored procedures,
|
||||
2) for multitable update after lock failure and table reopening.
|
||||
*/
|
||||
if (context->select_lex->first_natural_join_processing)
|
||||
|
||||
if (store_top_level_join_columns(thd, table_ref,
|
||||
left_neighbor, right_neighbor))
|
||||
DBUG_RETURN(true);
|
||||
if (left_neighbor)
|
||||
{
|
||||
if (store_top_level_join_columns(thd, table_ref,
|
||||
left_neighbor, right_neighbor))
|
||||
DBUG_RETURN(true);
|
||||
if (left_neighbor)
|
||||
{
|
||||
TABLE_LIST *first_leaf_on_the_right;
|
||||
first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();
|
||||
left_neighbor->next_name_resolution_table= first_leaf_on_the_right;
|
||||
}
|
||||
TABLE_LIST *first_leaf_on_the_right;
|
||||
first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();
|
||||
left_neighbor->next_name_resolution_table= first_leaf_on_the_right;
|
||||
}
|
||||
right_neighbor= table_ref;
|
||||
}
|
||||
@ -7907,8 +7925,11 @@ static bool setup_natural_join_row_types(THD *thd,
|
||||
DBUG_ASSERT(right_neighbor);
|
||||
context->first_name_resolution_table=
|
||||
right_neighbor->first_leaf_for_name_resolution();
|
||||
context->select_lex->first_natural_join_processing= false;
|
||||
|
||||
/*
|
||||
This is only to ensure that first_name_resolution_table doesn't
|
||||
change on re-execution
|
||||
*/
|
||||
context->natural_join_first_table= context->first_name_resolution_table;
|
||||
DBUG_RETURN (false);
|
||||
}
|
||||
|
||||
@ -8254,12 +8275,9 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
|
||||
if (table_list->merge_underlying_list)
|
||||
{
|
||||
DBUG_ASSERT(table_list->is_merged_derived());
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
Query_arena *arena, backup;
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
bool res;
|
||||
if (arena->is_conventional())
|
||||
arena= 0; // For easier test
|
||||
else
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
res= table_list->setup_underlying(thd);
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
@ -8510,7 +8528,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
||||
|
||||
if (!(item= field_iterator.create_item(thd)))
|
||||
DBUG_RETURN(TRUE);
|
||||
// DBUG_ASSERT(item->fixed);
|
||||
|
||||
/* cache the table for the Item_fields inserted by expanding stars */
|
||||
if (item->type() == Item::FIELD_ITEM && tables->cacheable_table)
|
||||
((Item_field *)item)->cached_table= tables;
|
||||
@ -8638,11 +8656,8 @@ void wrap_ident(THD *thd, Item **conds)
|
||||
{
|
||||
Item_direct_ref_to_ident *wrapper;
|
||||
DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM);
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
if (arena->is_conventional())
|
||||
arena= 0;
|
||||
else
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
Query_arena *arena, backup;
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
if ((wrapper= new Item_direct_ref_to_ident((Item_ident *)(*conds))))
|
||||
(*conds)= (Item*) wrapper;
|
||||
if (arena)
|
||||
|
Reference in New Issue
Block a user