Bug #68691 Apply schema privileges sql error when underscore DB name
Submitted: 16 Mar 2013 14:21 Modified: 16 Mar 2013 17:45
Reporter: Teodor Hadjiev Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: Administration Severity:S3 (Non-critical)
Version:5.2.47 OS:Windows (Win7 x64)
Assigned to: CPU Architecture:Any
Tags: escape, privileges, schema, special, SQL, symbols, underscore, wildcard

[16 Mar 2013 14:21] Teodor Hadjiev
Description:
Trying to add a schema privilege record in Administration for an user account, on a schema that has an _ (underscore) in its name, results in an error dialog and failed query.
The message is as follows:

MySQL Workbench

Error:

[Content]
Error executing 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, TRIGGER ON myapp\_new.* TO 'myapp_new'@'%''
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\_new.* TO 'myapp_new'@'%'' at line 1.
SQL Error: 1064

The username and DB name both have _ in the name, but the query seems to fail at the DB name.
Mysql is 5.5.8.

How to repeat:
Create a database with an underscore in the name.
Open Administration tab to Mysql. Go to Users and Privileges. Get a test user account created and go to Schema privileges tab. Pick the test user, Add Entry, pick the database with the underscore with the last option in the dialog, Ok, then select privileges from the checkboxes. Hit Apply. The error pops up.

Suggested fix:
Proper handling of underscores (escaping or the lack thereof) and other special/wildcard symbols in the query builder in Schema privileges and elsewhere.
[16 Mar 2013 17:45] MySQL Verification Team
Thank you for the bug report. Duplicate of http://bugs.mysql.com/bug.php?id=68175 .