summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@oracle.com>2013-02-28 14:52:47 +0100
committerJon Olav Hauglid <jon.hauglid@oracle.com>2013-02-28 14:52:47 +0100
commitd1c1981ba9e774106d99eba373eb79b9b5638f77 (patch)
treeb508be02e2c7da90edfbb11d10170ef2354a93c6 /sql/sql_handler.cc
parent7e0b6433955a829c2dc8ef7c1db9d203130292e9 (diff)
downloadmariadb-git-d1c1981ba9e774106d99eba373eb79b9b5638f77.tar.gz
Bug#16385711: HANDLER, CREATE TABLE IF NOT EXISTS,
PROBLEM AFTER MYSQL_HA_FIND This problem occured if a prepared statement tried to create a table for which there already existed a view with the same name while a SQL handler was opened. Before DDL statements are executed, mysql_ha_rm_tables() is called to remove any matching tables from the internal list of opened SQL handler tables. This match was done on TABLE_LIST::db and TABLE_LIST::table_name. This is problematic for views (which use TABLE_LIST::view_db and TABLE_LIST::view_name) and anonymous derived tables. This patch fixes the problem by skipping TABLE_LISTs representing anonymous derived tables and using get_db_name()/get_table_name() which handles views when looking for SQL handler tables to remove.
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index e7973850194..5c0a7ec184b 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -820,10 +820,15 @@ static TABLE_LIST *mysql_ha_find(THD *thd, TABLE_LIST *tables)
hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i);
for (tables= first; tables; tables= tables->next_local)
{
- if ((! *tables->db ||
- ! my_strcasecmp(&my_charset_latin1, hash_tables->db, tables->db)) &&
- ! my_strcasecmp(&my_charset_latin1, hash_tables->table_name,
- tables->table_name))
+ if (tables->is_anonymous_derived_table())
+ continue;
+ if ((! *tables->get_db_name() ||
+ ! my_strcasecmp(&my_charset_latin1,
+ hash_tables->get_db_name(),
+ tables->get_db_name())) &&
+ ! my_strcasecmp(&my_charset_latin1,
+ hash_tables->get_table_name(),
+ tables->get_table_name()))
break;
}
if (tables)