Bug #25848 Different errors on the same invalid GRANT statement
Submitted: 25 Jan 2007 14:16 Modified: 1 Feb 2007 18:25
Reporter: Alexey Kopytov Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Errors Severity:S4 (Feature request)
Version:4.0.28, 4.1.23, 5.0.36, 5.1.15 OS:
Assigned to: CPU Architecture:Any

[25 Jan 2007 14:16] Alexey Kopytov
Description:
The following GRANT statement:

GRANT PROCESS ON * TO user@localhost;

which has an invalid syntax according to the manual returns different error messages. When there is no default database the error returned is "ERROR 1046 (3D000): No database selected". When there is a default database, the error is "ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES" (a correct one).

How to repeat:
shell> mysql -u root

mysql> GRANT PROCESS ON * TO user@localhost;
ERROR 1046 (3D000): No database selected

mysql> GRANT PROCESS ON * TO user@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
[25 Jan 2007 14:18] Alexey Kopytov
The "How to repeat" section should actually be:

shell> mysql -u root

mysql> GRANT PROCESS ON * TO user@localhost;
ERROR 1046 (3D000): No database selected

mysql> use test;

mysql> GRANT PROCESS ON * TO user@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
[1 Feb 2007 18:25] Sergei Golubchik
It's not incorrect. Compare with:

shell> mysql -u root

mysql> grant select on * to user@localhost;
ERROR 1046 (3D000): No database selected

That is, there're two errors in your statement, the first that is found it returned.