Bug #50319 Drop database fails if temporary table has same name as other table in the db
Submitted: 14 Jan 2010 0:45 Modified: 14 Jan 2010 7:53
Reporter: Hema Sridharan Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.0 OS:Any
Assigned to: CPU Architecture:Any

[14 Jan 2010 0:45] Hema Sridharan
Description:
Create database db1 and table t1 in db1
Create temporary table t1(same name as already existing table t1)
Insert some data contents in both table t1 and temp table t1
Drop the database db1. This will fail due to presence of temp table t1.
An alternative to this is drop table t1 and then drop the database. Drop db will pass this time.

How to repeat:
Here is the test case for this,

CREATE DATABASE db1;
USE db1;
CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES(1),(2);
CREATE TEMPORARY TABLE t1(id INT);
INSERT INTO t1 VALUES(3);
--error ER_DB_DROP_RMDIR
DROP DATABASE db1; # This will fail

#Now drop the table and then drop database,

DROP TABLE t1;
DROP DATABASE db1;

The result file is,
------------------
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES(1),(2);
CREATE TEMPORARY TABLE t1(id INT);
INSERT INTO t1 VALUES(3);
DROP DATABASE db1;
ERROR HY000: Error dropping database (can't rmdir './db1', errno: 39)
DROP TABLE t1;
DROP DATABASE db1;

If you notice, test does not pass when DROP DATABASE is used at first instant. Only after using DROP TABLE, the DROP DATABASE passes.
[14 Jan 2010 7:53] Valeriy Kravchuk
This is a duplicate of bug #48067.