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.cc63
1 files changed, 16 insertions, 47 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 12cd999d130..52d5928ea1d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1094,13 +1094,20 @@ bool close_temporary_tables(THD *thd)
DBUG_RETURN(FALSE);
DBUG_ASSERT(!thd->rgi_slave);
+ /*
+ Ensure we don't have open HANDLERs for tables we are about to close.
+ This is necessary when close_temporary_tables() is called as part
+ of execution of BINLOG statement (e.g. for format description event).
+ */
+ mysql_ha_rm_temporary_tables(thd);
if (!mysql_bin_log.is_open())
{
TABLE *tmp_next;
- for (table= thd->temporary_tables; table; table= tmp_next)
+ for (TABLE *t= thd->temporary_tables; t; t= tmp_next)
{
- tmp_next= table->next;
- close_temporary(table, 1, 1);
+ tmp_next= t->next;
+ mysql_lock_remove(thd, thd->lock, t);
+ close_temporary(t, 1, 1);
}
thd->temporary_tables= 0;
DBUG_RETURN(FALSE);
@@ -1196,6 +1203,7 @@ bool close_temporary_tables(THD *thd)
strlen(table->s->table_name.str));
s_query.append(',');
next= table->next;
+ mysql_lock_remove(thd, thd->lock, table);
close_temporary(table, 1, 1);
}
thd->clear_error();
@@ -6415,6 +6423,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
*/
table_name && table_name[0] &&
(my_strcasecmp(table_alias_charset, table_list->alias, table_name) ||
+ (db_name && db_name[0] && (!table_list->db || !table_list->db[0])) ||
(db_name && db_name[0] && table_list->db && table_list->db[0] &&
(table_list->schema_table ?
my_strcasecmp(system_charset_info, db_name, table_list->db) :
@@ -6888,7 +6897,10 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
for (uint i= 0; (item=li++); i++)
{
- if (field_name && item->real_item()->type() == Item::FIELD_ITEM)
+ if (field_name &&
+ (item->real_item()->type() == Item::FIELD_ITEM ||
+ ((item->type() == Item::REF_ITEM) &&
+ (((Item_ref *)item)->ref_type() == Item_ref::VIEW_REF))))
{
Item_ident *item_field= (Item_ident*) item;
@@ -7014,35 +7026,6 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
break;
}
}
- else if (table_name && item->type() == Item::REF_ITEM &&
- ((Item_ref *)item)->ref_type() == Item_ref::VIEW_REF)
- {
- /*
- TODO:Here we process prefixed view references only. What we should
- really do is process all types of Item_refs. But this will currently
- lead to a clash with the way references to outer SELECTs (from the
- HAVING clause) are handled in e.g. :
- SELECT 1 FROM t1 AS t1_o GROUP BY a
- HAVING (SELECT t1_o.a FROM t1 AS t1_i GROUP BY t1_i.a LIMIT 1).
- Processing all Item_refs here will cause t1_o.a to resolve to itself.
- We still need to process the special case of Item_direct_view_ref
- because in the context of views they have the same meaning as
- Item_field for tables.
- */
- Item_ident *item_ref= (Item_ident *) item;
- if (field_name && item_ref->name && item_ref->table_name &&
- !my_strcasecmp(system_charset_info, item_ref->name, field_name) &&
- !my_strcasecmp(table_alias_charset, item_ref->table_name,
- table_name) &&
- (!db_name || (item_ref->db_name &&
- !strcmp (item_ref->db_name, db_name))))
- {
- found= li.ref();
- *counter= i;
- *resolution= RESOLVED_IGNORING_ALIAS;
- break;
- }
- }
}
if (!found)
{
@@ -7380,14 +7363,6 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
*/
result= FALSE;
- /*
- Save the lists made during natural join matching (because
- the matching done only once but we need the list in case
- of prepared statements).
- */
- table_ref_1->persistent_used_items= table_ref_1->used_items;
- table_ref_2->persistent_used_items= table_ref_2->used_items;
-
err:
if (arena)
thd->restore_active_arena(arena, &backup);
@@ -8434,11 +8409,6 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
}
}
#endif
- /*
- field_iterator.create_item() builds used_items which we
- have to save because changes made once and they are persistent
- */
- tables->persistent_used_items= tables->used_items;
if ((field= field_iterator.field()))
{
@@ -9075,7 +9045,6 @@ my_bool mysql_rm_tmp_tables(void)
my_dirend(dirp);
}
delete thd;
- set_current_thd(0);
DBUG_RETURN(0);
}