Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit plugin add examined_row_count/affected_row_count/return_row_count parameter #5035

Open
wants to merge 2 commits into
base: 5.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/mysql/plugin_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ struct mysql_event_general
MYSQL_LEX_CSTRING general_sql_command;
MYSQL_LEX_CSTRING general_external_user;
MYSQL_LEX_CSTRING general_ip;
MYSQL_LEX_CSTRING general_database;
unsigned long long general_examined_row_count;
unsigned long long general_affected_row_count;
unsigned long long general_return_row_count;
};

/**
Expand Down
4 changes: 4 additions & 0 deletions include/mysql/plugin_audit.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
MYSQL_LEX_CSTRING general_sql_command;
MYSQL_LEX_CSTRING general_external_user;
MYSQL_LEX_CSTRING general_ip;
MYSQL_LEX_CSTRING general_database;
unsigned long long general_examined_row_count;
unsigned long long general_affected_row_count;
unsigned long long general_return_row_count;
};
typedef enum
{
Expand Down
8 changes: 8 additions & 0 deletions sql/sql_audit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ int mysql_audit_notify(THD *thd, mysql_event_general_subclass_t subclass,
event.general_host= sctx->host();
event.general_external_user= sctx->external_user();
event.general_rows= thd->get_stmt_da()->current_row_for_condition();
event.general_database= thd->db();
event.general_examined_row_count= thd->get_examined_row_count();
if (thd->get_row_count_func() < 0) {
event.general_affected_row_count= 0;
} else {
event.general_affected_row_count= thd->get_row_count_func();
}
event.general_return_row_count= thd->get_sent_row_count();
if (thd->lex->sql_command == SQLCOM_END && msg_len > 0 && error_code == 0)
{
int found_index= -1;
Expand Down