summaryrefslogtreecommitdiff
path: root/mysql-test/t/temp_table.test
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-06-23 13:34:40 +0200
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-06-23 13:34:40 +0200
commita1c6a39a1320ec2cb1ec816543873513a97ee0a5 (patch)
tree65e8c411add29a22d287df643b53cc6df44fe7f3 /mysql-test/t/temp_table.test
parent429454f76ecfbc107fafeb25a33ef4d90f221fc0 (diff)
downloadmariadb-git-a1c6a39a1320ec2cb1ec816543873513a97ee0a5.tar.gz
Backport from mysql-6.0-codebase of:
------------------------------------------------------------ revno: 3672 committer: lars-erik.bjork@sun.com branch nick: 48067-mysql-6.0-codebase-bugfixing timestamp: Mon 2009-10-26 13:51:43 +0100 message: This is a patch for bug#48067 "A temp table with the same name as an existing table, makes drop database fail" When dropping the database, mysql_rm_known_files() reads the contents of the database directory, and creates a TABLE_LIST object, for each .frm file encountered. Temporary tables, however, are not associated with any .frm file. The list of tables to drop are passed to mysql_rm_table_part2(). This method prefers temporary tables over regular tables, so if there is a temporary table with the same name as a regular, the temporary is removed, leaving the regular table intact. Regular tables are only deleted if there are no temporary tables with the same name. This fix ensures, that for all TABLE_LIST objects that are created by mysql_rm_known_files(), 'open_type' is set to 'OT_BASE_ONLY', to indicate that this is a regular table. In all cases in mysql_rm_table_part2() where we prefer a temporary table to a non-temporary table, we chek if 'open_type' equals 'OT_BASE_ONLY'. mysql-test/r/temp_table.result: The expected result of the test. mysql-test/t/temp_table.test: Test based on the bug report. sql/sql_db.cc: For all TABLE_LIST objects that are created by mysql_rm_known_files(), 'open_type' is set to 'OT_BASE_ONLY', to indicate that these are regular tables. sql/sql_table.cc: Check if 'open_type' is set to 'OT_BASE_ONLY, every place a temporary table is preferred to a non-temporary table.
Diffstat (limited to 'mysql-test/t/temp_table.test')
-rw-r--r--mysql-test/t/temp_table.test15
1 files changed, 15 insertions, 0 deletions
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 2bfa4936c91..92c22242cdb 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -235,4 +235,19 @@ INSERT INTO t2 SELECT f1();
DROP TABLE t1,t2,t3;
DROP FUNCTION f1;
+--echo #
+--echo # Bug #48067: A temp table with the same name as an existing table,
+--echo # makes drop database fail.
+--echo #
+--disable_warnings
+DROP TEMPORARY TABLE IF EXISTS bug48067.t1;
+DROP DATABASE IF EXISTS bug48067;
+--enable_warnings
+CREATE DATABASE bug48067;
+CREATE TABLE bug48067.t1 (c1 int);
+INSERT INTO bug48067.t1 values (1);
+CREATE TEMPORARY TABLE bug48067.t1 (c1 int);
+DROP DATABASE bug48067;
+DROP TEMPORARY table bug48067.t1;
+
--echo End of 5.1 tests