MySQL Proxy: Oh, no… Why did they have to go and do that? (by )

The MySQL folks have a new tool, MySQL Proxy, which looks like a MySQL server to clients, but actually just passes incoming queries to a user-supplied Lua script which can pass them on to other MySQL servers, process them itself, rewrite queries before passing them on then rewrite the results, etc.

Which is fine in and of itself. I can think of a few uses for such a thing: it'd be great for query logging during debugging, especially when you're examining the interactions of queries from several sources, so just logging on the client wouldn't help. And it'd be useful for distributed database stuff, too.

However, there's a tutorial prominently linked, Getting Started with MySQL Proxy.

And what examples of the uses of the proxy does it give?

  • Pass it along unchanged (default)
  • Fix spelling mistakes (ever written CRATE DATAABSE?)
  • Filter it out, i.e., remove it altogether
  • Rewrite the query according to some policy (enforcing strong passwords, forbidding empty ones)
  • Add forgotten statements (autocommit is enabled and the user sent a BEGIN WORK? You can inject a SET AUTOCOMMIT = 0 before that)
  • Much more: if you can think of it, it's probably already possible; if it isn't, blog about it: chances are that someone will make it happen

Am I the only person who feels that setting up a proxy in front of an SQL server to catch spelling mistakes and semantic errors and Do What I Mean rather than reporting an error so the developer fixes their code will just lead to endless pain... like every past DWIM system? And is an SQL query proxy really the place to enforce strong passwords, as opposed to in the application code or in the database itself?

I think proxies for just about any protocol can be useful, but condoning such practices as listed above is rather irresponsible...

4 Comments

  • By Ben, Thu 16th Aug 2007 @ 12:18 pm

    Can you think of any non-stupid uses for it though?

    It's probably just someone going "oh that's cool, what can it be used for usefully, er, not sure, I know, how about fixing dumb errors?"

  • By David Cantrell, Fri 17th Aug 2007 @ 2:32 pm

    The obvious use vaguely-sane use for it is as a sick and perverted way of adding triggers.

    I bet it'd fall over and have a fit if you start using cursors. I expect MySQL's workaround for that is to have just not implemented them.

  • By @ndy Macolleague, Wed 22nd Aug 2007 @ 12:20 pm

    How about using this as a way to integrate your memcached intrastructure?

  • By alaric, Fri 24th Aug 2007 @ 2:18 pm

    We came up with a use for it on IRC:

    alaricsp: The order in which an SQL server returns rows, unless you ask it to order, is undefined

    [3:13pm] alaricsp: So will generally be whichever order the query finds them in

    [3:14pm] sjamaan: yeah

    [3:14pm] sjamaan: Someone should make an SQL database that returns things in random order

    [3:15pm] sjamaan: Just to see all the Rails/PHP kiddies whine

    [3:16pm] alaricsp: :-)

    [3:16pm] alaricsp: Easily done with... MySQL Proxy! When there's no ORDER BY on a query, just append ORDER BY RANDOM() :-)

    [3:16pm] sjamaan: haha

    [3:16pm] alaricsp: At last, I've found a use for it!

    [3:16pm] sjamaan: hurray!

    [3:16pm] • alaricsp copies this conversation to a comment on his blog posting about it

Other Links to this Post

RSS feed for comments on this post.

Leave a comment

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales