Embedding comments in MySQL statements

一笑奈何 提交于 2019-12-04 20:07:02

Normally, comments are stripped before the SQL statement is recorded in the binary log. However, a nasty workaround is to pretend that ypur comment contains syntax for some future version of MySQL - eg. 9.99.99:

/*!99999 user:jwilkie */ insert into tbl values (yyy);

These comments will then be passed through into the binary log.

If you have control over the SQL queries being generated, then you should be able to embed comments in them programatically in your query builder.

Select queries don't go in the binary log, but the comments may make it into the slow query log, general query log, etc.

Here's a blog post from Percona that touches on the subject a bit, specifically in the context of mk-query-digest. It might help:

http://www.mysqlperformanceblog.com/2010/07/05/mk-query-digest-query-comments-and-the-query-cache/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!