Bug #63562 unknown database information_schema
Submitted: 3 Dec 2011 14:03 Modified: 25 Jul 2012 19:07
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.1.60, 5.5.18 OS:Any
Assigned to: CPU Architecture:Any

[3 Dec 2011 14:03] Peter Laursen
Description:
Just a few more entries to be added to the long list of non-good and inconsistent error messages in MySQL! 

I had swithced the database context from a user database to I_S, left the seat for a coffe-break. When I came back I had forgotten about the changed context and bumped into 1) below ("Unknown database 'information_schema'").  

Then I also compared with would happen when creating a table and with behaviour of same in P_S.

How to repeat:
DELIMITER $$

-- 1
CREATE PROCEDURE `information_schema`.`is`()
    BEGIN
	-- let us see what happens here
    END$$
/*
Error Code: 1049
Unknown database 'information_schema'
*/

-- 2
CREATE PROCEDURE `performance_schema`.`ps`()
    BEGIN
	-- let us see what happens here
    END$$
/*
Error Code: 1044
Access denied for user 'root'@'localhost' to database 'performance_schema'
*/

DELIMITER ;

-- 3
CREATE TABLE `information_schema`.`IS` (id INT);
/*
Error Code: 1044
Access denied for user 'root'@'localhost' to database 'information_schema'
*/

-- 4
CREATE TABLE `performance_schema`.`ps` (id INT);
/*
Error Code: 1142
CREATE command denied to user 'root'@'localhost' for table 'ps'
*/

Suggested fix:
1) is not just funny! In the beginning I thought that I_S had corrupted somewhow (creating a routine will INSERT a row to I_S.ROUTINES) and did not realize that a SP was attempted created in I_S itself. 

2) +3 ) are unprecise because root *does* have access to both P_S and I_S (but not *any kind of access* - not access to CREATE objects for instance).

4) is better. But "for table 'ps'" could/should be omitted here though as the restriction is not specific for this particular table).
[3 Dec 2011 15:26] Valeriy Kravchuk
I agree that 1) is something to fix. We have it in 5.1.x also:

macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.60 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create procedure information_schema.is() select 1;      
ERROR 1049 (42000): Unknown database 'information_schema'

For cases 2) and 3) also some improvement is possible. In 5.1.x we have even less clear message: 

mysql> create table information_schema.t(c2 int);
ERROR 1109 (42S02): Unknown table 't' in information_schema
[3 Dec 2011 16:19] Peter Laursen
Inconsistence is also

1) CREATE SP and CREATE TABLE generate different errors on same database. Why? "CREATE denied [for user@host] to database"  is an error message that tells what the problem is. "Access denied for user@host to database" is simply wrong IMHO. I have access to both databases!

2) Same operation to I_S and P_S returns different errors. They have same restriction with CREATE (+ DROP etc.) *any kind of object* (it is not possible - the schema is 'locked')).  It would be consistent if the same error messages were returned with both databases.
[25 Jul 2012 19:07] Paul DuBois
Test case changes (to demonstrate bug no longer present). No changelog entry
needed.