summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc75
1 files changed, 52 insertions, 23 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index c42551100ae..3e27355cc26 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -62,7 +62,7 @@ private:
bool
Prelock_error_handler::handle_error(uint sql_errno,
const char * /* message */,
- MYSQL_ERROR::enum_warning_level /* level */,
+ MYSQL_ERROR::enum_warning_level level,
THD * /* thd */)
{
if (sql_errno == ER_NO_SUCH_TABLE)
@@ -71,7 +71,8 @@ Prelock_error_handler::handle_error(uint sql_errno,
return TRUE;
}
- m_unhandled_errors++;
+ if (level == MYSQL_ERROR::WARN_LEVEL_ERROR)
+ m_unhandled_errors++;
return FALSE;
}
@@ -675,7 +676,7 @@ void close_handle_and_leave_table_as_lock(TABLE *table)
*/
if (table->child_l || table->parent)
detach_merge_children(table, FALSE);
- table->file->close();
+ table->file->ha_close();
table->db_stat= 0; // Mark file closed
release_table_share(table->s, RELEASE_NORMAL);
table->s= share;
@@ -3708,7 +3709,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name)
if (table->db_stat)
{
table->db_stat= 0;
- table->file->close();
+ table->file->ha_close();
}
}
else
@@ -5861,10 +5862,15 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
*/
if (*ref && !(*ref)->is_autogenerated_name)
{
+ if (register_tree_change &&
+ thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())
+ arena= thd->activate_stmt_arena_if_needed(&backup);
item->set_name((*ref)->name, (*ref)->name_length,
system_charset_info);
item->real_item()->set_name((*ref)->name, (*ref)->name_length,
system_charset_info);
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
}
if (register_tree_change)
thd->change_item_tree(ref, item);
@@ -6441,19 +6447,28 @@ find_field_in_tables(THD *thd, Item_ident *item,
{
SELECT_LEX *current_sel= thd->lex->current_select;
SELECT_LEX *last_select= table_ref->select_lex;
+ bool all_merged= TRUE;
+ for (SELECT_LEX *sl= current_sel; sl && sl!=last_select;
+ sl=sl->outer_select())
+ {
+ Item *subs= sl->master_unit()->item;
+ if (subs->type() == Item::SUBSELECT_ITEM &&
+ ((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&
+ ((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN))
+ {
+ continue;
+ }
+ all_merged= FALSE;
+ break;
+ }
/*
If the field was an outer referencee, mark all selects using this
sub query as dependent on the outer query
*/
- if (current_sel != last_select)
+ if (!all_merged && current_sel != last_select)
{
mark_select_range_as_dependent(thd, last_select, current_sel,
found, *ref, item);
- if (item->can_be_depended)
- {
- DBUG_ASSERT((*ref) == (Item*)item);
- current_sel->register_dependency_item(last_select, ref);
- }
}
}
return found;
@@ -7789,9 +7804,18 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
if (select_lex->first_cond_optimization)
{
leaves.empty();
- select_lex->leaf_tables_exec.empty();
- make_leaves_list(leaves, tables, full_table_list, first_select_table);
-
+ if (!select_lex->is_prep_leaf_list_saved)
+ {
+ make_leaves_list(leaves, tables, full_table_list, first_select_table);
+ select_lex->leaf_tables_exec.empty();
+ }
+ else
+ {
+ List_iterator_fast <TABLE_LIST> ti(select_lex->leaf_tables_prep);
+ while ((table_list= ti++))
+ leaves.push_back(table_list);
+ }
+
while ((table_list= ti++))
{
TABLE *table= table_list->table;
@@ -7830,9 +7854,17 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
select_lex->leaf_tables.empty();
while ((table_list= ti++))
{
- table_list->table->tablenr= table_list->tablenr_exec;
- table_list->table->map= table_list->map_exec;
- table_list->table->pos_in_table_list= table_list;
+ if(table_list->jtbm_subselect)
+ {
+ table_list->jtbm_table_no= table_list->tablenr_exec;
+ }
+ else
+ {
+ table_list->table->tablenr= table_list->tablenr_exec;
+ table_list->table->map= table_list->map_exec;
+ table_list->table->maybe_null= table_list->maybe_null_exec;
+ table_list->table->pos_in_table_list= table_list;
+ }
select_lex->leaf_tables.push_back(table_list);
}
}
@@ -8259,7 +8291,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
SELECT_LEX *select_lex= thd->lex->current_select;
Query_arena *arena= thd->stmt_arena, backup;
TABLE_LIST *table= NULL; // For HP compilers
- TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
List_iterator<TABLE_LIST> ti(leaves);
/*
it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX
@@ -8300,7 +8331,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
goto err_no_arena;
}
- thd->thd_marker.emb_on_expr_nest= NO_JOIN_NEST;
if (*conds)
{
thd->where="where clause";
@@ -8314,11 +8344,11 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
*/
if ((*conds)->type() == Item::FIELD_ITEM && !derived)
wrap_ident(thd, conds);
+ (*conds)->mark_as_condition_AND_part(NO_JOIN_NEST);
if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
(*conds)->check_cols(1))
goto err_no_arena;
}
- thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest;
/*
Apply fix_fields() to all ON clauses at all levels of nesting,
@@ -8334,8 +8364,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
if (embedded->on_expr)
{
/* Make a join an a expression */
- thd->thd_marker.emb_on_expr_nest= embedded;
thd->where="on clause";
+ embedded->on_expr->mark_as_condition_AND_part(embedded);
if ((!embedded->on_expr->fixed &&
embedded->on_expr->fix_fields(thd, &embedded->on_expr)) ||
embedded->on_expr->check_cols(1))
@@ -8359,7 +8389,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
}
}
}
- thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest;
if (!thd->stmt_arena->is_conventional())
{
@@ -8881,7 +8910,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
{
if (!in_use->killed)
{
- in_use->killed= THD::KILL_CONNECTION;
+ in_use->killed= KILL_SYSTEM_THREAD;
pthread_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{
@@ -9215,7 +9244,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
! in_use->killed)
{
- in_use->killed= THD::KILL_CONNECTION;
+ in_use->killed= KILL_SYSTEM_THREAD;
pthread_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{