Bug #317 Inconsistency in SHOW GRANTS output
Submitted: 23 Apr 2003 9:54 Modified: 23 Apr 2003 10:40
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.x OS:Any (any)
Assigned to: CPU Architecture:Any

[23 Apr 2003 9:54] Paul DuBois
Description:
SHOW GRANTS isn't consistent about quoting
in its output.

How to repeat:
Let's say I issue these statements:

GRANT SELECT on world.* TO abc@localhost;
GRANT SELECT on world.City TO abc@localhost;
GRANT SELECT (ID) on world.City TO abc@localhost;

Then I issue SHOW GRANTS:

mysql> show grants for abc@localhost;
+------------------------------------------------------+
| Grants for abc@localhost                             |
+------------------------------------------------------+
| GRANT USAGE ON *.* TO 'abc'@'localhost'              |
| GRANT SELECT ON `world`.* TO 'abc'@'localhost'       |
| GRANT SELECT (ID) ON world.City TO 'abc'@'localhost' |
+------------------------------------------------------+

Note that world is quoted in the second GRANT
statement, but that world and City are not in the
third statement.

I guess this is just cosmetic in a sense, but if
the db or table names happened to contain
special character, the lack of quotes would be
incorrect.
[23 Apr 2003 10:40] MySQL Verification Team
Fixed, thanks.

This is a patch:
===== sql/sql_acl.cc 1.93 vs edited =====
*** /tmp/sql_acl.cc-1.93-2058   Mon Apr 21 22:53:53 2003
--- edited/sql/sql_acl.cc       Wed Apr 23 20:36:56 2003
***************
*** 3031,3041 ****
            }
          }
        }
!       global.append(" ON ",4);
        global.append(grant_table->db);
!       global.append(".",1);
        global.append(grant_table->tname);
!       global.append(" TO '",5);
        global.append(lex_user->user.str,lex_user->user.length); 
        global.append("'@'",3);
        global.append(lex_user->host.str,lex_user->host.length); 
--- 3031,3041 ----
            }
          }
        }
!       global.append(" ON `",5);
        global.append(grant_table->db);
!       global.append("`.`",3);
        global.append(grant_table->tname);
!       global.append("` TO '",6);
        global.append(lex_user->user.str,lex_user->user.length); 
        global.append("'@'",3);
        global.append(lex_user->host.str,lex_user->host.length);