Description:
When issuing DROP DATABASE IF EXISTS no_such_db, MySQL reports a warning. However, issuing SHOW WARNINGS immediately afterwards shows no warnings:
mysql> DROP DATABASE t;
ERROR 1008 (HY000): Can't drop database 't'; database doesn't exist
mysql> DROP DATABASE IF EXISTS t;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
Empty set (0.00 sec)
When the client is configured to automatically display warnings, the warning is displayed (both automatically, and in response to subsequent SHOW WARNINGS statement):
mysql> WARNINGS;
Show warnings enabled.
mysql> DROP DATABASE IF EXISTS t;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Note (Code 1008): Can't drop database 't'; database doesn't exist
mysql> SHOW WARNINGS;
+-------+------+-------------------------------------------------+
| Level | Code | Message |
+-------+------+-------------------------------------------------+
| Note | 1008 | Can't drop database 't'; database doesn't exist |
+-------+------+-------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.7-rc |
+-----------+
1 row in set (0.00 sec)
How to repeat:
* Issue DROP DATABASE IF EXISTS no_such_db;
* Try to view warnings via SHOW WARNINGS;
Suggested fix:
Don't clear warnings incorrectly.