Bug #43138 DROP DATABASE failure does not clean up message list
Submitted: 24 Feb 2009 10:43 Modified: 12 Nov 2009 19:14
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:6.0-TRUNK OS:Any
Assigned to: Alexander Nozdrin CPU Architecture:Any

[24 Feb 2009 10:43] Alexander Nozdrin
Description:
This is a part of problems described in Bug#43012
(Bad error message handling in "drop database").

The problem is that if message (warning) list had
some elements, "DROP DATABASE" failure does not
clear them.

How to repeat:
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);

connection con1;
set autocommit=0;
create database try;
use try;
create table t3(id int) engine=falcon;
insert into t3 values(1),(2);

connection con2;

create database try;
ERROR HY000: Can't create database 'try'; database exists
show warnings;
Level	Code	Message
Error	1007	Can't create database 'try'; database exists

## Notice how the error message from a failing create database 
## is both reported as an error *and* shown in the warning list

drop database try;
ERROR 42S02: Unknown table 't3'
show warnings;
Level	Code	Message
Error	1007	Can't create database 'try'; database exists

## Notice that the error message from "create table" is still here, that 
## the error message seems wrong, and that the error message is not in
## the error list
[30 Apr 2009 15:31] 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/73199

2768 Alexander Nozdrin	2009-04-30
      Fix for Bug#43138: DROP DATABASE failure does not clean up message list.
      
      The problem was that the high-level function mysql_rm_db() invoked
      low-level mysql_rm_table_part2(), which reported low-level error
      (Unknown table) if SE refused to delete a table. Also when
      mysql_rm_table_part2() reported an error, it didn't add corresponding
      warning into the list (because it is used from other places where such
      behaviour is required).
      
      The fix is to
        1. Remove no_warnings_for_error usage from sql_table.cc
        2. Improve internal error handler support in THD, so that
           a stack of error handlers is allowed.
        3. Create an internal error handler (Drop_table_error_handler)
           to silence useless warnings.
        4. Use the handler in DROP DATABASE and DROP TABLE statements.
[30 Apr 2009 15:32] Alexander Nozdrin
The patch pushed into 6.0-runtime.
[1 May 2009 13:38] 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/73235

2771 Dmitry Lenev	2009-05-01
      Follow-up for fix for bug "Bug#43138: DROP DATABASE failure
      does not clean up message list".
      
      Fixed drop.test failure under non-debug server by moving part
      of test dependent on debug-only feature to separate .test file,
      which won't be run for non-debug versions of server.
[13 May 2009 20:56] 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/73979

2763 Sergei Golubchik	2009-05-13
      followup for bug#43138
      if delete fails with a permission denied error, we want to show it
[16 May 2009 8:41] Bugs System
Pushed into 6.0.12-alpha (revid:alik@sun.com-20090516083402-0avycdy7w6dnn0tv) (version source revid:serg@mysql.com-20090513180858-8n20oo3kc248e8p6) (merge vers: 6.0.12-alpha) (pib:6)
[21 May 2009 2:33] Paul DuBois
Noted in 6.0.12 changelog.

DROP DATABASE did not clear the message list.
[24 Aug 2009 17:56] Alexander Nozdrin
Bug#37431 has been marked as a duplicate of this one.
[22 Oct 2009 18:23] 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/87806

2892 Alexander Nozdrin	2009-10-22
      Backporting a patch for Bug#43138. That patch had been already backported
      to 5.1 partially. This patch brings what was left to mysql-next-mr.
      
      Original revisions in 6.0:
      ------------------------------------------------------------
      revno: 2617.31.26
      committer: Alexander Nozdrin <alik@sun.com>
      branch nick: 6.0-rt-bug43138.3
      timestamp: Thu 2009-04-30 19:31:30 +0400
      message:
        Fix for Bug#43138: DROP DATABASE failure does not clean up message list.
        
        The problem was that the high-level function mysql_rm_db() invoked
        low-level mysql_rm_table_part2(), which reported low-level error
        (Unknown table) if SE refused to delete a table. Also when
        mysql_rm_table_part2() reported an error, it didn't add corresponding
        warning into the list (because it is used from other places where such
        behaviour is required).
        
        The fix is to
          1. Remove no_warnings_for_error usage from sql_table.cc
          2. Improve internal error handler support in THD, so that
             a stack of error handlers is allowed.
          3. Create an internal error handler (Drop_table_error_handler)
             to silence useless warnings.
          4. Use the handler in DROP DATABASE and DROP TABLE statements.
      ------------------------------------------------------------
      revno: 2617.69.38
      committer: Alexander Nozdrin <alik@sun.com>
      branch nick: mysql-next-bugfixing-bug37431
      timestamp: Mon 2009-08-24 21:52:09 +0400
      message:
        A test case for Bug#37431 (DROP TABLE does not report errors correctly).
      ------------------------------------------------------------
      revno: 2617.31.29
      committer: Dmitry Lenev <dlenev@mysql.com>
      branch nick: mysql-6.0-runtime
      timestamp: Fri 2009-05-01 17:37:34 +0400
      message:
        Follow-up for fix for bug "Bug#43138: DROP DATABASE failure
        does not clean up message list".
        
        Fixed drop.test failure under non-debug server by moving part
        of test dependent on debug-only feature to separate .test file,
        which won't be run for non-debug versions of server.
      ------------------------------------------------------------
      revno: 2617.45.17
      committer: Sergei Golubchik <serg@mysql.com>
      branch nick: 6.0-maria
      timestamp: Wed 2009-05-13 20:08:58 +0200
      message:
        followup for bug#43138
        if delete fails with a permission denied error, we want to show it
      ------------------------------------------------------------
      
      The patch was backported to 5.1 in scope of Bug#42364 by
      the following revision:
      ------------------------------------------------------------
      revno: 2497.975.3
      committer: Sergey Glukhov <Sergey.Glukhov@sun.com>
      branch nick: mysql-5.1-bugteam
      timestamp: Fri 2009-07-03 13:22:06 +0500
      message:
        Bug#42364 SHOW ERRORS returns empty resultset after dropping non existent table
        enabled message storing into error message list
        for 'drop table' command
      ------------------------------------------------------------
[22 Oct 2009 19:32] 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/87817

2895 Alexander Nozdrin	2009-10-22
      Adding forgotten files for test case for Bug#43138.
[23 Oct 2009 6:48] Alexander Nozdrin
Pushed to 5.5.0 (mysql-next-mr-runtime).
[23 Oct 2009 15:06] Paul DuBois
Noted in 5.5.0 changelog.
[27 Oct 2009 8:55] 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/88261

2897 Alexander Nozdrin	2009-10-27
      Test postfix for Bug#43138 (DROP DATABASE failure does not
      clean up message list).
[3 Nov 2009 7:16] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091102151658-j9o4wgro47m5v84d) (version source revid:alik@sun.com-20091102151658-j9o4wgro47m5v84d) (merge vers: 6.0.14-alpha) (pib:13)
[3 Nov 2009 15:22] Paul DuBois
Already fixed in earlier 6.0.x release.
[12 Nov 2009 8:20] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091110093229-0bh5hix780cyeicl) (version source revid:mikael@mysql.com-20091103113702-p61dlwc6ml6fxg18) (merge vers: 5.5.0-beta) (pib:13)