Bug #303 GRANT fails for non-existent table
Submitted: 17 Apr 2003 10:50 Modified: 17 Apr 2003 11:29
Reporter: Paul DuBois Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.12 OS:Any
Assigned to: CPU Architecture:Any

[17 Apr 2003 10:50] Paul DuBois
Description:
I ran these GRANT statements, which assign global, db-level,
and table-level privileges:

mysql> GRANT FILE on *.* TO 'abc'@'myhost.domain.com';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT on mydb.* TO 'abc'@'myhost.domain.com';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT UPDATE on mydb.mytable TO 'abc'@'myhost.domain.com';
ERROR 1146: Table 'mydb.mytable' doesn't exist

Why, for the third statement, should it matter whether or not the
table exists?  This makes it difficult to set up privileges in advance
of creating the tables.  It's also inconsistent with the second
statement, because no mydb database exists on this server, yet
GRANT doesn't complain about that.

How to repeat:
[17 Apr 2003 11:29] MySQL Verification Team
The behaviour is different for security reasons and a manner in which table grants are cached.

So, if requested grants do not comprehend CREATE grant, and table does not exist, grent can not be completed.

Table grants are cached in several levels, including table_cache, and there is no such thing as database cache ... ;o)

So, it is a mixture of both security reasons and a manner in which table / column grants are cached.