saltstack/salt — pull request #9150 by regilero (2013-12-11 00:16:13+00:00)
Title: Mysql additions

Big improvments on MySql module internals.
Made some tests, found some edge cases, fixed the code.

Now I encoutered some problems:
* Connection on database containing non ascci characters, or with users containing non ascii characters are not working in current version of MySQLdb : https://github.com/farcepest/MySQLdb1/issues/40 . So this part is commented on tests. Maybe we could add a `latin1` decode for a subset of the non-ascii world on theses strings on the connection string.
* Grants queries on MySQL escapes the `%` and `_` on the database name, but only for the `db.*` form, not for `db.table`, it would be too easy.
* MySQLdb needs a `%%` escape for all '%' characters in the whole query to avoid conflicts with escaped arguments... but this escape should not be done on query running in `execute()` without arguments.

I made several fixs on the grant queries lexical analysis, and on the mysql_grants state using it. Now this part is quite unsure. It needs some more tests
* does the grants applies on users when they use a password?
* why not using the `table` element on tokens, this makes quite hard to manage table grants with the current states
* why allowing escape=False on the database name? Database escaping rules are complex and ensure security of the query.

Now, that's already a big peer review stuff for you, I'm open on comments and fixs.