MXS-1734 Add possibility to instruct when to dump statements

With the configuration entry

dump_last_statements=[never|on_close|on_error]

you can now specify when and if to dump the last statements
of of a session.
This commit is contained in:
Johan Wikman
2018-03-26 10:42:11 +03:00
parent 6d599395d4
commit 3d45d452eb
6 changed files with 68 additions and 5 deletions

View File

@ -80,6 +80,7 @@ const char CN_CONNECTION_TIMEOUT[] = "connection_timeout";
const char CN_DATA[] = "data";
const char CN_DEFAULT[] = "default";
const char CN_DESCRIPTION[] = "description";
const char CN_DUMP_LAST_STATEMENTS[] = "dump_last_statements";
const char CN_ENABLE_ROOT_USER[] = "enable_root_user";
const char CN_FILTERS[] = "filters";
const char CN_FILTER[] = "filter";
@ -1740,13 +1741,33 @@ handle_global_item(const char *name, const char *value)
int intval = strtol(value, &endptr, 0);
if (*endptr == '\0' && intval >= 0)
{
session_retain_last_statements(intval);
session_set_retain_last_statements(intval);
}
else
{
MXS_ERROR("Invalid value for '%s': %s", CN_RETAIN_LAST_STATEMENTS, value);
}
}
else if (strcmp(name, CN_DUMP_LAST_STATEMENTS) == 0)
{
if (strcmp(value, "on_close") == 0)
{
session_set_dump_statements(SESSION_DUMP_STATEMENTS_ON_CLOSE);
}
else if (strcmp(value, "on_error") == 0)
{
session_set_dump_statements(SESSION_DUMP_STATEMENTS_ON_ERROR);
}
else if (strcmp(value, "never") == 0)
{
session_set_dump_statements(SESSION_DUMP_STATEMENTS_NEVER);
}
else
{
MXS_ERROR("%s can have the values 'never', 'on_close' or 'on_error'.",
CN_DUMP_LAST_STATEMENTS);
}
}
else
{
for (i = 0; lognames[i].name; i++)