diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2014-11-30 21:13:41 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2014-11-30 21:13:41 -0500 |
commit | 2b40a389a5d82cfea7fabf1f34ff2737b4d65cfa (patch) | |
tree | be9e46ba0ac3e16520b77da6366f447be2187617 /sql | |
parent | b16b072186764da468dd947b33a8299b7f4c1a8a (diff) | |
download | mariadb-git-2b40a389a5d82cfea7fabf1f34ff2737b4d65cfa.tar.gz |
MDEV-4412 : SLOW QUERY LOG - add affected rows (UPDATE / DELETE) in slow query log
Added Rows_affected to slow query log & mysql.slow_log table.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/log.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/log.cc b/sql/log.cc index ff04105b43d..24e52838e47 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -837,7 +837,7 @@ bool Log_to_csv_event_handler:: restore_record(table, s->default_values); // Get empty record /* check that all columns exist */ - if (table->s->fields < 11) + if (table->s->fields < 13) goto err; /* store the time and user values */ @@ -918,6 +918,12 @@ bool Log_to_csv_event_handler:: if (table->field[11]->store((longlong) thd->thread_id, TRUE)) goto err; + /* Rows_affected */ + if (table->field[12]->store(thd->get_stmt_da()->is_ok() ? + (longlong) thd->get_stmt_da()->affected_rows() : + 0, TRUE)) + goto err; + /* log table entries are not replicated */ if (table->file->ha_write_row(table->record[0])) goto err; @@ -2918,12 +2924,16 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, sprintf(lock_time_buff, "%.6f", ulonglong2double(lock_utime)/1000000.0); if (my_b_printf(&log_file, "# Thread_id: %lu Schema: %s QC_hit: %s\n" \ - "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu\n", + "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu\n" \ + "# Rows_affected: %lu\n", (ulong) thd->thread_id, (thd->db ? thd->db : ""), ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"), query_time_buff, lock_time_buff, (ulong) thd->get_sent_row_count(), - (ulong) thd->get_examined_row_count()) == (size_t) -1) + (ulong) thd->get_examined_row_count(), + thd->get_stmt_da()->is_ok() ? + (ulong) thd->get_stmt_da()->affected_rows() : + 0) == (size_t) -1) tmp_errno= errno; if ((thd->variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_QUERY_PLAN) && (thd->query_plan_flags & |