Bug #26704 Failing DROP DATABASE brings mysql-client out of sync
Submitted: 27 Feb 2007 23:41 Modified: 12 Nov 2009 18:59
Reporter: Jan Kneschke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1.12/5.1BK OS:Linux (linux)
Assigned to: Alexander Nozdrin CPU Architecture:Any
Tags: Contribution

[27 Feb 2007 23:41] Jan Kneschke
Description:
This bug is follow up of bug #26703 where the DROP DATABASE fails on mysql50 legacy tables with backticks.

If DROP DATABASE fails, the connection is loosing the selected database, but the client still shows the old database as selected.

How to repeat:
root@localhost [(none)]> create database t1;
Query OK, 1 row affected (0.00 sec)

root@localhost [(none)]> use t1;
Database changed
root@localhost [t1]> create table `#mysql50#abc``def` ( id int );
Query OK, 0 rows affected (0.08 sec)

root@localhost [t1]> drop database t1;
ERROR 1010 (HY000): Error dropping database (can't rmdir './t1', errno: 39)
root@localhost [t1]> drop table `#mysql50#abc``def`;
ERROR 1046 (3D000): No database selected
root@localhost [t1]> use t1;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@localhost [t1]> drop table `#mysql50#abc``def`;
Query OK, 0 rows affected (0.00 sec)

root@localhost [t1]> drop database t1;
Query OK, 0 rows affected (0.00 sec)

Suggested fix:
Either keep the database as selected (it still exists) or make the client show (none) for the db-name.
[28 Feb 2007 0:00] MySQL Verification Team
Thank you for the bug report. Verified as described.
[1 Nov 2007 10:37] Sergei Golubchik
patch: http://lists.mysql.com/internals/35145
[20 Feb 2008 1:26] Jim Winstead
This is actually a server problem, as the proposed patch shows. Re-opening so a complete patch (with test case) will get done.
[28 Mar 2008 20:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44620

ChangeSet@1.2579, 2008-03-28 23:02:36+03:00, anozdrin@quad.opbmk +3 -0
  A fix for Bug#26704: Failing DROP DATABASE brings
  mysql-client out of sync.
  
  The problem was that we changed current database w/o caring
  whether it was dropped successfully or not.
  
  The fix is not to change current database if we failed to drop it.
[19 May 2008 11:51] Konstantin Osipov
Push into 6.0 please.
[29 May 2008 17:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/47215
[30 May 2008 5:38] Alexander Nozdrin
Pushed into 6.0-runtime.
[1 Dec 2008 10:24] Alexander Nozdrin
Pushed into 6.0.5.
[1 Dec 2008 16:33] Paul Dubois
Noted in 6.0.5 changelog.

The default database is no longer changed to NULL ("no database") if
DROP DATABASE for that database failed.
[9 Oct 2009 14:58] Alexander Nozdrin
Pushed into 5.5.0.
[12 Oct 2009 15:10] Paul Dubois
Noted in 5.5.0 changelog.
[31 Oct 2009 8:18] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091031081410-qkxmjsdzjmj840aq) (version source revid:guilhem@mysql.com-20091010123356-qfouds7ucvkvbczt) (merge vers: 6.0.14-alpha) (pib:13)
[12 Nov 2009 8:16] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091110093229-0bh5hix780cyeicl) (version source revid:mikael@mysql.com-20091102100915-a2nbfxaqprpgptfw) (merge vers: 5.5.0-beta) (pib:13)