开发者

Is it possible to configure MySQL logging so that it only reports queries that were rolled back?

开发者 https://www.devze.com 2023-03-08 18:26 出处:网络
I have an intermittent bug that I\'m trying to track down, and I\'d like to capture only MySQL queri开发者_JAVA技巧es that fail resulting in a rollback.I don\'t want a full general query or binary log

I have an intermittent bug that I'm trying to track down, and I'd like to capture only MySQL queri开发者_JAVA技巧es that fail resulting in a rollback. I don't want a full general query or binary log because there would be millions of entries in the haystack to sort through.

Something like this solution except for MySQL would be perfect.

TIA,

JD


Not a direct answer to your question, but the utility mysqlbinlog can extract data from the binary log.

See: the user comments in this page: http://dev.mysql.com/doc/refman/5.5/en/binary-log.html
And this page: http://ronaldbradford.com/blog/mysql-dml-stats-per-table-2009-09-09/

Here's the official documentation for mysqlbinlog, which might help you get the info you need.


In MySQL it is very difficult (or maybe impossible). You can do it in PHP. If you don't use low functions like mysql_query and you use high methods like ->query(), you can add logic to theirs. If query failed (return false for example), add it to log. Sorry for my english.

Note for Zend_DB:

class My_DB extends Zend_DB {
    public function insert($data) {
        try {
            parent::insert($data);
        } catch (Exception $e) {
            // put $e->getMessage() to log
        }
    }
}

You can overwrite different methods, such as update, query and others...

0

精彩评论

暂无评论...
验证码 换一张
取 消