MXS-1734 Add statement dumping mechanism

With the configuration entry

   retain_last_statements=<unsigned>

or the debug flag '--debug=retain-last-statements=<unsigned>',
MaxScale will store the specified number of last statements
for each session. By calling

    session_dump_statements(session);

MaxScale will dump the last statements as NOTICE messages.
For debugging purposes.
This commit is contained in:
Johan Wikman
2018-03-22 15:31:13 +02:00
parent 6e859fcf02
commit 6d599395d4
6 changed files with 154 additions and 0 deletions

View File

@ -192,6 +192,7 @@ static void enable_module_unloading(const char* arg);
static void enable_statement_logging(const char* arg);
static void disable_statement_logging(const char* arg);
static void redirect_output_to_file(const char* arg);
static void retain_last_statements(const char* arg);
static bool user_is_acceptable(const char* specified_user);
static bool init_sqlite3();
@ -228,6 +229,11 @@ const DEBUG_ARGUMENT debug_arguments[] =
"disable-statement-logging", disable_statement_logging,
"disable the logging of SQL statements sent by MaxScale to the servers"
},
{
"retain-last-statements", retain_last_statements,
"retain the specified number of client statements\n"
SPACER "allows statements to be logged in problem situations"
},
{NULL, NULL, NULL}
};
@ -3206,6 +3212,18 @@ static void disable_statement_logging(const char* arg)
mxs_mysql_set_log_statements(false);
}
static void retain_last_statements(const char* arg)
{
int n = atoi(arg);
if (n < 0)
{
n = 0;
}
session_retain_last_statements(n);
}
static void redirect_output_to_file(const char* arg)
{
if (arg)