diff --git a/config/blobs.yml b/config/blobs.yml index f412bffd8..6381dbe31 100644 --- a/config/blobs.yml +++ b/config/blobs.yml @@ -6,10 +6,10 @@ Percona-XtraDB-Cluster-8.0.44-35.tar.gz: size: 529799158 object_id: 1636042c-aa5f-47c5-75e3-973440644229 sha: sha256:0bd17bb930c0bf2e0bd5857ef12e547663658d7c9abfac99ff097daf9d74d488 -Percona-XtraDB-Cluster-8.4.6-6.tar.gz: - size: 506765745 - object_id: ec442812-58d7-4ff8-616a-6e72be3d6a56 - sha: sha256:1b8ae8266c223b34330a54d4af76f7e10d0b0875ac51041bad0e02e95fa47fd4 +Percona-XtraDB-Cluster-8.4.7-7.tar.gz: + size: 506738352 + object_id: 46238cf5-2ca3-4619-47d2-e54bf1d2f418 + sha: sha256:5b8e7c4d4cb422d018ec668d9cc69f6f403e4974ea71a6d7405a8b2194aa14a9 boost_1_59_0.tar.bz2: size: 70389425 object_id: 7344fc77-b911-45c2-5467-c6d5fcab6d29 @@ -42,10 +42,10 @@ percona-xtrabackup-8.0.35-34.tar.gz: size: 447840968 object_id: 7fd5dc55-cf98-40e3-7505-0854a918327d sha: sha256:6ca81cd647e7cb1d8fd341f97cd32248bd719f9104a63eb24f1edda6a2d2441c -percona-xtrabackup-8.4.0-4.tar.gz: - size: 432657062 - object_id: 036a8d00-269f-4e54-627d-e1ad7be215e4 - sha: sha256:e566a164a21b18781aad281b84426418ac2bcf71052ec85d8c5e62f742a7dfeb +percona-xtrabackup-8.4.0-5.tar.gz: + size: 432646274 + object_id: edf66c32-e051-4a55-561a-bd67bb8a13bb + sha: sha256:fadcf27efd2a2596f689388659e2ff5c36debcc051a55974ac8bb4a83c015f57 pkg-config_0.29.2.orig.tar.gz: size: 2016830 object_id: ca3d829d-016e-4acd-6509-9d1766884b9d diff --git a/packages/percona-xtradb-cluster-8.4/packaging b/packages/percona-xtradb-cluster-8.4/packaging index ab5e146a9..18f90c28e 100644 --- a/packages/percona-xtradb-cluster-8.4/packaging +++ b/packages/percona-xtradb-cluster-8.4/packaging @@ -61,10 +61,6 @@ build() { ( cd Percona-XtraDB-Cluster-*/ - if ! patch -p1 < ../patches/mysql-8.4/audit_log_plugin.patch; then - echo >&2 "Failed to apply patch to port Percona audit log plugin to MySQL v8.4" - exit 1 - fi source MYSQL_VERSION mysql_version="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}" wsrep_version="$(grep WSREP_INTERFACE_VERSION wsrep-lib/wsrep-API/v26/wsrep_api.h | cut -d '"' -f2).$(grep 'SET(WSREP_PATCH_VERSION' "cmake/wsrep-lib.cmake" | cut -d '"' -f2)" diff --git a/packages/percona-xtradb-cluster-8.4/spec b/packages/percona-xtradb-cluster-8.4/spec index 4c570bc86..089aa133e 100644 --- a/packages/percona-xtradb-cluster-8.4/spec +++ b/packages/percona-xtradb-cluster-8.4/spec @@ -10,4 +10,3 @@ files: - libaio_*.orig.tar.xz - pkg-config_*.tar.gz - socat-*.tar.gz -- patches/mysql-8.4/*.patch diff --git a/src/patches/mysql-8.4/audit_log_plugin.patch b/src/patches/mysql-8.4/audit_log_plugin.patch deleted file mode 100644 index e57363d10..000000000 --- a/src/patches/mysql-8.4/audit_log_plugin.patch +++ /dev/null @@ -1,7919 +0,0 @@ -diff --git a/plugin/audit_log/CMakeLists.txt b/plugin/audit_log/CMakeLists.txt -new file mode 100644 -index 00000000000..c7aa10ed53a ---- /dev/null -+++ b/plugin/audit_log/CMakeLists.txt -@@ -0,0 +1,24 @@ -+# Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; version 2 of the License. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ -+MYSQL_ADD_PLUGIN(audit_log audit_log.cc file_logger.cc buffer.cc audit_file.cc -+ audit_syslog.cc filter.cc -+ MODULE_ONLY MODULE_OUTPUT_NAME "audit_log") -+ -+IF(UNIX) -+ IF(INSTALL_MYSQLTESTDIR) -+ INSTALL(DIRECTORY tests/mtr/ DESTINATION ${INSTALL_MYSQLTESTDIR}/suite/audit_log COMPONENT Test) -+ ENDIF() -+ENDIF() -diff --git a/plugin/audit_log/audit_file.cc b/plugin/audit_log/audit_file.cc -new file mode 100644 -index 00000000000..ee8ae42439b ---- /dev/null -+++ b/plugin/audit_log/audit_file.cc -@@ -0,0 +1,183 @@ -+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#include "audit_handler.h" -+#include "audit_log.h" -+#include "buffer.h" -+#include "my_dbug.h" -+#include "my_sys.h" -+#include "mysql/service_mysql_alloc.h" -+ -+struct audit_handler_file_data_t { -+ size_t struct_size; -+ LOGGER_HANDLE *logger; -+ logger_prolog_func_t header; -+ logger_epilog_func_t footer; -+ bool sync_on_write; -+ bool use_buffer; -+ audit_log_buffer_t *buffer; -+}; -+ -+static int audit_handler_file_write(audit_handler_t *handler, const char *buf, -+ size_t len); -+static int audit_handler_file_flush(audit_handler_t *handler) noexcept; -+static int audit_handler_file_close(audit_handler_t *handler) noexcept; -+static int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger, -+ const char *buf, size_t len, -+ log_record_state_t state) noexcept; -+static int audit_handler_file_write_buf(audit_log_buffer_t *buffer, -+ const char *buf, size_t len); -+static void audit_handler_file_set_option(audit_handler_t *handler, -+ audit_handler_option_t opt, -+ void *val) noexcept; -+ -+static int write_callback(void *data, const char *buf, size_t len, -+ log_record_state_t state) noexcept { -+ audit_handler_t *handler = (audit_handler_t *)data; -+ audit_handler_file_data_t *hdata = (audit_handler_file_data_t *)handler->data; -+ -+ assert(hdata->struct_size == sizeof(audit_handler_file_data_t)); -+ -+ return audit_handler_file_write_nobuf(hdata->logger, buf, len, state); -+} -+ -+audit_handler_t *audit_handler_file_open( -+ audit_handler_file_config_t *opts) noexcept { -+ audit_handler_t *handler = (audit_handler_t *)my_malloc( -+ key_memory_audit_log_handler, -+ sizeof(audit_handler_t) + sizeof(audit_handler_file_data_t), MY_ZEROFILL); -+ if (handler != nullptr) { -+ audit_handler_file_data_t *data = -+ (audit_handler_file_data_t *)(handler + 1); -+ data->struct_size = sizeof(audit_handler_file_data_t); -+ data->footer = opts->footer; -+ data->header = opts->header; -+ data->sync_on_write = opts->sync_on_write; -+ data->use_buffer = opts->use_buffer; -+ if (data->use_buffer) { -+ data->buffer = audit_log_buffer_init( -+ opts->buffer_size, opts->can_drop_data, write_callback, handler); -+ if (data->buffer == nullptr) goto error; -+ } -+ data->logger = logger_open(opts->name, opts->rotate_on_size, -+ opts->rotate_on_size ? opts->rotations : 0, -+ !opts->use_buffer, opts->header); -+ if (data->logger == nullptr) { -+ goto error; -+ } -+ handler->data = data; -+ handler->write = audit_handler_file_write; -+ handler->flush = audit_handler_file_flush; -+ handler->close = audit_handler_file_close; -+ handler->set_option = audit_handler_file_set_option; -+ goto success; -+ error: -+ if (data->buffer) { -+ audit_log_buffer_shutdown(data->buffer); -+ } -+ my_free(handler); -+ handler = nullptr; -+ } -+success: -+ return handler; -+} -+ -+static int audit_handler_file_write_nobuf(LOGGER_HANDLE *logger, -+ const char *buf, size_t len, -+ log_record_state_t state) noexcept { -+ return logger_write(logger, buf, len, state); -+} -+ -+static int audit_handler_file_write_buf(audit_log_buffer_t *buffer, -+ const char *buf, size_t len) { -+ return audit_log_buffer_write(buffer, buf, len); -+} -+ -+static int audit_handler_file_write(audit_handler_t *handler, const char *buf, -+ size_t len) { -+ audit_handler_file_data_t *data = (audit_handler_file_data_t *)handler->data; -+ int res; -+ -+ assert(data->struct_size == sizeof(audit_handler_file_data_t)); -+ -+ if (data->use_buffer) { -+ assert(data->buffer); -+ res = audit_handler_file_write_buf(data->buffer, buf, len); -+ } else { -+ assert(data->logger); -+ res = audit_handler_file_write_nobuf(data->logger, buf, len, -+ log_record_state_t::COMPLETE); -+ -+ if (data->sync_on_write) { -+ logger_sync(data->logger); -+ } -+ } -+ -+ return res; -+} -+ -+static int audit_handler_file_flush(audit_handler_t *handler) noexcept { -+ audit_handler_file_data_t *data = (audit_handler_file_data_t *)handler->data; -+ LOGGER_HANDLE *logger; -+ int res; -+ -+ assert(data->struct_size == sizeof(audit_handler_file_data_t)); -+ -+ logger = data->logger; -+ -+ if (data->use_buffer) audit_log_buffer_pause(data->buffer); -+ -+ res = logger_reopen(logger, data->header, data->footer); -+ -+ if (data->use_buffer) audit_log_buffer_resume(data->buffer); -+ -+ return res; -+} -+ -+static int audit_handler_file_close(audit_handler_t *handler) noexcept { -+ audit_handler_file_data_t *data = (audit_handler_file_data_t *)handler->data; -+ int res; -+ LOGGER_HANDLE *logger; -+ -+ assert(data->struct_size == sizeof(audit_handler_file_data_t)); -+ -+ logger = data->logger; -+ -+ if (data->use_buffer) { -+ audit_log_buffer_shutdown(data->buffer); -+ } -+ -+ res = logger_close(logger, data->footer); -+ -+ my_free(handler); -+ -+ return res; -+} -+ -+static void audit_handler_file_set_option(audit_handler_t *handler, -+ audit_handler_option_t opt, -+ void *val) noexcept { -+ audit_handler_file_data_t *data = (audit_handler_file_data_t *)handler->data; -+ -+ switch (opt) { -+ case audit_handler_option_t::ROTATE_ON_SIZE: -+ logger_set_size_limit(data->logger, *(ulonglong *)(val)); -+ break; -+ case audit_handler_option_t::ROTATIONS: -+ logger_set_rotations(data->logger, *(ulonglong *)(val)); -+ break; -+ } -+} -diff --git a/plugin/audit_log/audit_handler.h b/plugin/audit_log/audit_handler.h -new file mode 100644 -index 00000000000..a5bd77336a0 ---- /dev/null -+++ b/plugin/audit_log/audit_handler.h -@@ -0,0 +1,92 @@ -+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#ifndef AUDIT_HANDLER_INCLUDED -+#define AUDIT_HANDLER_INCLUDED -+ -+#include "logger.h" -+ -+struct audit_handler_file_config_t; -+struct audit_handler_syslog_config_t; -+struct audit_handler_buffered_t; -+typedef void *audit_handler_data_t; -+ -+enum class audit_handler_option_t { ROTATE_ON_SIZE, ROTATIONS }; -+ -+struct audit_handler_t { -+ int (*write)(audit_handler_t *, const char *, size_t); -+ int (*flush)(audit_handler_t *); -+ int (*close)(audit_handler_t *); -+ void (*set_option)(audit_handler_t *, audit_handler_option_t, void *); -+ audit_handler_data_t data; -+}; -+ -+struct audit_handler_file_config_t { -+ const char *name; -+ size_t rotate_on_size; -+ size_t rotations; -+ bool sync_on_write; -+ bool use_buffer; -+ size_t buffer_size; -+ bool can_drop_data; -+ logger_prolog_func_t header; -+ logger_epilog_func_t footer; -+}; -+ -+struct audit_handler_syslog_config_t { -+ const char *ident; -+ int facility; -+ int priority; -+ logger_prolog_func_t header; -+ logger_epilog_func_t footer; -+}; -+ -+static inline int audit_handler_write(audit_handler_t *handler, const char *buf, -+ size_t len) { -+ if (handler != nullptr && handler->write != nullptr) { -+ return handler->write(handler, buf, len); -+ } -+ return len; -+} -+ -+static inline int audit_handler_flush(audit_handler_t *handler) { -+ if (handler != nullptr && handler->flush != nullptr) { -+ return handler->flush(handler); -+ } -+ return 0; -+} -+ -+static inline int audit_handler_close(audit_handler_t *handler) { -+ if (handler != nullptr && handler->close != nullptr) { -+ return handler->close(handler); -+ } -+ return 0; -+} -+ -+static inline void audit_handler_set_option(audit_handler_t *handler, -+ audit_handler_option_t opt, -+ void *val) { -+ if (handler != nullptr && handler->set_option != nullptr) { -+ handler->set_option(handler, opt, val); -+ } -+} -+ -+audit_handler_t *audit_handler_file_open( -+ audit_handler_file_config_t *opts) noexcept; -+audit_handler_t *audit_handler_syslog_open( -+ audit_handler_syslog_config_t *opts) noexcept; -+ -+#endif -diff --git a/plugin/audit_log/audit_log.cc b/plugin/audit_log/audit_log.cc -new file mode 100644 -index 00000000000..91f1f6cdbc2 ---- /dev/null -+++ b/plugin/audit_log/audit_log.cc -@@ -0,0 +1,1664 @@ -+/* Copyright (c) 2014-2016 Percona LLC and/or its affiliates. All rights -+ reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "my_sys.h" -+#include "mysql/components/services/component_sys_var_service.h" -+#include "mysql/plugin.h" -+#include "mysql/plugin_audit.h" -+#include "mysql/psi/mysql_memory.h" -+#include "mysql/service_security_context.h" -+#include "mysql_com.h" -+#include "mysql_version.h" -+#include "mysqld_error.h" -+#include "sql/mysqld.h" -+#include "sql/mysqld_cs.h" -+#include "sql/sql_plugin_var.h" -+#include "typelib.h" -+ -+#include "audit_handler.h" -+#include "audit_log.h" -+#include "buffer.h" -+#include "filter.h" -+#include "logger.h" -+ -+#define PLUGIN_VERSION 0x0002 -+ -+enum audit_log_policy_t { ALL, NONE, LOGINS, QUERIES }; -+enum audit_log_strategy_t { -+ ASYNCHRONOUS, -+ PERFORMANCE, -+ SEMISYNCHRONOUS, -+ SYNCHRONOUS -+}; -+enum audit_log_format_t { OLD, NEW, JSON, CSV }; -+enum audit_log_handler_t { HANDLER_FILE, HANDLER_SYSLOG }; -+ -+typedef void (*escape_buf_func_t)(const char *, size_t *, char *, size_t *); -+ -+static audit_handler_t *log_handler = nullptr; -+static std::atomic record_id{0}; -+static time_t log_file_time = 0; -+static char *audit_log_file; -+static const char default_audit_log_file[] = "audit.log"; -+static ulong audit_log_policy = audit_log_policy_t::ALL; -+static ulong audit_log_strategy = audit_log_strategy_t::ASYNCHRONOUS; -+static ulonglong audit_log_buffer_size = 1048576; -+static ulonglong audit_log_rotate_on_size = 0; -+static ulonglong audit_log_rotations = 0; -+static bool audit_log_flush = false; -+static ulong audit_log_format = audit_log_format_t::OLD; -+static ulong audit_log_handler = audit_log_handler_t::HANDLER_FILE; -+static char *audit_log_syslog_ident; -+static const char default_audit_log_syslog_ident[] = "percona-audit"; -+static ulong audit_log_syslog_facility = 0; -+static ulong audit_log_syslog_priority = 0; -+static char *audit_log_exclude_accounts = nullptr; -+static char *audit_log_include_accounts = nullptr; -+static char *audit_log_exclude_databases = nullptr; -+static char *audit_log_include_databases = nullptr; -+static char *audit_log_exclude_commands = nullptr; -+static char *audit_log_include_commands = nullptr; -+std::atomic audit_log_buffer_size_overflow(0); -+ -+PSI_memory_key key_memory_audit_log_logger_handle; -+PSI_memory_key key_memory_audit_log_handler; -+PSI_memory_key key_memory_audit_log_buffer; -+PSI_memory_key key_memory_audit_log_accounts; -+PSI_memory_key key_memory_audit_log_databases; -+PSI_memory_key key_memory_audit_log_commands; -+ -+static PSI_memory_info all_audit_log_memory[] = { -+ {&key_memory_audit_log_logger_handle, "audit_log_logger_handle", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+ {&key_memory_audit_log_handler, "audit_log_handler", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+ {&key_memory_audit_log_buffer, "audit_log_buffer", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+ {&key_memory_audit_log_accounts, "audit_log_accounts", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+ {&key_memory_audit_log_databases, "audit_log_databases", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+ {&key_memory_audit_log_commands, "audit_log_commands", -+ PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}, -+}; -+ -+static const int audit_log_syslog_facility_codes[] = { -+ LOG_USER, LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_FTP, LOG_KERN, -+ LOG_LPR, LOG_MAIL, LOG_NEWS, -+#if (defined LOG_SECURITY) -+ LOG_SECURITY, -+#endif -+ LOG_SYSLOG, LOG_AUTH, LOG_UUCP, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, -+ LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7, 0}; -+ -+static const char *audit_log_syslog_facility_names[] = { -+ "LOG_USER", "LOG_AUTHPRIV", "LOG_CRON", "LOG_DAEMON", -+ "LOG_FTP", "LOG_KERN", "LOG_LPR", "LOG_MAIL", -+ "LOG_NEWS", -+#if (defined LOG_SECURITY) -+ "LOG_SECURITY", -+#endif -+ "LOG_SYSLOG", "LOG_AUTH", "LOG_UUCP", "LOG_LOCAL0", -+ "LOG_LOCAL1", "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4", -+ "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", 0}; -+ -+static const int audit_log_syslog_priority_codes[] = { -+ LOG_INFO, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, -+ LOG_NOTICE, LOG_EMERG, LOG_DEBUG, 0}; -+ -+static const char *audit_log_syslog_priority_names[] = { -+ "LOG_INFO", "LOG_ALERT", "LOG_CRIT", "LOG_ERR", "LOG_WARNING", -+ "LOG_NOTICE", "LOG_EMERG", "LOG_DEBUG", 0}; -+ -+static MYSQL_PLUGIN plugin_ptr; -+ -+static void init_record_id(off_t size) noexcept { -+ record_id.store(size, std::memory_order_relaxed); -+} -+ -+static ulonglong next_record_id() noexcept { -+ return record_id.fetch_add(1, std::memory_order_relaxed) + 1; -+} -+ -+static const constexpr auto MAX_RECORD_ID_SIZE = 50; -+static const constexpr auto MAX_TIMESTAMP_SIZE = 25; -+ -+static char *make_timestamp(char *buf, size_t buf_len, time_t t) noexcept { -+ tm tm; -+ -+ memset(&tm, 0, sizeof(tm)); -+ strftime(buf, buf_len, "%FT%TZ", gmtime_r(&t, &tm)); -+ -+ return buf; -+} -+ -+static char *make_record_id(char *buf, size_t buf_len) noexcept { -+ tm tm; -+ size_t len; -+ -+ memset(&tm, 0, sizeof(tm)); -+ len = snprintf(buf, buf_len, "%llu_", next_record_id()); -+ -+ strftime(buf + len, buf_len - len, "%FT%T", gmtime_r(&log_file_time, &tm)); -+ -+ return buf; -+} -+ -+struct escape_rule_t { -+ char character; -+ size_t length; -+ const char *replacement; -+}; -+ -+static void escape_buf(const char *in, size_t *inlen, char *out, size_t *outlen, -+ const escape_rule_t *control_escape_rules, -+ const escape_rule_t *other_escape_rules) noexcept { -+ char *outstart = out; -+ const char *base = in; -+ char *outend = out + *outlen; -+ -+ const char *inend = in + (*inlen); -+ -+ while ((in < inend) && (out < outend)) { -+ const escape_rule_t *replace_rule = nullptr; -+ if ((unsigned char)(*in) < 32) { -+ if (control_escape_rules[(unsigned int)*in].character) { -+ replace_rule = &control_escape_rules[(unsigned int)*in]; -+ } -+ } else { -+ const escape_rule_t *rule = nullptr; -+ for (rule = other_escape_rules; rule->character; rule++) { -+ if (*in == rule->character) { -+ replace_rule = rule; -+ break; -+ } -+ } -+ } -+ if (replace_rule) { -+ if ((outend - out) < (ptrdiff_t)replace_rule->length) break; -+ memcpy(out, replace_rule->replacement, replace_rule->length); -+ out += replace_rule->length; -+ } else { -+ *out++ = *in; -+ } -+ ++in; -+ } -+ *outlen = out - outstart; -+ *inlen = in - base; -+} -+ -+static void xml_escape(const char *in, size_t *inlen, char *out, -+ size_t *outlen) noexcept { -+ // Although most control sequences aren't supported in XML 1.0, we are better -+ // off printing them anyway instead of the original control characters -+ static const escape_rule_t control_rules[] = { -+ {0, 1, "?"}, {1, 4, ""}, {2, 4, ""}, -+ {3, 4, ""}, {4, 4, ""}, {5, 4, ""}, -+ {6, 4, ""}, {7, 4, ""}, {8, 4, ""}, -+ {'\t', 4, " "}, {'\n', 5, " "}, {11, 5, " "}, -+ {12, 5, " "}, {'\r', 5, " "}, {14, 5, ""}, -+ {15, 5, ""}, {16, 5, ""}, {17, 5, ""}, -+ {18, 5, ""}, {19, 5, ""}, {20, 5, ""}, -+ {21, 5, ""}, {22, 5, ""}, {23, 5, ""}, -+ {24, 5, ""}, {25, 5, ""}, {26, 5, ""}, -+ {27, 5, ""}, {28, 5, ""}, {29, 5, ""}, -+ {30, 5, ""}, {31, 5, ""}, -+ }; -+ static const escape_rule_t other_rules[] = {{'<', 4, "<"}, -+ {'>', 4, ">"}, -+ {'&', 5, "&"}, -+ {'"', 6, """}, -+ {0, 0, nullptr}}; -+ -+ escape_buf(in, inlen, out, outlen, control_rules, other_rules); -+} -+ -+static void json_escape(const char *in, size_t *inlen, char *out, -+ size_t *outlen) noexcept { -+ static const escape_rule_t control_rules[] = { -+ {0, 6, "\\u0000"}, {1, 6, "\\u0001"}, {2, 6, "\\u0002"}, -+ {3, 6, "\\u0003"}, {4, 6, "\\u0004"}, {5, 6, "\\u0005"}, -+ {6, 6, "\\u0006"}, {7, 6, "\\u0007"}, {'\b', 2, "\\b"}, -+ {'\t', 2, "\\t"}, {'\n', 2, "\\n"}, {11, 6, "\\u000B"}, -+ {'\f', 2, "\\f"}, {'\r', 2, "\\r"}, {14, 6, "\\u000E"}, -+ {15, 6, "\\u000F"}, {16, 6, "\\u0010"}, {17, 6, "\\u0011"}, -+ {18, 6, "\\u0012"}, {19, 6, "\\u0013"}, {20, 6, "\\u0014"}, -+ {21, 6, "\\u0015"}, {22, 6, "\\u0016"}, {23, 6, "\\u0017"}, -+ {24, 6, "\\u0018"}, {25, 6, "\\u0019"}, {26, 6, "\\u001A"}, -+ {27, 6, "\\u001B"}, {28, 6, "\\u001C"}, {29, 6, "\\u001D"}, -+ {30, 6, "\\u001E"}, {31, 6, "\\u001F"}, -+ }; -+ -+ static const escape_rule_t other_rules[] = { -+ {'\\', 2, "\\\\"}, {'"', 2, "\\\""}, {'/', 2, "\\/"}, {0, 0, NULL}}; -+ -+ escape_buf(in, inlen, out, outlen, control_rules, other_rules); -+} -+ -+static void csv_escape(const char *in, size_t *inlen, char *out, -+ size_t *outlen) noexcept { -+ // We do not have any standard control escape rules for CSVs -+ static const escape_rule_t control_rules[] = { -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, {0, 0, nullptr}, -+ }; -+ -+ static const escape_rule_t other_rules[] = {{'"', 2, "\"\""}, -+ {0, 0, nullptr}}; -+ -+ escape_buf(in, inlen, out, outlen, control_rules, other_rules); -+} -+ -+static const escape_buf_func_t format_escape_func[] = {xml_escape, xml_escape, -+ json_escape, csv_escape}; -+ -+/* -+ Calculate the size of the otput bufer needed to escape the string. -+ -+ @param[in] in Input string -+ @param[in] len Length of the input string -+ -+ @return -+ size of the otput bufer including trailing zero -+*/ -+static size_t calculate_escape_string_buf_len(const char *in, -+ size_t len) noexcept { -+ char tmp[128]; -+ size_t full_outlen = 0; -+ -+ while (len > 0) { -+ size_t tmp_size = sizeof(tmp); -+ size_t inlen = len; -+ format_escape_func[static_cast(audit_log_format)](in, &inlen, tmp, -+ &tmp_size); -+ in += inlen; -+ len -= inlen; -+ full_outlen += tmp_size; -+ } -+ return full_outlen + 1; -+} -+ -+/* -+ Escape string according to audit_log_format. -+ -+ @param[in] in Input string -+ @param[in] inlen Length of the input string -+ @param[in] out Output buffer -+ @param[in] outlen Length of the output buffer -+ @param[out] endptr A pointer to the character after the -+ last escaped character in the output -+ buffer -+ @param[out] full_outlen Length of the output buffer that would -+ be needed to store complete non-truncated -+ escaped input buffer -+ -+ @return -+ pointer to the beginning of the output buffer -+*/ -+static char *escape_string(const char *in, size_t inlen, char *out, -+ size_t outlen, char **endptr, -+ size_t *full_outlen) noexcept { -+ if (outlen == 0) { -+ if (endptr) *endptr = out; -+ if (full_outlen) *full_outlen += calculate_escape_string_buf_len(in, inlen); -+ } else if (in != nullptr) { -+ size_t inlen_res = inlen; -+ --outlen; -+ format_escape_func[static_cast(audit_log_format)](in, &inlen_res, out, -+ &outlen); -+ out[outlen] = 0; -+ if (endptr) *endptr = out + outlen + 1; -+ if (full_outlen) { -+ *full_outlen += outlen; -+ *full_outlen += -+ calculate_escape_string_buf_len(in + inlen_res, inlen - inlen_res); -+ } -+ } else { -+ *out = 0; -+ if (endptr) *endptr = out + 1; -+ if (full_outlen) ++(*full_outlen); -+ } -+ return out; -+} -+ -+static void my_plugin_perror(void) noexcept { -+ char errbuf[MYSYS_STRERROR_SIZE]; -+ my_strerror(errbuf, sizeof(errbuf), errno); -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, "Error: %s", errbuf); -+} -+ -+static void audit_log_write(const char *buf, size_t len) { -+ static bool write_error = false; -+ -+ if (audit_handler_write(log_handler, buf, len) < 0) { -+ if (!write_error) { -+ write_error = true; -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, -+ "Error writing to file %s.", audit_log_file); -+ my_plugin_perror(); -+ } -+ } else { -+ write_error = false; -+ } -+} -+ -+static char *make_argv(char *buf, size_t len, int argc, char **argv) noexcept { -+ size_t left = len; -+ -+ buf[0] = 0; -+ while (argc > 0 && left > 0) { -+ const int ret = -+ snprintf(buf + len - left, left, "%s%c", *argv, argc > 1 ? ' ' : 0); -+ assert(ret > 0); -+ if (ret < 0 || static_cast(ret) >= left) break; -+ left -= ret; -+ argc--; -+ argv++; -+ } -+ -+ return buf; -+} -+ -+static char *audit_log_audit_record(char *buf, size_t buflen, const char *name, -+ time_t t, size_t *outlen) noexcept { -+ char id_str[MAX_RECORD_ID_SIZE]; -+ char timestamp[MAX_TIMESTAMP_SIZE]; -+ char arg_buf[512]; -+ static const char *format_string[] = { -+ "\n", -+ -+ "\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " " MACHINE_TYPE "-" SYSTEM_TYPE -+ "\n" -+ "\n", -+ -+ "{\"audit_record\":{\"name\":\"%s\",\"record\":\"%s\"," -+ "\"timestamp\":\"%s\",\"mysql_version\":\"%s\"," -+ "\"startup_optionsi\":\"%s\"," -+ "\"os_version\":\"" MACHINE_TYPE "-" SYSTEM_TYPE "\"}}\n", -+ -+ "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"," -+ "\"" MACHINE_TYPE "-" SYSTEM_TYPE "\"\n"}; -+ -+ *outlen = snprintf( -+ buf, buflen, format_string[static_cast(audit_log_format)], name, -+ make_record_id(id_str, sizeof(id_str)), -+ make_timestamp(timestamp, sizeof(timestamp), t), server_version, -+ make_argv(arg_buf, sizeof(arg_buf), orig_argc - 1, orig_argv + 1)); -+ -+ /* make sure that record is not truncated */ -+ assert(buf + *outlen <= buf + buflen); -+ -+ return buf; -+} -+ -+static char *audit_log_general_record(char *buf, size_t buflen, -+ const char *name, time_t t, int status, -+ const mysql_event_general &event, -+ const char *default_db, -+ size_t *outlen) noexcept { -+ char id_str[MAX_RECORD_ID_SIZE]; -+ char timestamp[MAX_TIMESTAMP_SIZE]; -+ char *query, *user, *host, *external_user, *ip, *db; -+ char *endptr = buf, *endbuf = buf + buflen; -+ size_t full_outlen = 0, buflen_estimated; -+ size_t query_length; -+ -+ static const char *format_string[] = { -+ "\n", -+ -+ "\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %lu\n" -+ " %d\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ "\n", -+ -+ "{\"audit_record\":" -+ "{\"name\":\"%s\"," -+ "\"record\":\"%s\"," -+ "\"timestamp\":\"%s\"," -+ "\"command_class\":\"%s\"," -+ "\"connection_id\":\"%lu\"," -+ "\"status\":%d," -+ "\"sqltext\":\"%s\"," -+ "\"user\":\"%s\"," -+ "\"host\":\"%s\"," -+ "\"os_user\":\"%s\"," -+ "\"ip\":\"%s\"," -+ "\"db\":\"%s\"}}\n", -+ -+ ("\"%s\",\"%s\",\"%s\",\"%s\",\"%lu\",%d,\"%s\",\"%s\"," -+ "\"%s\",\"%s\",\"%s\",\"%s\"\n")}; -+ -+ query_length = -+ my_charset_utf8mb4_general_ci.mbmaxlen * event.general_query.length; -+ -+ /* Note: query_length is the maximun size using utf8m4(4 bytes) that -+ * event->general_query_length may use. In the if branch, we convert it to -+ * utf8mb4. We store the recalculated (real size) length to query variable -+ * and use the remaing of the buffer for the output that will be printed to -+ * audit log. Parameter char *buf must be big enough to store -+ * the query (using utf8mb4) + the full output of audit event, which will -+ * contain the query again. At the else branch we estime this size. -+ */ -+ if (query_length < (size_t)(endbuf - endptr)) { -+ uint errors; -+ query_length = -+ my_convert(endptr, query_length, &my_charset_utf8mb4_general_ci, -+ event.general_query.str, event.general_query.length, -+ event.general_charset, &errors); -+ query = endptr; -+ endptr += query_length; -+ -+ full_outlen += query_length; -+ -+ query = escape_string(query, query_length, endptr, endbuf - endptr, &endptr, -+ &full_outlen); -+ } else { -+ endptr = endbuf; -+ query = escape_string(event.general_query.str, event.general_query.length, -+ endptr, endbuf - endptr, &endptr, &full_outlen); -+ full_outlen *= my_charset_utf8mb4_general_ci.mbmaxlen; -+ full_outlen += query_length; -+ } -+ -+ user = escape_string(event.general_user.str, event.general_user.length, -+ endptr, endbuf - endptr, &endptr, &full_outlen); -+ host = escape_string(event.general_host.str, event.general_host.length, -+ endptr, endbuf - endptr, &endptr, &full_outlen); -+ external_user = escape_string(event.general_external_user.str, -+ event.general_external_user.length, endptr, -+ endbuf - endptr, &endptr, &full_outlen); -+ ip = escape_string(event.general_ip.str, event.general_ip.length, endptr, -+ endbuf - endptr, &endptr, &full_outlen); -+ db = escape_string(default_db, strlen(default_db), endptr, endbuf - endptr, -+ &endptr, &full_outlen); -+ -+ buflen_estimated = full_outlen + -+ strlen(format_string[static_cast(audit_log_format)]) + -+ strlen(name) + event.general_sql_command.length + -+ 20 + /* general_thread_id */ -+ 20 + /* status */ -+ MAX_RECORD_ID_SIZE + MAX_TIMESTAMP_SIZE; -+ if (buflen_estimated > buflen) { -+ *outlen = buflen_estimated; -+ return NULL; -+ } -+ -+ *outlen = snprintf(endptr, endbuf - endptr, -+ format_string[static_cast(audit_log_format)], name, -+ make_record_id(id_str, sizeof(id_str)), -+ make_timestamp(timestamp, sizeof(timestamp), t), -+ event.general_sql_command.str, event.general_thread_id, -+ status, query, user, host, external_user, ip, db); -+ -+ /* make sure that record is not truncated */ -+ assert(endptr + *outlen <= buf + buflen); -+ -+ return endptr; -+} -+ -+static char *audit_log_connection_record(char *buf, size_t buflen, -+ const char *name, time_t t, -+ const mysql_event_connection &event, -+ size_t *outlen) noexcept { -+ char id_str[MAX_RECORD_ID_SIZE]; -+ char timestamp[MAX_TIMESTAMP_SIZE]; -+ char *user, *priv_user, *external_user, *proxy_user, *host, *ip, *database; -+ char *endptr = buf, *endbuf = buf + buflen; -+ -+ static const char *format_string[] = { -+ "\n", -+ -+ "\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %lu\n" -+ " %d\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ " %s\n" -+ "\n", -+ -+ "{\"audit_record\":" -+ "{\"name\":\"%s\"," -+ "\"record\":\"%s\"," -+ "\"timestamp\":\"%s\"," -+ "\"connection_id\":\"%lu\"," -+ "\"status\":%d," -+ "\"user\":\"%s\"," -+ "\"priv_user\":\"%s\"," -+ "\"os_login\":\"%s\"," -+ "\"proxy_user\":\"%s\"," -+ "\"host\":\"%s\"," -+ "\"ip\":\"%s\"," -+ "\"db\":\"%s\"}}\n", -+ -+ ("\"%s\",\"%s\",\"%s\",\"%lu\",%d,\"%s\",\"%s\",\"%s\"," -+ "\"%s\",\"%s\",\"%s\",\"%s\"\n")}; -+ -+ user = escape_string(event.user.str, event.user.length, endptr, -+ endbuf - endptr, &endptr, nullptr); -+ priv_user = escape_string(event.priv_user.str, event.priv_user.length, endptr, -+ endbuf - endptr, &endptr, nullptr); -+ external_user = -+ escape_string(event.external_user.str, event.external_user.length, endptr, -+ endbuf - endptr, &endptr, nullptr); -+ proxy_user = escape_string(event.proxy_user.str, event.proxy_user.length, -+ endptr, endbuf - endptr, &endptr, nullptr); -+ host = escape_string(event.host.str, event.host.length, endptr, -+ endbuf - endptr, &endptr, nullptr); -+ ip = escape_string(event.ip.str, event.ip.length, endptr, endbuf - endptr, -+ &endptr, nullptr); -+ database = escape_string(event.database.str, event.database.length, endptr, -+ endbuf - endptr, &endptr, nullptr); -+ -+ assert((endptr - buf) * 2 + -+ strlen(format_string[static_cast(audit_log_format)]) + -+ strlen(name) + MAX_RECORD_ID_SIZE + MAX_TIMESTAMP_SIZE + -+ 20 + /* event.thread_id */ -+ 20 /* event.status */ -+ < buflen); -+ -+ *outlen = snprintf(endptr, endbuf - endptr, -+ format_string[static_cast(audit_log_format)], name, -+ make_record_id(id_str, sizeof(id_str)), -+ make_timestamp(timestamp, sizeof(timestamp), t), -+ event.connection_id, event.status, user, priv_user, -+ external_user, proxy_user, host, ip, database); -+ -+ /* make sure that record is not truncated */ -+ assert(endptr + *outlen <= buf + buflen); -+ -+ return endptr; -+} -+ -+static size_t audit_log_header(MY_STAT *stat, char *buf, -+ size_t buflen) noexcept { -+ static const char *const format_string[5] = { -+ "\n" -+ "\n", -+ "\n" -+ "\n", -+ "", ""}; -+ -+ assert(strcmp(system_charset_info->csname, "utf8mb3") == 0); -+ -+ log_file_time = stat->st_mtime; -+ -+ init_record_id(stat->st_size); -+ -+ if (buf == nullptr) { -+ return 0; -+ } -+ -+ return snprintf(buf, buflen, "%s", format_string[audit_log_format]); -+} -+ -+static size_t audit_log_footer(char *buf, size_t buflen) noexcept { -+ static const char *const format_string[] = {"\n", "\n", "", -+ ""}; -+ -+ if (buf == nullptr) { -+ return 0; -+ } -+ -+ return snprintf(buf, buflen, "%s", format_string[audit_log_format]); -+} -+ -+static int init_new_log_file() noexcept { -+ if (audit_log_handler == audit_log_handler_t::HANDLER_FILE) { -+ audit_handler_file_config_t opts; -+ opts.name = audit_log_file; -+ opts.rotate_on_size = audit_log_rotate_on_size; -+ opts.rotations = audit_log_rotations; -+ opts.sync_on_write = -+ audit_log_strategy == audit_log_strategy_t::SYNCHRONOUS; -+ opts.use_buffer = -+ audit_log_strategy < audit_log_strategy_t::SEMISYNCHRONOUS; -+ opts.buffer_size = audit_log_buffer_size; -+ opts.can_drop_data = -+ audit_log_strategy == audit_log_strategy_t::PERFORMANCE; -+ opts.header = audit_log_header; -+ opts.footer = audit_log_footer; -+ -+ log_handler = audit_handler_file_open(&opts); -+ if (log_handler == nullptr) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, "Cannot open file %s.", -+ audit_log_file); -+ my_plugin_perror(); -+ return (1); -+ } -+ } else { -+ audit_handler_syslog_config_t opts; -+ opts.facility = audit_log_syslog_facility_codes[audit_log_syslog_facility]; -+ opts.ident = audit_log_syslog_ident; -+ opts.priority = audit_log_syslog_priority_codes[audit_log_syslog_priority]; -+ opts.header = audit_log_header; -+ opts.footer = audit_log_footer; -+ -+ log_handler = audit_handler_syslog_open(&opts); -+ if (log_handler == nullptr) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, "Cannot open syslog."); -+ my_plugin_perror(); -+ return (1); -+ } -+ } -+ -+ return (0); -+} -+ -+static int reopen_log_file() { -+ if (audit_handler_flush(log_handler)) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, "Cannot open file %s.", -+ audit_log_file); -+ my_plugin_perror(); -+ return (1); -+ } -+ -+ return (0); -+} -+ -+struct query_stack_frame { -+ /* number of included databases */ -+ int databases_included; -+ /* number of excluded databases */ -+ int databases_excluded; -+ /* number of accessed databases */ -+ int databases_accessed; -+ /* query */ -+ const char *query; -+}; -+ -+struct query_stack { -+ size_t size; -+ size_t top; -+ query_stack_frame *frames; -+}; -+ -+/* -+ Struct to store various THD specific data -+ */ -+struct audit_log_thd_local { -+ /* size of allocated large buffer for record formatting */ -+ size_t record_buffer_size; -+ /* large buffer for record formatting */ -+ char *record_buffer; -+ /* skip session logging */ -+ bool skip_session; -+ /* skip logging for the next query */ -+ bool skip_query; -+ /* default database */ -+ char db[NAME_LEN + 1]; -+ /* default database candidate */ -+ char init_db_query[NAME_LEN + 1]; -+ /* call stack */ -+ query_stack stack; -+}; -+ -+/* -+ Return pointer to THD specific data. -+ */ -+static audit_log_thd_local *get_thd_local(MYSQL_THD thd) noexcept; -+ -+/* -+ Allocate and return buffer of given size. -+ */ -+static char *get_record_buffer(MYSQL_THD thd, size_t size) noexcept; -+ -+/* -+ Allocate and return given number of stack frames. -+ */ -+static query_stack_frame *realloc_stack_frames(MYSQL_THD thd, -+ size_t size) noexcept; -+ -+static int audit_log_plugin_init(MYSQL_PLUGIN plugin_info) { -+ char buf[1024]; -+ size_t len; -+ int count; -+ -+ plugin_ptr = plugin_info; -+ -+ count = array_elements(all_audit_log_memory); -+ mysql_memory_register(AUDIT_LOG_PSI_CATEGORY, all_audit_log_memory, count); -+ logger_init_mutexes(); -+ -+ audit_log_filter_init(); -+ -+ if (audit_log_exclude_accounts != nullptr && -+ audit_log_include_accounts != nullptr) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, -+ "Both 'audit_log_exclude_accounts' and " -+ "'audit_log_include_accounts' are not NULL\n"); -+ return 1; -+ } -+ -+ if (audit_log_exclude_commands != nullptr && -+ audit_log_include_commands != nullptr) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, -+ "Both 'audit_log_exclude_commands' and " -+ "'audit_log_include_commands' are not NULL\n"); -+ return 1; -+ } -+ -+ if (audit_log_exclude_databases != nullptr && -+ audit_log_include_databases != nullptr) { -+ my_plugin_log_message(&plugin_ptr, MY_ERROR_LEVEL, -+ "Both 'audit_log_exclude_databases' and " -+ "'audit_log_include_databases' are not NULL\n"); -+ return 1; -+ } -+ -+ if (audit_log_exclude_accounts != nullptr) { -+ audit_log_set_exclude_accounts(audit_log_exclude_accounts); -+ } -+ if (audit_log_include_accounts != nullptr) { -+ audit_log_set_include_accounts(audit_log_include_accounts); -+ } -+ if (audit_log_exclude_commands != nullptr) { -+ audit_log_set_exclude_commands(audit_log_exclude_commands); -+ } -+ if (audit_log_include_commands != nullptr) { -+ audit_log_set_include_commands(audit_log_include_commands); -+ } -+ if (audit_log_exclude_databases != nullptr) { -+ audit_log_set_exclude_databases(audit_log_exclude_databases); -+ } -+ if (audit_log_include_databases != nullptr) { -+ audit_log_set_include_databases(audit_log_include_databases); -+ } -+ -+ if (init_new_log_file()) return (1); -+ -+ if (audit_log_audit_record(buf, sizeof(buf), "Audit", time(nullptr), &len)) -+ audit_log_write(buf, len); -+ -+ return 0; -+} -+ -+static int audit_log_plugin_deinit(void *arg [[maybe_unused]]) { -+ char buf[1024]; -+ size_t len; -+ -+ if (audit_log_audit_record(buf, sizeof(buf), "NoAudit", time(nullptr), &len)) -+ audit_log_write(buf, len); -+ -+ audit_handler_close(log_handler); -+ -+ audit_log_filter_destroy(); -+ -+ return 0; -+} -+ -+static bool is_event_class_allowed_by_policy(mysql_event_class_t event_class, -+ ulong policy) noexcept { -+ static const unsigned int class_mask[] = { -+ /* ALL */ -+ (1 << MYSQL_AUDIT_GENERAL_CLASS) | (1 << MYSQL_AUDIT_CONNECTION_CLASS), -+ 0, /* NONE */ -+ (1 << MYSQL_AUDIT_CONNECTION_CLASS), /* LOGINS */ -+ (1 << MYSQL_AUDIT_GENERAL_CLASS), /* QUERIES */ -+ }; -+ -+ return (class_mask[policy] & (1 << event_class)) != 0; -+} -+ -+static const char *next_word(const char *str, size_t *len, -+ const CHARSET_INFO *charset) noexcept { -+ while (*str && my_isspace(charset, *str)) { -+ if (*str == '/' && str[1] == '*' && str[2] == '!') -+ str += 3; -+ else if (*str == '/' && str[1] == '*') { -+ while (*str && !(*str == '*' && str[1] == '/')) str++; -+ } else -+ str++; -+ } -+ -+ *len = 0; -+ while (str[*len] && my_isvar(charset, str[*len])) (*len)++; -+ -+ if (*len == 0 && *str == '`') { -+ (*len)++; -+ while (str[*len]) { -+ if (str[*len] == '`' && str[*len + 1] == '`') -+ (*len)++; -+ else if (str[*len] == '`') -+ break; -+ (*len)++; -+ } -+ (*len)++; -+ } -+ -+ return str; -+} -+ -+static bool audit_log_update_thd_local(MYSQL_THD thd, -+ audit_log_thd_local *local, -+ unsigned int event_class, -+ const void *event) { -+ assert(audit_log_include_accounts == nullptr || -+ audit_log_exclude_accounts == nullptr); -+ -+ assert(audit_log_include_databases == nullptr || -+ audit_log_exclude_databases == nullptr); -+ -+ assert(audit_log_include_commands == nullptr || -+ audit_log_exclude_commands == nullptr); -+ -+ if (event_class == MYSQL_AUDIT_CONNECTION_CLASS) { -+ const mysql_event_connection *event_connection = -+ (const mysql_event_connection *)event; -+ LEX_STRING priv_user, priv_host; -+ MYSQL_SECURITY_CONTEXT ctx; -+ -+ if (thd_get_security_context(thd, &ctx)) { -+ my_message(ER_AUDIT_API_ABORT, "Error: can not get security context", -+ MYF(0)); -+ return false; -+ } -+ -+ if (security_context_get_option(ctx, "priv_user", &priv_user)) { -+ my_message(ER_AUDIT_API_ABORT, -+ "Error: can not get priv_user from " -+ "security context", -+ MYF(0)); -+ return false; -+ } -+ -+ if (security_context_get_option(ctx, "priv_host", &priv_host)) { -+ my_message(ER_AUDIT_API_ABORT, -+ "Error: can not get priv_host from " -+ "security context", -+ MYF(0)); -+ return false; -+ } -+ -+ local->skip_session = false; -+ if (audit_log_include_accounts != nullptr && -+ !audit_log_check_account_included(priv_user.str, priv_user.length, -+ priv_host.str, priv_host.length)) -+ local->skip_session = true; -+ if (audit_log_exclude_accounts != nullptr && -+ audit_log_check_account_excluded(priv_user.str, priv_user.length, -+ priv_host.str, priv_host.length)) -+ local->skip_session = true; -+ -+ if (event_connection->status == 0) { -+ /* track default DB change */ -+ assert(event_connection->database.length <= sizeof(local->db)); -+ if (event_connection->database.str != nullptr) -+ memcpy(local->db, event_connection->database.str, -+ event_connection->database.length); -+ local->db[event_connection->database.length] = 0; -+ } -+ } else if (event_class == MYSQL_AUDIT_GENERAL_CLASS) { -+ const mysql_event_general *event_general = -+ (const mysql_event_general *)event; -+ -+ if (event_general->event_subclass == MYSQL_AUDIT_GENERAL_STATUS) { -+ local->skip_query = false; -+ -+ if (local->stack.frames[local->stack.top].query == -+ event_general->general_query.str) { -+ local->skip_query |= -+ audit_log_include_databases && -+ local->stack.frames[local->stack.top].databases_accessed > 0 && -+ local->stack.frames[local->stack.top].databases_included == 0; -+ -+ local->skip_query |= -+ audit_log_exclude_databases && -+ local->stack.frames[local->stack.top].databases_accessed > 0 && -+ local->stack.frames[local->stack.top].databases_excluded == -+ local->stack.frames[local->stack.top].databases_accessed; -+ -+ local->stack.frames[local->stack.top].databases_included = 0; -+ local->stack.frames[local->stack.top].databases_accessed = 0; -+ local->stack.frames[local->stack.top].databases_excluded = 0; -+ local->stack.frames[local->stack.top].query = nullptr; -+ -+ if (local->stack.top > 0) --local->stack.top; -+ } -+ -+ local->skip_query |= audit_log_include_commands && -+ !audit_log_check_command_included( -+ event_general->general_sql_command.str, -+ event_general->general_sql_command.length); -+ -+ local->skip_query |= audit_log_exclude_commands && -+ audit_log_check_command_excluded( -+ event_general->general_sql_command.str, -+ event_general->general_sql_command.length); -+ -+ if (!local->skip_query && -+ ((event_general->general_command.length == 4 && -+ strncmp(event_general->general_command.str, "Quit", 4) == 0) || -+ (event_general->general_command.length == 11 && -+ strncmp(event_general->general_command.str, "Change user", 11) == -+ 0))) -+ local->skip_query = true; -+ } -+ -+ if (event_general->event_subclass == MYSQL_AUDIT_GENERAL_LOG && -+ event_general->general_command.length == 7 && -+ strncmp(event_general->general_command.str, "Init DB", 7) == 0 && -+ event_general->general_query.str != nullptr && -+ strpbrk("\n\r\t ", event_general->general_query.str) == nullptr) { -+ /* Database is about to be changed. Server doesn't provide database -+ name in STATUS event, so remember it now. */ -+ -+ assert(event_general->general_query.length <= sizeof(local->db)); -+ memcpy(local->db, event_general->general_query.str, -+ event_general->general_query.length); -+ local->db[event_general->general_query.length] = 0; -+ } -+ if (event_general->event_subclass == MYSQL_AUDIT_GENERAL_STATUS && -+ event_general->general_sql_command.length == 9 && -+ strncmp(event_general->general_sql_command.str, "change_db", 9) == 0 && -+ event_general->general_command.length == 5 && -+ strncmp(event_general->general_command.str, "Query", 5) == 0 && -+ event_general->general_error_code == 0) { -+ /* it's "use dbname" query */ -+ -+ size_t len; -+ const char *word; -+ -+ word = next_word(event_general->general_query.str, &len, -+ event_general->general_charset); -+ if (strncasecmp("use", word, len) == 0) { -+ uint errors; -+ -+ word = next_word(word + len, &len, event_general->general_charset); -+ if (*word == '`') { -+ word++; -+ len -= 2; -+ } -+ len = my_convert(local->db, sizeof(local->db) - 1, system_charset_info, -+ word, len, event_general->general_charset, &errors); -+ local->db[len] = 0; -+ } -+ } -+ } else if (event_class == MYSQL_AUDIT_TABLE_ACCESS_CLASS) { -+ const mysql_event_table_access *event_table = -+ (const mysql_event_table_access *)event; -+ -+ if (local->stack.frames[local->stack.top].query != event_table->query.str && -+ local->stack.frames[local->stack.top].query != nullptr) { -+ if (++local->stack.top >= local->stack.size) -+ realloc_stack_frames(thd, local->stack.size * 2); -+ } -+ local->stack.frames[local->stack.top].query = event_table->query.str; -+ -+ ++local->stack.frames[local->stack.top].databases_accessed; -+ -+ if (audit_log_include_databases != nullptr && -+ audit_log_check_database_included(event_table->table_database.str, -+ event_table->table_database.length)) -+ ++local->stack.frames[local->stack.top].databases_included; -+ -+ if (audit_log_exclude_databases != nullptr && -+ audit_log_check_database_excluded(event_table->table_database.str, -+ event_table->table_database.length)) -+ ++local->stack.frames[local->stack.top].databases_excluded; -+ } -+ return true; -+} -+ -+static int audit_log_notify(MYSQL_THD thd, mysql_event_class_t event_class, -+ const void *event) { -+ audit_log_thd_local *local = get_thd_local(thd); -+ if (!audit_log_update_thd_local(thd, local, event_class, event)) return 1; -+ -+ if (!is_event_class_allowed_by_policy(event_class, audit_log_policy)) -+ return 0; -+ -+ if (local->skip_session) return 0; -+ -+ char buf[4096]; -+ char *log_rec; -+ size_t len, buflen; -+ if (event_class == MYSQL_AUDIT_GENERAL_CLASS) { -+ const mysql_event_general *event_general = -+ (const mysql_event_general *)event; -+ switch (event_general->event_subclass) { -+ case MYSQL_AUDIT_GENERAL_STATUS: { -+ if (local->skip_query) break; -+ -+ /* use allocated buffer if available */ -+ char *allocated_buf = get_record_buffer(thd, 0); -+ if (allocated_buf != nullptr) { -+ log_rec = allocated_buf; -+ buflen = local->record_buffer_size; -+ } else { -+ log_rec = buf; -+ buflen = sizeof(buf); -+ } -+ log_rec = audit_log_general_record( -+ log_rec, buflen, event_general->general_command.str, -+ event_general->general_time, event_general->general_error_code, -+ *event_general, local->db, &len); -+ if (len > buflen) { -+ buflen = len + 1024; -+ log_rec = audit_log_general_record( -+ get_record_buffer(thd, buflen), buflen, -+ event_general->general_command.str, event_general->general_time, -+ event_general->general_error_code, *event_general, local->db, -+ &len); -+ assert(log_rec); -+ } -+ if (log_rec) audit_log_write(log_rec, len); -+ break; -+ } -+ case MYSQL_AUDIT_GENERAL_LOG: -+ case MYSQL_AUDIT_GENERAL_ERROR: -+ case MYSQL_AUDIT_GENERAL_RESULT: -+ break; -+ } -+ } else if (event_class == MYSQL_AUDIT_CONNECTION_CLASS) { -+ const mysql_event_connection *event_connection = -+ (const mysql_event_connection *)event; -+ switch (event_connection->event_subclass) { -+ case MYSQL_AUDIT_CONNECTION_CONNECT: -+ log_rec = -+ audit_log_connection_record(buf, sizeof(buf), "Connect", -+ time(nullptr), *event_connection, &len); -+ break; -+ case MYSQL_AUDIT_CONNECTION_DISCONNECT: -+ log_rec = audit_log_connection_record( -+ buf, sizeof(buf), "Quit", time(nullptr), *event_connection, &len); -+ break; -+ case MYSQL_AUDIT_CONNECTION_CHANGE_USER: -+ log_rec = -+ audit_log_connection_record(buf, sizeof(buf), "Change user", -+ time(nullptr), *event_connection, &len); -+ break; -+ default: -+ log_rec = nullptr; -+ len = 0; -+ break; -+ } -+ if (log_rec) audit_log_write(log_rec, len); -+ } -+ return 0; -+} -+ -+/* -+ * Plugin system vars -+ */ -+ -+static MYSQL_SYSVAR_STR(file, audit_log_file, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | -+ PLUGIN_VAR_MEMALLOC, -+ "The name of the log file.", nullptr, nullptr, -+ default_audit_log_file); -+ -+static const char *audit_log_policy_names[] = {"ALL", "NONE", "LOGINS", -+ "QUERIES", nullptr}; -+ -+static TYPELIB audit_log_policy_typelib = { -+ array_elements(audit_log_policy_names) - 1, "audit_log_policy_typelib", -+ audit_log_policy_names, nullptr}; -+ -+static MYSQL_SYSVAR_ENUM( -+ policy, audit_log_policy, PLUGIN_VAR_RQCMDARG, -+ "The policy controlling the information written by the audit log " -+ "plugin to its log file.", -+ NULL, NULL, audit_log_policy_t::ALL, &audit_log_policy_typelib); -+ -+static const char *audit_log_strategy_names[] = { -+ "ASYNCHRONOUS", "PERFORMANCE", "SEMISYNCHRONOUS", "SYNCHRONOUS", nullptr}; -+static TYPELIB audit_log_strategy_typelib = { -+ array_elements(audit_log_strategy_names) - 1, "audit_log_strategy_typelib", -+ audit_log_strategy_names, nullptr}; -+ -+static MYSQL_SYSVAR_ENUM(strategy, audit_log_strategy, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, -+ "The logging method used by the audit log plugin, " -+ "if FILE handler is used.", -+ nullptr, nullptr, ASYNCHRONOUS, -+ &audit_log_strategy_typelib); -+ -+static const char *audit_log_format_names[] = {"OLD", "NEW", "JSON", "CSV", -+ nullptr}; -+static TYPELIB audit_log_format_typelib = { -+ array_elements(audit_log_format_names) - 1, "audit_log_format_typelib", -+ audit_log_format_names, nullptr}; -+ -+static MYSQL_SYSVAR_ENUM(format, audit_log_format, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, -+ "The audit log file format.", nullptr, nullptr, -+ ASYNCHRONOUS, &audit_log_format_typelib); -+ -+static const char *audit_log_handler_names[] = {"FILE", "SYSLOG", nullptr}; -+static TYPELIB audit_log_handler_typelib = { -+ array_elements(audit_log_handler_names) - 1, "audit_log_handler_typelib", -+ audit_log_handler_names, nullptr}; -+ -+static MYSQL_SYSVAR_ENUM(handler, audit_log_handler, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, -+ "The audit log handler.", nullptr, nullptr, -+ HANDLER_FILE, &audit_log_handler_typelib); -+ -+static MYSQL_SYSVAR_ULONGLONG( -+ buffer_size, audit_log_buffer_size, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, -+ "The size of the buffer for asynchronous logging, " -+ "if FILE handler is used.", -+ NULL, NULL, 1048576UL, 4096UL, ULLONG_MAX, 4096UL); -+ -+static void audit_log_rotate_on_size_update( -+ MYSQL_THD thd [[maybe_unused]], SYS_VAR *var [[maybe_unused]], -+ void *var_ptr [[maybe_unused]], const void *save) noexcept { -+ ulonglong new_val = *(const ulonglong *)(save); -+ -+ audit_handler_set_option(log_handler, audit_handler_option_t::ROTATE_ON_SIZE, -+ &new_val); -+ -+ audit_log_rotate_on_size = new_val; -+} -+ -+static MYSQL_SYSVAR_ULONGLONG( -+ rotate_on_size, audit_log_rotate_on_size, PLUGIN_VAR_RQCMDARG, -+ "Maximum size of the log to start the rotation, if FILE handler is used.", -+ NULL, audit_log_rotate_on_size_update, 0UL, 0UL, ULLONG_MAX, 4096UL); -+ -+static void audit_log_rotations_update(MYSQL_THD thd [[maybe_unused]], -+ SYS_VAR *var [[maybe_unused]], -+ void *var_ptr [[maybe_unused]], -+ const void *save) noexcept { -+ ulonglong new_val = *(const ulonglong *)(save); -+ -+ audit_handler_set_option(log_handler, audit_handler_option_t::ROTATIONS, -+ &new_val); -+ -+ audit_log_rotations = new_val; -+} -+ -+static MYSQL_SYSVAR_ULONGLONG( -+ rotations, audit_log_rotations, PLUGIN_VAR_RQCMDARG, -+ "Maximum number of rotations to keep, if FILE handler is used.", NULL, -+ audit_log_rotations_update, 0UL, 0UL, 999UL, 1UL); -+ -+static void audit_log_flush_update(MYSQL_THD thd [[maybe_unused]], -+ SYS_VAR *var [[maybe_unused]], -+ void *var_ptr [[maybe_unused]], -+ const void *save) { -+ char new_val = *(const char *)(save); -+ -+ if (new_val != audit_log_flush && new_val) { -+ audit_log_flush = true; -+ reopen_log_file(); -+ audit_log_flush = false; -+ } -+} -+ -+static MYSQL_SYSVAR_BOOL(flush, audit_log_flush, PLUGIN_VAR_OPCMDARG, -+ "Flush the log file.", nullptr, audit_log_flush_update, -+ false); -+ -+static MYSQL_SYSVAR_STR( -+ syslog_ident, audit_log_syslog_ident, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC, -+ "The string that will be prepended to each log message, " -+ "if SYSLOG handler is used.", -+ nullptr, nullptr, default_audit_log_syslog_ident); -+ -+static TYPELIB audit_log_syslog_facility_typelib = { -+ array_elements(audit_log_syslog_facility_names) - 1, -+ "audit_log_syslog_facility_typelib", audit_log_syslog_facility_names, -+ nullptr}; -+ -+static MYSQL_SYSVAR_ENUM( -+ syslog_facility, audit_log_syslog_facility, PLUGIN_VAR_RQCMDARG, -+ "The syslog facility to assign to messages, if SYSLOG handler is used.", -+ nullptr, nullptr, 0, &audit_log_syslog_facility_typelib); -+ -+static TYPELIB audit_log_syslog_priority_typelib = { -+ array_elements(audit_log_syslog_priority_names) - 1, -+ "audit_log_syslog_priority_typelib", audit_log_syslog_priority_names, -+ nullptr}; -+ -+static MYSQL_SYSVAR_ENUM( -+ syslog_priority, audit_log_syslog_priority, PLUGIN_VAR_RQCMDARG, -+ "Priority to be assigned to all messages written to syslog.", nullptr, -+ nullptr, 0, &audit_log_syslog_priority_typelib); -+ -+static MYSQL_THDVAR_STR(record_buffer, -+ PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC | -+ PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT, -+ "Buffer for query formatting.", nullptr, nullptr, ""); -+ -+static MYSQL_THDVAR_STR(query_stack, -+ PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC | -+ PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT, -+ "Query stack.", nullptr, nullptr, ""); -+ -+static int audit_log_exclude_accounts_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_include_accounts) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_exclude_accounts_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, const void *save) { -+ assert(audit_log_include_accounts == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_exclude_accounts != nullptr) { -+ audit_log_set_exclude_accounts(audit_log_exclude_accounts); -+ } else { -+ audit_log_set_exclude_accounts(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR(exclude_accounts, audit_log_exclude_accounts, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of accounts " -+ "for which events should not be logged.", -+ audit_log_exclude_accounts_validate, -+ audit_log_exclude_accounts_update, nullptr); -+ -+static int audit_log_include_accounts_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_exclude_accounts) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_include_accounts_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, const void *save) { -+ assert(audit_log_exclude_accounts == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_include_accounts != nullptr) { -+ audit_log_set_include_accounts(audit_log_include_accounts); -+ } else { -+ audit_log_set_include_accounts(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR( -+ include_accounts, audit_log_include_accounts, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of accounts for which events should be logged.", -+ audit_log_include_accounts_validate, audit_log_include_accounts_update, -+ nullptr); -+ -+static int audit_log_exclude_databases_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_include_databases) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_exclude_databases_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, -+ const void *save) { -+ assert(audit_log_include_databases == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_exclude_databases != nullptr) { -+ audit_log_set_exclude_databases(audit_log_exclude_databases); -+ } else { -+ audit_log_set_exclude_databases(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR(exclude_databases, audit_log_exclude_databases, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of databases " -+ "for which events should not be logged.", -+ audit_log_exclude_databases_validate, -+ audit_log_exclude_databases_update, nullptr); -+ -+static int audit_log_include_databases_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_exclude_databases) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_include_databases_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, -+ const void *save) { -+ assert(audit_log_exclude_databases == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_include_databases != nullptr) { -+ audit_log_set_include_databases(audit_log_include_databases); -+ } else { -+ audit_log_set_include_databases(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR( -+ include_databases, audit_log_include_databases, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of databases for which events should be logged.", -+ audit_log_include_databases_validate, audit_log_include_databases_update, -+ nullptr); -+ -+static int audit_log_exclude_commands_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_include_commands) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_exclude_commands_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, const void *save) { -+ assert(audit_log_include_commands == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_exclude_commands != nullptr) { -+ audit_log_set_exclude_commands(audit_log_exclude_commands); -+ } else { -+ audit_log_set_exclude_commands(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR(exclude_commands, audit_log_exclude_commands, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of commands " -+ "for which events should not be logged.", -+ audit_log_exclude_commands_validate, -+ audit_log_exclude_commands_update, nullptr); -+ -+static int audit_log_include_commands_validate(MYSQL_THD thd, SYS_VAR *var, -+ void *save, -+ st_mysql_value *value) { -+ if (audit_log_exclude_commands) { -+ return 1; -+ } -+ -+ return check_func_str(thd, var, save, value); -+} -+ -+static void audit_log_include_commands_update(MYSQL_THD thd, SYS_VAR *var, -+ void *var_ptr, const void *save) { -+ assert(audit_log_exclude_commands == nullptr); -+ -+ update_func_str(thd, var, var_ptr, save); -+ -+ if (audit_log_include_commands != nullptr) { -+ audit_log_set_include_commands(audit_log_include_commands); -+ } else { -+ audit_log_set_include_commands(""); -+ } -+} -+ -+static MYSQL_SYSVAR_STR( -+ include_commands, audit_log_include_commands, -+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, -+ "Comma separated list of commands for which events should be logged.", -+ audit_log_include_commands_validate, audit_log_include_commands_update, -+ nullptr); -+ -+static MYSQL_THDVAR_STR(local, -+ PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC | -+ PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT, -+ "Local store.", nullptr, nullptr, ""); -+ -+static MYSQL_THDVAR_ULONG(local_ptr, -+ PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | -+ PLUGIN_VAR_NOCMDOPT, -+ "Local store ptr.", nullptr, nullptr, 0, 0, ULONG_MAX, -+ 0); -+ -+static SYS_VAR *audit_log_system_variables[] = {MYSQL_SYSVAR(file), -+ MYSQL_SYSVAR(policy), -+ MYSQL_SYSVAR(strategy), -+ MYSQL_SYSVAR(format), -+ MYSQL_SYSVAR(buffer_size), -+ MYSQL_SYSVAR(rotate_on_size), -+ MYSQL_SYSVAR(rotations), -+ MYSQL_SYSVAR(flush), -+ MYSQL_SYSVAR(handler), -+ MYSQL_SYSVAR(syslog_ident), -+ MYSQL_SYSVAR(syslog_priority), -+ MYSQL_SYSVAR(syslog_facility), -+ MYSQL_SYSVAR(record_buffer), -+ MYSQL_SYSVAR(query_stack), -+ MYSQL_SYSVAR(exclude_accounts), -+ MYSQL_SYSVAR(include_accounts), -+ MYSQL_SYSVAR(exclude_databases), -+ MYSQL_SYSVAR(include_databases), -+ MYSQL_SYSVAR(exclude_commands), -+ MYSQL_SYSVAR(include_commands), -+ MYSQL_SYSVAR(local), -+ MYSQL_SYSVAR(local_ptr), -+ NULL}; -+ -+static char thd_local_init_buf[sizeof(audit_log_thd_local)]; -+ -+static void MY_ATTRIBUTE((constructor)) audit_log_so_init() noexcept { -+ memset(thd_local_init_buf, 1, sizeof(thd_local_init_buf) - 1); -+ thd_local_init_buf[sizeof(thd_local_init_buf) - 1] = 0; -+} -+ -+/* -+ Return pointer to THD specific data. -+ */ -+static audit_log_thd_local *get_thd_local(MYSQL_THD thd) noexcept { -+ auto *thd_local = -+ reinterpret_cast(THDVAR(thd, local_ptr)); -+ -+ static_assert(sizeof(THDVAR(thd, local_ptr)) >= sizeof(void *), -+ "THD::local_ptr must be at least pointer-big"); -+ -+ if (unlikely(thd_local == nullptr)) { -+ THDVAR_SET(thd, local, thd_local_init_buf); -+ thd_local = (audit_log_thd_local *)THDVAR(thd, local); -+ memset(thd_local, 0, sizeof(audit_log_thd_local)); -+ THDVAR(thd, local_ptr) = (ulong)thd_local; -+ -+ realloc_stack_frames(thd, 4); -+ } -+ return thd_local; -+} -+ -+/* -+ Allocate and return buffer of given size. -+ */ -+static char *get_record_buffer(MYSQL_THD thd, size_t size) noexcept { -+ auto *thd_local = get_thd_local(thd); -+ char *buf = thd_local->record_buffer; -+ -+ if (thd_local->record_buffer_size < size) { -+ thd_local->record_buffer_size = size; -+ -+ buf = (char *)my_malloc(PSI_NOT_INSTRUMENTED, size, MYF(MY_FAE)); -+ memset(buf, 1, size - 1); -+ buf[size - 1] = 0; -+ -+ THDVAR_SET(thd, record_buffer, buf); -+ -+ my_free(buf); -+ -+ buf = (char *)THDVAR(thd, record_buffer); -+ thd_local->record_buffer = buf; -+ } -+ -+ return buf; -+} -+ -+/* -+ Allocate and return given number of stack frames. -+ */ -+static query_stack_frame *realloc_stack_frames(MYSQL_THD thd, -+ size_t size) noexcept { -+ auto *thd_local = get_thd_local(thd); -+ auto *stack = reinterpret_cast(THDVAR(thd, query_stack)); -+ -+ if (thd_local->stack.size < size) { -+ char *buf = (char *)my_malloc( -+ PSI_NOT_INSTRUMENTED, -+ (thd_local->stack.size + size) * sizeof(query_stack_frame), -+ MYF(MY_FAE)); -+ memset(buf + thd_local->stack.size * sizeof(query_stack_frame), 1, -+ size * sizeof(query_stack_frame) - 1); -+ buf[(thd_local->stack.size + size) * sizeof(query_stack_frame) - 1] = 0; -+ if (thd_local->stack.size > 0) -+ memcpy(buf, stack, thd_local->stack.size * sizeof(query_stack_frame)); -+ THDVAR_SET(thd, query_stack, -+ buf + thd_local->stack.size * sizeof(query_stack_frame)); -+ stack = (query_stack_frame *)THDVAR(thd, query_stack); -+ memset(stack, 0, size * sizeof(query_stack_frame)); -+ if (thd_local->stack.size > 0) -+ memcpy(stack, buf, thd_local->stack.size * sizeof(query_stack_frame)); -+ thd_local->stack.frames = stack; -+ thd_local->stack.size = size; -+ my_free(buf); -+ } -+ -+ return stack; -+} -+ -+/* -+ Plugin type-specific descriptor -+*/ -+static st_mysql_audit audit_log_descriptor = { -+ MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */ -+ nullptr, /* release_thd function */ -+ audit_log_notify, /* notify function */ -+ {MYSQL_AUDIT_GENERAL_ALL, MYSQL_AUDIT_CONNECTION_ALL, 0, 0, -+ MYSQL_AUDIT_TABLE_ACCESS_ALL, 0, 0, 0, 0, 0} /* class mask */ -+}; -+ -+/* -+ Plugin status variables for SHOW STATUS -+*/ -+static int show_audit_log_buffer_size_overflow(THD *, SHOW_VAR *var, -+ char *buff) { -+ var->type = SHOW_LONG; -+ var->value = buff; -+ uint64_t *value = reinterpret_cast(buff); -+ *value = static_cast( -+ audit_log_buffer_size_overflow.load(std::memory_order_relaxed)); -+ return 0; -+} -+static SHOW_VAR audit_log_status_variables[] = { -+ {"Audit_log_buffer_size_overflow", -+ (char *)&show_audit_log_buffer_size_overflow, SHOW_FUNC, -+ SHOW_SCOPE_GLOBAL}, -+ {NullS, NullS, SHOW_LONG, SHOW_SCOPE_GLOBAL}}; -+ -+/* -+ Plugin library descriptor -+*/ -+ -+mysql_declare_plugin(audit_log){ -+ MYSQL_AUDIT_PLUGIN, /* type */ -+ &audit_log_descriptor, /* descriptor */ -+ "audit_log", /* name */ -+ "Percona LLC and/or its affiliates.", /* author */ -+ "Audit log", /* description */ -+ PLUGIN_LICENSE_GPL, -+ audit_log_plugin_init, /* init function (when loaded) */ -+ nullptr, -+ audit_log_plugin_deinit, /* deinit function (when unloaded) */ -+ PLUGIN_VERSION, /* version */ -+ audit_log_status_variables, /* status variables */ -+ audit_log_system_variables, /* system variables */ -+ nullptr, -+ 0, -+} mysql_declare_plugin_end; -diff --git a/plugin/audit_log/audit_log.h b/plugin/audit_log/audit_log.h -new file mode 100644 -index 00000000000..508c792234c ---- /dev/null -+++ b/plugin/audit_log/audit_log.h -@@ -0,0 +1,34 @@ -+/* Copyright (c) 2015-2016 Percona LLC and/or its affiliates. All rights -+ reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#ifndef AUDIT_LOG_H_INCLUDED -+#define AUDIT_LOG_H_INCLUDED -+ -+#include -+#include "mysql/psi/psi_memory.h" -+ -+extern PSI_memory_key key_memory_audit_log_logger_handle; -+extern PSI_memory_key key_memory_audit_log_handler; -+extern PSI_memory_key key_memory_audit_log_buffer; -+extern PSI_memory_key key_memory_audit_log_accounts; -+extern PSI_memory_key key_memory_audit_log_databases; -+extern PSI_memory_key key_memory_audit_log_commands; -+extern std::atomic audit_log_buffer_size_overflow; -+ -+static const constexpr auto AUDIT_LOG_PSI_CATEGORY = "audit_log"; -+ -+#endif /* AUDIT_LOG_H_INCLUDED */ -diff --git a/plugin/audit_log/audit_syslog.cc b/plugin/audit_log/audit_syslog.cc -new file mode 100644 -index 00000000000..8095071fe1e ---- /dev/null -+++ b/plugin/audit_log/audit_syslog.cc -@@ -0,0 +1,89 @@ -+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#include -+#include -+#include "audit_handler.h" -+#include "audit_log.h" -+#include "my_dbug.h" -+#include "my_sys.h" -+#include "mysql/service_mysql_alloc.h" -+ -+struct audit_handler_syslog_data_t { -+ size_t struct_size; -+ int priority; -+ logger_prolog_func_t header; -+ logger_epilog_func_t footer; -+}; -+ -+static int audit_handler_syslog_write(audit_handler_t *handler, const char *buf, -+ size_t len); -+static int audit_handler_syslog_flush(audit_handler_t *handler); -+static int audit_handler_syslog_close(audit_handler_t *handler); -+ -+audit_handler_t *audit_handler_syslog_open( -+ audit_handler_syslog_config_t *opts) noexcept { -+ audit_handler_t *handler = (audit_handler_t *)my_malloc( -+ key_memory_audit_log_handler, -+ sizeof(audit_handler_t) + sizeof(audit_handler_syslog_data_t), -+ MY_ZEROFILL); -+ if (handler != nullptr) { -+ audit_handler_syslog_data_t *data = -+ (audit_handler_syslog_data_t *)(handler + 1); -+ -+ data->struct_size = sizeof(audit_handler_syslog_data_t); -+ data->priority = opts->priority; -+ data->header = opts->header; -+ data->footer = opts->footer; -+ openlog(opts->ident, 0, opts->facility); -+ MY_STAT stat_arg; -+ memset(&stat_arg, 0, sizeof(stat_arg)); -+ opts->header(&stat_arg, nullptr, 0); -+ handler->data = data; -+ handler->write = audit_handler_syslog_write; -+ handler->flush = audit_handler_syslog_flush; -+ handler->close = audit_handler_syslog_close; -+ } -+ return handler; -+} -+ -+static int audit_handler_syslog_write(audit_handler_t *handler, const char *buf, -+ size_t len) { -+ audit_handler_syslog_data_t *data = -+ (audit_handler_syslog_data_t *)handler->data; -+ assert(data->struct_size == sizeof(audit_handler_syslog_data_t)); -+ syslog(data->priority, "%s", buf); -+ return len; -+} -+ -+static int audit_handler_syslog_flush(audit_handler_t *handler) { -+ audit_handler_syslog_data_t *data = -+ (audit_handler_syslog_data_t *)handler->data; -+ MY_STAT stat_arg; -+ memset(&stat_arg, 0, sizeof(stat_arg)); -+ data->header(&stat_arg, nullptr, 0); -+ data->footer(nullptr, 0); -+ return 0; -+} -+ -+static int audit_handler_syslog_close(audit_handler_t *handler) { -+ audit_handler_syslog_data_t *data = -+ (audit_handler_syslog_data_t *)handler->data; -+ data->footer(nullptr, 0); -+ closelog(); -+ my_free(handler); -+ return 0; -+} -diff --git a/plugin/audit_log/buffer.cc b/plugin/audit_log/buffer.cc -new file mode 100644 -index 00000000000..47cb986e8ac ---- /dev/null -+++ b/plugin/audit_log/buffer.cc -@@ -0,0 +1,209 @@ -+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#include "buffer.h" -+ -+#include "audit_log.h" -+#include "my_dbug.h" -+#include "my_sys.h" -+#include "my_systime.h" -+#include "my_thread.h" -+#include "mysql/psi/mysql_cond.h" -+#include "mysql/psi/mysql_mutex.h" -+#include "mysql/psi/psi_cond.h" -+#include "mysql/psi/psi_mutex.h" -+#include "mysql/service_mysql_alloc.h" -+#include "template_utils.h" -+#include "thr_mutex.h" -+ -+struct audit_log_buffer_t { -+ char *buf; -+ size_t size; -+ size_t write_pos; -+ size_t flush_pos; -+ pthread_t flush_worker_thread; -+ bool stop; -+ bool drop_if_full; -+ void *write_func_data; -+ audit_log_write_func write_func; -+ mysql_mutex_t mutex; -+ mysql_cond_t flushed_cond; -+ mysql_cond_t written_cond; -+ log_record_state_t state; -+}; -+ -+#if defined(HAVE_PSI_INTERFACE) -+/* These belong to the service initialization */ -+static PSI_mutex_key key_log_mutex; -+static PSI_mutex_info mutex_key_list[] = { -+ {&key_log_mutex, "audit_log_buffer::mutex", PSI_FLAG_SINGLETON, 0, -+ PSI_DOCUMENT_ME}}; -+ -+static PSI_cond_key key_log_written_cond, key_log_flushed_cond; -+static PSI_cond_info cond_key_list[] = { -+ {&key_log_written_cond, "audit_log_buffer::written_cond", -+ PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, -+ {&key_log_flushed_cond, "audit_log_buffer::flushed_cond", -+ PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}}; -+ -+#endif -+ -+static void audit_log_flush(audit_log_buffer_t *log) { -+ mysql_mutex_lock(&log->mutex); -+ while (log->flush_pos == log->write_pos) { -+ if (log->stop) { -+ mysql_mutex_unlock(&log->mutex); -+ return; -+ } -+ timespec abstime; -+ set_timespec(&abstime, 1); -+ mysql_cond_timedwait(&log->written_cond, &log->mutex, &abstime); -+ } -+ -+ if (log->flush_pos >= log->write_pos % log->size) { -+ log->state = (log->write_pos % log->size == 0) -+ ? log_record_state_t::COMPLETE -+ : log_record_state_t::INCOMPLETE; -+ mysql_mutex_unlock(&log->mutex); -+ log->write_func(log->write_func_data, log->buf + log->flush_pos, -+ log->size - log->flush_pos, log->state); -+ mysql_mutex_lock(&log->mutex); -+ log->flush_pos = 0; -+ log->write_pos %= log->size; -+ } else { -+ const size_t flushlen = log->write_pos - log->flush_pos; -+ mysql_mutex_unlock(&log->mutex); -+ log->write_func(log->write_func_data, log->buf + log->flush_pos, flushlen, -+ log_record_state_t::COMPLETE); -+ mysql_mutex_lock(&log->mutex); -+ log->flush_pos += flushlen; -+ log->state = log_record_state_t::COMPLETE; -+ } -+ assert(log->write_pos >= log->flush_pos); -+ mysql_cond_broadcast(&log->flushed_cond); -+ mysql_mutex_unlock(&log->mutex); -+} -+ -+static void *audit_log_flush_worker(void *arg) { -+ audit_log_buffer_t *log = (audit_log_buffer_t *)arg; -+ -+ my_thread_init(); -+ while (!(log->stop && log->flush_pos == log->write_pos)) { -+ audit_log_flush(log); -+ } -+ my_thread_end(); -+ -+ return nullptr; -+} -+ -+audit_log_buffer_t *audit_log_buffer_init(size_t size, bool drop_if_full, -+ audit_log_write_func write_func, -+ void *data) noexcept { -+ audit_log_buffer_t *log = (audit_log_buffer_t *)my_malloc( -+ key_memory_audit_log_buffer, sizeof(audit_log_buffer_t) + size, -+ MY_ZEROFILL); -+ -+#ifdef HAVE_PSI_INTERFACE -+ mysql_mutex_register(AUDIT_LOG_PSI_CATEGORY, mutex_key_list, -+ array_elements(mutex_key_list)); -+ mysql_cond_register(AUDIT_LOG_PSI_CATEGORY, cond_key_list, -+ array_elements(cond_key_list)); -+#endif /* HAVE_PSI_INTERFACE */ -+ -+ if (log != nullptr) { -+ log->buf = ((char *)log + sizeof(audit_log_buffer_t)); -+ log->drop_if_full = drop_if_full; -+ log->write_func = write_func; -+ log->write_func_data = data; -+ log->size = size; -+ log->state = log_record_state_t::COMPLETE; -+ -+ mysql_mutex_init(key_log_mutex, &log->mutex, MY_MUTEX_INIT_FAST); -+ mysql_cond_init(key_log_flushed_cond, &log->flushed_cond); -+ mysql_cond_init(key_log_written_cond, &log->written_cond); -+ pthread_create(&log->flush_worker_thread, nullptr, audit_log_flush_worker, -+ log); -+ } -+ -+ return log; -+} -+ -+void audit_log_buffer_shutdown(audit_log_buffer_t *log) noexcept { -+ log->stop = true; -+ -+ pthread_join(log->flush_worker_thread, nullptr); -+ mysql_cond_destroy(&log->flushed_cond); -+ mysql_cond_destroy(&log->written_cond); -+ mysql_mutex_destroy(&log->mutex); -+ -+ my_free(log); -+} -+ -+void audit_log_buffer_pause(audit_log_buffer_t *log) noexcept { -+ mysql_mutex_lock(&log->mutex); -+ while (log->state == log_record_state_t::INCOMPLETE) { -+ mysql_cond_wait(&log->flushed_cond, &log->mutex); -+ } -+} -+ -+void audit_log_buffer_resume(audit_log_buffer_t *log) noexcept { -+ mysql_mutex_unlock(&log->mutex); -+} -+ -+int audit_log_buffer_write(audit_log_buffer_t *log, const char *buf, -+ size_t len) { -+ DBUG_EXECUTE_IF("audit_log_write_full_buffer", { -+ if (len > log->size) { -+ len = log->size - log->write_pos; -+ } else { -+ return 0; -+ } -+ }); -+ -+ if (len > log->size) { -+ if (!log->drop_if_full) { -+ /* pause flushing thread and write out one record bypassing the buffer */ -+ audit_log_buffer_pause(log); -+ log->write_func(log->write_func_data, buf, len, -+ log_record_state_t::COMPLETE); -+ audit_log_buffer_resume(log); -+ } -+ audit_log_buffer_size_overflow.fetch_add(1, std::memory_order_relaxed); -+ return (0); -+ } -+ -+ mysql_mutex_lock(&log->mutex); -+loop: -+ if (log->write_pos + len <= log->flush_pos + log->size) { -+ const size_t wrlen = -+ std::min(len, log->size - (log->write_pos % log->size)); -+ memcpy(log->buf + (log->write_pos % log->size), buf, wrlen); -+ if (wrlen < len) memcpy(log->buf, buf + wrlen, len - wrlen); -+ log->write_pos = log->write_pos + len; -+ assert(log->write_pos >= log->flush_pos); -+ } else { -+ if (!log->drop_if_full) { -+ mysql_cond_wait(&log->flushed_cond, &log->mutex); -+ goto loop; -+ } -+ } -+ if (log->write_pos > log->flush_pos + log->size / 2) { -+ mysql_cond_signal(&log->written_cond); -+ } -+ mysql_mutex_unlock(&log->mutex); -+ -+ return (0); -+} -diff --git a/plugin/audit_log/buffer.h b/plugin/audit_log/buffer.h -new file mode 100644 -index 00000000000..a59115b3af6 ---- /dev/null -+++ b/plugin/audit_log/buffer.h -@@ -0,0 +1,37 @@ -+/* Copyright (c) 2014 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#ifndef AUDIT_LOG_BUFFER_INCLUDED -+#define AUDIT_LOG_BUFFER_INCLUDED -+ -+#include -+#include "logger.h" -+ -+struct audit_log_buffer_t; -+ -+typedef int (*audit_log_write_func)(void *data, const char *buf, size_t len, -+ log_record_state_t state); -+ -+audit_log_buffer_t *audit_log_buffer_init(size_t size, bool drop_if_full, -+ audit_log_write_func write_func, -+ void *data) noexcept; -+void audit_log_buffer_shutdown(audit_log_buffer_t *log) noexcept; -+int audit_log_buffer_write(audit_log_buffer_t *log, const char *buf, -+ size_t len); -+void audit_log_buffer_pause(audit_log_buffer_t *log) noexcept; -+void audit_log_buffer_resume(audit_log_buffer_t *log) noexcept; -+ -+#endif -diff --git a/plugin/audit_log/file_logger.cc b/plugin/audit_log/file_logger.cc -new file mode 100644 -index 00000000000..da2700b4cfe ---- /dev/null -+++ b/plugin/audit_log/file_logger.cc -@@ -0,0 +1,264 @@ -+/* Copyright (C) 2012 Monty Program Ab -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; version 2 of the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -+ USA */ -+ -+#include -+#include "my_dir.h" -+#include "my_sys.h" -+#include "mysql/plugin.h" -+#include "sql/mysqld.h" -+ -+#include "audit_log.h" -+#include "logger.h" -+ -+#ifndef FLOGGER_NO_PSI -+#define flogger_mutex_init(A, B, C) \ -+ if ((B)->thread_safe) mysql_mutex_init(A, &((B)->lock), C) -+ -+#define flogger_mutex_destroy(A) \ -+ if ((A)->thread_safe) mysql_mutex_destroy(&((A)->lock)) -+ -+#define flogger_mutex_lock(A) \ -+ if ((A)->thread_safe) mysql_mutex_lock(&((A)->lock)) -+ -+#define flogger_mutex_unlock(A) \ -+ if ((A)->thread_safe) mysql_mutex_unlock(&((A)->lock)) -+#else -+#define flogger_mutex_init(A, B, C) \ -+ if ((B)->thread_safe) pthread_mutex_init(&((B)->lock.m_mutex), C) -+ -+#define flogger_mutex_destroy(A) \ -+ if ((A)->thread_safe) pthread_mutex_destroy(&((A)->lock.m_mutex)) -+ -+#define flogger_mutex_lock(A) \ -+ if ((A)->thread_safe) pthread_mutex_lock(&((A)->lock.m_mutex)) -+ -+#define flogger_mutex_unlock(A) \ -+ if ((A)->thread_safe) pthread_mutex_unlock(&((A)->lock.m_mutex)) -+#endif /*!FLOGGER_NO_PSI*/ -+ -+#if defined(HAVE_PSI_INTERFACE) && !defined(FLOGGER_NO_PSI) -+/* These belong to the service initialization */ -+static PSI_mutex_key key_LOCK_logger_service; -+static PSI_mutex_info mutex_list[] = { -+ {&key_LOCK_logger_service, "file_logger::lock", PSI_FLAG_SINGLETON, -+ PSI_VOLATILITY_UNKNOWN, PSI_DOCUMENT_ME}}; -+#else -+#define key_LOCK_logger_service nullptr -+#endif /*HAVE_PSI_INTERFACE && !FLOGGER_NO_PSI*/ -+ -+struct LOGGER_HANDLE { -+ File file; -+ char path[FN_REFLEN]; -+ unsigned long long size_limit; -+ unsigned int rotations; -+ size_t path_len; -+ mysql_mutex_t lock; -+ bool thread_safe; -+}; -+ -+#define LOG_FLAGS (O_APPEND | O_CREAT | O_WRONLY) -+ -+static constexpr unsigned int n_dig(unsigned int i) noexcept { -+ return (i == 0) ? 0 : ((i < 10) ? 1 : ((i < 100) ? 2 : 3)); -+} -+ -+LOGGER_HANDLE *logger_open(const char *path, unsigned long long size_limit, -+ unsigned int rotations, bool thread_safe, -+ logger_prolog_func_t header) noexcept { -+ /* -+ I don't think we ever need more rotations, -+ but if it's so, the rotation procedure should be adapted to it. -+ */ -+ if (rotations > 999) return 0; -+ -+ LOGGER_HANDLE new_log; -+ new_log.rotations = rotations; -+ new_log.size_limit = size_limit; -+ new_log.path_len = strlen( -+ fn_format(new_log.path, path, mysql_data_home, "", MY_UNPACK_FILENAME)); -+ new_log.thread_safe = thread_safe; -+ -+ if (new_log.path_len + n_dig(rotations) + 1 > FN_REFLEN) { -+ errno = ENAMETOOLONG; -+ /* File path too long */ -+ return 0; -+ } -+ -+ if ((new_log.file = my_open(new_log.path, LOG_FLAGS, 0666)) < 0) { -+ errno = my_errno(); -+ /* Check errno for the cause */ -+ return 0; -+ } -+ -+ MY_STAT stat_arg; -+ if (my_fstat(new_log.file, &stat_arg)) { -+ errno = my_errno(); -+ my_close(new_log.file, MYF(0)); -+ new_log.file = -1; -+ return 0; -+ } -+ -+ LOGGER_HANDLE *l_perm; -+ if (!(l_perm = (LOGGER_HANDLE *)my_malloc(key_memory_audit_log_logger_handle, -+ sizeof(LOGGER_HANDLE), MYF(0)))) { -+ my_close(new_log.file, MYF(0)); -+ new_log.file = -1; -+ return 0; /* End of memory */ -+ } -+ *l_perm = new_log; -+ -+ flogger_mutex_init(key_LOCK_logger_service, l_perm, MY_MUTEX_INIT_FAST); -+ -+ char buf[128]; -+ size_t len; -+ len = header(&stat_arg, buf, sizeof(buf)); -+ my_write(l_perm->file, (uchar *)buf, len, MYF(0)); -+ -+ return l_perm; -+} -+ -+int logger_close(LOGGER_HANDLE *log, logger_epilog_func_t footer) noexcept { -+ File file = log->file; -+ char buf[128]; -+ const size_t len = footer(buf, sizeof(buf)); -+ my_write(file, (uchar *)buf, len, MYF(0)); -+ -+ flogger_mutex_destroy(log); -+ my_free(log); -+ int result; -+ if ((result = my_close(file, MYF(0)))) errno = my_errno(); -+ return result; -+} -+ -+int logger_reopen(LOGGER_HANDLE *log, logger_prolog_func_t header, -+ logger_epilog_func_t footer) noexcept { -+ flogger_mutex_lock(log); -+ -+ char buf[128]; -+ size_t len = footer(buf, sizeof(buf)); -+ my_write(log->file, (uchar *)buf, len, MYF(0)); -+ -+ int result = 0; -+ if ((result = my_close(log->file, MYF(0)))) { -+ errno = my_errno(); -+ goto error; -+ } -+ -+ if ((log->file = my_open(log->path, LOG_FLAGS, MYF(0))) < 0) { -+ errno = my_errno(); -+ result = 1; -+ goto error; -+ } -+ -+ MY_STAT stat_arg; -+ if ((result = my_fstat(log->file, &stat_arg))) { -+ errno = my_errno(); -+ goto error; -+ } -+ -+ len = header(&stat_arg, buf, sizeof(buf)); -+ my_write(log->file, (uchar *)buf, len, MYF(0)); -+ -+error: -+ flogger_mutex_unlock(log); -+ -+ return result; -+} -+ -+static char *logname(const LOGGER_HANDLE &log, char *buf, size_t buf_len, -+ unsigned int n_log) noexcept { -+ snprintf(buf + log.path_len, buf_len, ".%0*u", n_dig(log.rotations), n_log); -+ return buf; -+} -+ -+static int do_rotate(LOGGER_HANDLE *log) { -+ if (log->rotations == 0) return 0; -+ -+ char new_name_buf[FN_REFLEN] = {0}; -+ char old_name_buf[FN_REFLEN] = {0}; -+ char *new_name = nullptr; -+ char *old_name = nullptr; -+ -+ memcpy(new_name_buf, log->path, log->path_len); -+ memcpy(old_name_buf, log->path, log->path_len); -+ -+ for (auto i = log->rotations; i > 0; i--) { -+ new_name = logname(*log, new_name_buf, sizeof(new_name_buf), i); -+ -+ if (i > 1) { -+ old_name = logname(*log, old_name_buf, sizeof(new_name_buf), i - 1); -+ } else { -+ old_name = old_name_buf; -+ old_name_buf[log->path_len] = 0; -+ } -+ -+ if (0 == access(old_name, F_OK) && -+ 0 != my_rename(old_name, new_name, MYF(0))) { -+ errno = my_errno(); -+ return -1; -+ } -+ } -+ -+ if (0 != my_close(log->file, MYF(0))) { -+ errno = my_errno(); -+ return -1; -+ } -+ -+ log->file = my_open(log->path, LOG_FLAGS, MYF(0)); -+ -+ errno = my_errno(); -+ return log->file < 0 ? -1 : 0; -+} -+ -+int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size, -+ log_record_state_t state) noexcept { -+ flogger_mutex_lock(log); -+ -+ int result = my_write(log->file, (const uchar *)buffer, size, MYF(0)); -+ -+ if (state == log_record_state_t::COMPLETE && log->rotations > 0) { -+ my_off_t filesize; -+ if ((filesize = my_tell(log->file, MYF(0))) == (my_off_t)-1 || -+ ((unsigned long long)filesize >= log->size_limit && do_rotate(log))) { -+ result = -1; -+ errno = my_errno(); -+ } -+ } -+ -+ flogger_mutex_unlock(log); -+ return result; -+} -+ -+void logger_init_mutexes() noexcept { -+#if defined(HAVE_PSI_INTERFACE) && !defined(FLOGGER_NO_PSI) && \ -+ !defined(FLOGGER_NO_THREADSAFE) -+ mysql_mutex_register(AUDIT_LOG_PSI_CATEGORY, mutex_list, -+ array_elements(mutex_list)); -+#endif /*HAVE_PSI_INTERFACE && !FLOGGER_NO_PSI*/ -+} -+ -+int logger_sync(LOGGER_HANDLE *log) noexcept { -+ return my_sync(log->file, MYF(0)); -+} -+ -+void logger_set_size_limit(LOGGER_HANDLE *log, -+ unsigned long long size_limit) noexcept { -+ log->size_limit = size_limit; -+} -+ -+void logger_set_rotations(LOGGER_HANDLE *log, unsigned int rotations) noexcept { -+ log->rotations = rotations; -+} -diff --git a/plugin/audit_log/filter.cc b/plugin/audit_log/filter.cc -new file mode 100644 -index 00000000000..b4540bba00c ---- /dev/null -+++ b/plugin/audit_log/filter.cc -@@ -0,0 +1,389 @@ -+/* Copyright (c) 2016 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#include "filter.h" -+ -+#include -+#include "audit_log.h" -+#include "map_helpers.h" -+#include "my_hostname.h" -+#include "my_sys.h" -+#include "my_user.h" -+#include "mysql/psi/mysql_rwlock.h" -+#include "mysql_com.h" -+#include "sql/mysqld_cs.h" -+ -+static std::string make_account_string(const char *user, size_t user_length, -+ const char *host, size_t host_length) { -+ std::string result(user, user_length); -+ result.reserve(user_length + host_length + 2); -+ result.append(1, '@'); -+ result.append(host, host_length); -+ result.append(1, '\0'); -+ return result; -+} -+ -+static std::string make_command_string(const char *name, size_t length) { -+ std::string result(name, length); -+ std::transform(result.begin(), result.end(), result.begin(), ::tolower); -+ result.shrink_to_fit(); -+ return result; -+} -+ -+using account_set_t = collation_unordered_set; -+ -+static account_set_t *include_accounts; -+static account_set_t *exclude_accounts; -+ -+using db_set_t = collation_unordered_set; -+ -+static db_set_t *include_databases; -+static db_set_t *exclude_databases; -+ -+using command_set_t = malloc_unordered_set; -+ -+static command_set_t *include_commands; -+static command_set_t *exclude_commands; -+ -+#if defined(HAVE_PSI_INTERFACE) -+ -+static PSI_rwlock_key key_LOCK_account_list; -+static PSI_rwlock_key key_LOCK_database_list; -+static PSI_rwlock_key key_LOCK_command_list; -+static PSI_rwlock_info all_rwlock_list[] = { -+ {&key_LOCK_account_list, "audit_log_filter::account_list", -+ PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, -+ {&key_LOCK_database_list, "audit_log_filter::database_list", -+ PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, -+ {&key_LOCK_account_list, "audit_log_filter::command_list", -+ PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}}; -+ -+#endif -+ -+static mysql_rwlock_t LOCK_account_list; -+static mysql_rwlock_t LOCK_database_list; -+static mysql_rwlock_t LOCK_command_list; -+ -+/* -+ Allocate memory and initialize new command -+*/ -+ -+/* -+ Remove enclosing quotes from string if any. -+*/ -+static void unquote_string(char *string, size_t *string_length) noexcept { -+ if (string[0] == '\'' && string[*string_length - 1] == '\'') { -+ *string_length -= 2; -+ memmove(string, string + 1, *string_length); -+ string[*string_length] = 0; -+ } -+} -+ -+/* -+ Parse comma-separated list of accounts and add it into account list. -+ Empty user name is allowed. -+*/ -+static void account_list_from_string(account_set_t *account_set, -+ const char *string) { -+ account_set->clear(); -+ -+ char *string_copy = my_strdup(PSI_NOT_INSTRUMENTED, string, MYF(MY_FAE)); -+ const size_t string_length = strlen(string_copy); -+ char *entry = string_copy; -+ while (entry - string_copy < static_cast(string_length)) { -+ size_t entry_length = 0; -+ bool quote = false; -+ -+ while (*entry == ' ') entry++; -+ -+ entry_length = 0; -+ while ( -+ ((entry[entry_length] != ' ' && entry[entry_length] != ',') || quote) && -+ entry[entry_length] != 0) { -+ if (entry[entry_length] == '\'') quote = !quote; -+ entry_length++; -+ } -+ -+ entry[entry_length] = 0; -+ -+ char user[USERNAME_LENGTH + 1], host[HOSTNAME_LENGTH + 1]; -+ size_t user_length, host_length; -+ parse_user(entry, entry_length, user, &user_length, host, &host_length); -+ unquote_string(user, &user_length); -+ unquote_string(host, &host_length); -+ my_casedn_str(system_charset_info, host); -+ -+ account_set->emplace( -+ make_account_string(user, user_length, host, host_length)); -+ -+ entry += entry_length + 1; -+ } -+ -+ my_free(string_copy); -+} -+ -+static void database_list_from_string(db_set_t *db_set, const char *string) { -+ const char *entry = string; -+ -+ db_set->clear(); -+ -+ while (*entry) { -+ while (*entry == ' ') entry++; -+ -+ size_t entry_length = 0; -+ bool quote = false; -+ char name[NAME_LEN + 1]; -+ size_t name_length = 0; -+ while ( -+ ((entry[entry_length] != ' ' && entry[entry_length] != ',') || quote) && -+ entry[entry_length] != 0) { -+ if (quote && entry[entry_length] == '`' && -+ entry[entry_length + 1] == '`') { -+ name[name_length++] = '`'; -+ entry_length += 1; -+ } else if (entry[entry_length] == '`') -+ quote = !quote; -+ else if (name_length < sizeof(name)) -+ name[name_length++] = entry[entry_length]; -+ entry_length++; -+ } -+ -+ if (name_length > 0) { -+ name[name_length] = 0; -+ db_set->emplace(name, name_length); -+ } -+ -+ entry += entry_length; -+ -+ if (*entry == ',') entry++; -+ } -+} -+ -+/* -+ Parse comma-separated list of command and add it into command hash. -+*/ -+static void command_list_from_string(command_set_t *command_set, -+ const char *string) { -+ std::string lcase_str(string); -+ std::transform(lcase_str.begin(), lcase_str.end(), lcase_str.begin(), -+ ::tolower); -+ -+ command_set->clear(); -+ -+ auto it = lcase_str.cbegin(); -+ while (it != lcase_str.cend()) { -+ std::string::size_type len = 0; -+ while (it != lcase_str.cend() && (*it == ' ' || *it == ',')) it++; -+ while (it + len != lcase_str.cend() && it[len] != ' ' && it[len] != ',') -+ len++; -+ if (len > 0) { -+ command_set->emplace(&(*it), len); -+ it += len; -+ } -+ } -+} -+ -+/* public interface */ -+ -+void audit_log_filter_init() { -+#ifdef HAVE_PSI_INTERFACE -+ mysql_rwlock_register(AUDIT_LOG_PSI_CATEGORY, all_rwlock_list, -+ array_elements(all_rwlock_list)); -+#endif /* HAVE_PSI_INTERFACE */ -+ mysql_rwlock_init(key_LOCK_account_list, &LOCK_account_list); -+ mysql_rwlock_init(key_LOCK_database_list, &LOCK_database_list); -+ mysql_rwlock_init(key_LOCK_command_list, &LOCK_command_list); -+ -+ include_accounts = -+ new account_set_t(&my_charset_bin, key_memory_audit_log_accounts); -+ -+ exclude_accounts = -+ new account_set_t(&my_charset_bin, key_memory_audit_log_accounts); -+ -+ include_databases = -+ new db_set_t(&my_charset_bin, key_memory_audit_log_databases); -+ -+ exclude_databases = -+ new db_set_t(&my_charset_bin, key_memory_audit_log_databases); -+ -+ include_commands = new command_set_t(key_memory_audit_log_commands); -+ -+ exclude_commands = new command_set_t(key_memory_audit_log_commands); -+} -+ -+void audit_log_filter_destroy() noexcept { -+ delete include_accounts; -+ delete exclude_accounts; -+ delete include_databases; -+ delete exclude_databases; -+ delete include_commands; -+ delete exclude_commands; -+ mysql_rwlock_destroy(&LOCK_account_list); -+ mysql_rwlock_destroy(&LOCK_database_list); -+ mysql_rwlock_destroy(&LOCK_account_list); -+ mysql_rwlock_destroy(&LOCK_command_list); -+} -+ -+/* -+ Parse and store the list of included accounts. -+*/ -+void audit_log_set_include_accounts(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_account_list); -+ account_list_from_string(include_accounts, val); -+ mysql_rwlock_unlock(&LOCK_account_list); -+} -+ -+/* -+ Parse and store the list of excluded accounts. -+*/ -+void audit_log_set_exclude_accounts(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_account_list); -+ account_list_from_string(exclude_accounts, val); -+ mysql_rwlock_unlock(&LOCK_account_list); -+} -+ -+/* -+ Check if account has to be included. -+*/ -+bool audit_log_check_account_included(const char *user, size_t user_length, -+ const char *host, size_t host_length) { -+ const std::string acc{ -+ make_account_string(user, user_length, host, host_length)}; -+ -+ mysql_rwlock_rdlock(&LOCK_account_list); -+ const auto &it = include_accounts->find(acc); -+ const bool res = it != include_accounts->cend(); -+ mysql_rwlock_unlock(&LOCK_account_list); -+ -+ return res; -+} -+ -+/* -+ Check if account has to be excluded. -+*/ -+bool audit_log_check_account_excluded(const char *user, size_t user_length, -+ const char *host, size_t host_length) { -+ const std::string acc{ -+ make_account_string(user, user_length, host, host_length)}; -+ -+ mysql_rwlock_rdlock(&LOCK_account_list); -+ const auto &it = exclude_accounts->find(acc); -+ const bool res = it != exclude_accounts->cend(); -+ ; -+ mysql_rwlock_unlock(&LOCK_account_list); -+ -+ return res; -+} -+ -+/* -+ Parse and store the list of included databases. -+*/ -+void audit_log_set_include_databases(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_database_list); -+ database_list_from_string(include_databases, val); -+ mysql_rwlock_unlock(&LOCK_database_list); -+} -+ -+/* -+ Parse and store the list of excluded databases. -+*/ -+void audit_log_set_exclude_databases(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_database_list); -+ database_list_from_string(exclude_databases, val); -+ mysql_rwlock_unlock(&LOCK_database_list); -+} -+ -+/* -+ Check if database has to be included. -+*/ -+bool audit_log_check_database_included(const char *name, size_t length) { -+ if (length == 0) return false; -+ -+ const std::string db(name, length); -+ -+ mysql_rwlock_rdlock(&LOCK_database_list); -+ const auto &it = include_databases->find(db); -+ const bool res = it != include_databases->cend(); -+ mysql_rwlock_unlock(&LOCK_database_list); -+ -+ return res; -+} -+ -+/* -+ Check if database has to be excluded. -+*/ -+bool audit_log_check_database_excluded(const char *name, size_t length) { -+ if (length == 0) return false; -+ -+ const std::string db(name, length); -+ -+ mysql_rwlock_rdlock(&LOCK_database_list); -+ const auto &it = exclude_databases->find(db); -+ const bool res = it != exclude_databases->cend(); -+ mysql_rwlock_unlock(&LOCK_database_list); -+ -+ return res; -+} -+ -+/* -+ Parse and store the list of included commands. -+*/ -+void audit_log_set_include_commands(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_command_list); -+ command_list_from_string(include_commands, val); -+ mysql_rwlock_unlock(&LOCK_command_list); -+} -+ -+/* -+ Parse and store the list of excluded commands. -+*/ -+void audit_log_set_exclude_commands(const char *val) { -+ mysql_rwlock_wrlock(&LOCK_command_list); -+ command_list_from_string(exclude_commands, val); -+ mysql_rwlock_unlock(&LOCK_command_list); -+} -+ -+/* -+ Check if command has to be included. -+*/ -+bool audit_log_check_command_included(const char *name, size_t length) { -+ if (length == 0) return false; -+ -+ const std::string cmd{make_command_string(name, length)}; -+ -+ mysql_rwlock_rdlock(&LOCK_command_list); -+ const auto &it = include_commands->find(cmd); -+ const bool res = it != include_commands->cend(); -+ mysql_rwlock_unlock(&LOCK_command_list); -+ -+ return res; -+} -+ -+/* -+ Check if command has to be excluded. -+*/ -+bool audit_log_check_command_excluded(const char *name, size_t length) { -+ if (length == 0) return false; -+ -+ const std::string cmd{make_command_string(name, length)}; -+ -+ mysql_rwlock_rdlock(&LOCK_command_list); -+ const auto &it = exclude_commands->find(cmd); -+ const bool res = it != exclude_commands->cend(); -+ mysql_rwlock_unlock(&LOCK_command_list); -+ -+ return res; -+} -diff --git a/plugin/audit_log/filter.h b/plugin/audit_log/filter.h -new file mode 100644 -index 00000000000..1622ef2f6d3 ---- /dev/null -+++ b/plugin/audit_log/filter.h -@@ -0,0 +1,42 @@ -+/* Copyright (c) 2016 Percona LLC and/or its affiliates. All rights reserved. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License -+ as published by the Free Software Foundation; version 2 of -+ the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -+ -+#ifndef AUDIT_LOG_FILTER_INCLUDED -+#define AUDIT_LOG_FILTER_INCLUDED -+ -+#include -+ -+void audit_log_set_include_accounts(const char *val); -+void audit_log_set_exclude_accounts(const char *val); -+bool audit_log_check_account_included(const char *user, size_t user_length, -+ const char *host, size_t host_length); -+bool audit_log_check_account_excluded(const char *user, size_t user_length, -+ const char *host, size_t host_length); -+ -+void audit_log_set_include_databases(const char *val); -+void audit_log_set_exclude_databases(const char *val); -+bool audit_log_check_database_included(const char *name, size_t length); -+bool audit_log_check_database_excluded(const char *name, size_t length); -+ -+void audit_log_set_include_commands(const char *val); -+void audit_log_set_exclude_commands(const char *val); -+bool audit_log_check_command_included(const char *command, size_t length); -+bool audit_log_check_command_excluded(const char *command, size_t length); -+ -+void audit_log_filter_init(); -+void audit_log_filter_destroy() noexcept; -+ -+#endif -diff --git a/plugin/audit_log/logger.h b/plugin/audit_log/logger.h -new file mode 100644 -index 00000000000..1f097ec0e60 ---- /dev/null -+++ b/plugin/audit_log/logger.h -@@ -0,0 +1,73 @@ -+/* Copyright (C) 2012 Monty Program Ab -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; version 2 of the License. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -+ USA */ -+ -+#ifndef MYSQL_SERVICE_LOGGER_INCLUDED -+#define MYSQL_SERVICE_LOGGER_INCLUDED -+ -+/** -+ @file -+ logger service -+ -+ Log file with rotation implementation. -+ -+ This service implements logging with possible rotation -+ of the log files. Interface intentionally tries to be similar to FILE* -+ related functions. -+ -+ So that one can open the log with logger_open(), specifying -+ the limit on the logfile size and the rotations number. -+ -+ As the size of the logfile grows over the specified limit, -+ it is renamed to 'logfile.1'. The former 'logfile.1' becomes -+ 'logfile.2', etc. The file 'logfile.rotations' is removed. -+ That's how the rotation works. -+ -+ Finally the log should be closed with logger_close(). -+ -+@notes: -+ Implementation checks the size of the log file before it starts new -+ printf into it. So the size of the file gets over the limit when it rotates. -+ -+ The access is secured with the mutex, so the log is threadsafe. -+*/ -+ -+#include -+#include -+#include "my_compiler.h" -+#include "my_dir.h" -+ -+struct LOGGER_HANDLE; -+ -+typedef size_t (*logger_prolog_func_t)(MY_STAT *, char *buf, size_t buflen); -+typedef size_t (*logger_epilog_func_t)(char *buf, size_t buflen); -+ -+enum class log_record_state_t { COMPLETE, INCOMPLETE }; -+ -+void logger_init_mutexes() noexcept; -+LOGGER_HANDLE *logger_open(const char *path, unsigned long long size_limit, -+ unsigned int rotations, bool thread_safe, -+ logger_prolog_func_t header) noexcept; -+int logger_close(LOGGER_HANDLE *log, logger_epilog_func_t footer) noexcept; -+int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size, -+ log_record_state_t state) noexcept; -+int logger_sync(LOGGER_HANDLE *log) noexcept; -+int logger_reopen(LOGGER_HANDLE *log, logger_prolog_func_t header, -+ logger_epilog_func_t footer) noexcept; -+void logger_set_size_limit(LOGGER_HANDLE *log, -+ unsigned long long size_limit) noexcept; -+void logger_set_rotations(LOGGER_HANDLE *log, unsigned int rotations) noexcept; -+ -+#endif /*MYSQL_SERVICE_LOGGER_INCLUDED*/ -diff --git a/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.result b/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.result -new file mode 100644 -index 00000000000..e145b0aa064 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.result -@@ -0,0 +1,14 @@ -+# restart: --audit_log_buffer_size=4096 -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+Variable_name Value -+Audit_log_buffer_size_overflow 1 -+# restart: --audit_log_buffer_size=4096 --audit_log_strategy=PERFORMANCE -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+Variable_name Value -+Audit_log_buffer_size_overflow 1 -diff --git a/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.test b/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.test -new file mode 100644 -index 00000000000..d26b179d3d8 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_buffer_size_overflow.test -@@ -0,0 +1,28 @@ -+# Bug PS-3969: Adding a status variable to catch when statement was too big to fit buffer. -+ -+# Test it with default audit_log_strategy -+--let $restart_parameters="restart: --audit_log_buffer_size=4096" -+--source include/restart_mysqld.inc -+ -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+ -+--disable_query_log -+--disable_result_log -+SELECT "4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonj"; -+--enable_result_log -+--enable_query_log -+ -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+ -+# Test it with audit_log_strategy = PERFORMANCE -+--let $restart_parameters="restart: --audit_log_buffer_size=4096 --audit_log_strategy=PERFORMANCE" -+--source include/restart_mysqld.inc -+ -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -+ -+--disable_query_log -+--disable_result_log -+SELECT "4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonj"; -+--enable_result_log -+--enable_query_log -+SHOW GLOBAL STATUS LIKE 'Audit_log_buffer_size_overflow'; -diff --git a/plugin/audit_log/tests/mtr/audit_log_charset-master.opt b/plugin/audit_log/tests/mtr/audit_log_charset-master.opt -new file mode 100644 -index 00000000000..ad7f91c65bd ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_charset-master.opt -@@ -0,0 +1,6 @@ -+$AUDIT_LOG_OPT -+$AUDIT_LOG_LOAD -+--audit_log_file=test_audit.log -+--audit_log_policy=ALL -+--audit-log-format=CSV -+--audit_log_strategy=SYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_charset.result b/plugin/audit_log/tests/mtr/audit_log_charset.result -new file mode 100644 -index 00000000000..56221f2d92d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_charset.result -@@ -0,0 +1,74 @@ -+SET GLOBAL audit_log_flush=ON; -+set names tis620; -+SET NAMES utf8mb4; -+INSERT IGNORE INTO t VALUES ('𦉘𦟌𦧲'); -+Warnings: -+Warning 1366 Incorrect string value: '\xF0\xA6\x89\x98\xF0\xA6...' for column 'txt' at row 1 -+CREATE DATABASE 𦉘𦟌𦧲; -+Warnings: -+Warning 1300 Cannot convert string '\xF0\xA6\x89\x98\xF0\xA6...' from utf8mb4 to utf8mb3 -+SHOW DATABASES; -+Database -+??? -+information_schema -+mtr -+mysql -+performance_schema -+sys -+test -+ฐานข้อมูล -+use 𦉘𦟌𦧲; -+Warnings: -+Warning 1300 Cannot convert string '\xF0\xA6\x89\x98\xF0\xA6...' from utf8mb4 to utf8mb3 -+use ฐานข้อมูล; -+SET NAMES utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+SELECT * FROM t WHERE txt LIKE 'ขุนนาง%'; -+txt -+ขุนนางใช่พ่อแม่ หินแง่ใช่ตายาย -+use test; -+SELECT * FROM ฐานข้อมูล.t LIMIT 1; -+txt -+ขุนนางใช่พ่อแม่ หินแง่ใช่ตายาย -+use ฐานข้อมูล; -+DROP DATABASE ฐานข้อมูล; -+DROP DATABASE `???`; -+use test; -+SET @@character_set_client=cp1256; -+CREATE t \217\355ݏ\355ݏ\355\335(\217\260\241\217\260\241\217\260\241 char) DEFAULT CHARSET=ujis engine=TokuDB; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't \217\355ف?\355ف?\355\335(\217\260\241\217\260\241\217\260\241 char) DEFAULT ' at line 1 -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"set names tis620","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT x'b0d2b9a2e9cdc1d9c5'","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT x'a2d8b9b9d2a7e3aae8bee8cde1c1e820cbd4b9e1a7e8e3aae8b5d2c2d2c2'","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT x'a1a7e0a1c7d5c2b9a1d3e0a1c7d5c2b9'","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT REPEAT('กงเกวียนกำเกวียน ', 400)","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 'ฐานข้อมูล'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_db","",0,"CREATE DATABASE `ฐานข้อมูล`","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"use `ฐานข้อมูล`","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","create_table","",0,"CREATE TABLE t (txt TEXT) charset='utf8'","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","insert","",0,"INSERT INTO t VALUES ('ขุนนางใช่พ่อแม่ หินแง่ใช่ตายาย')","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","insert","",0,"INSERT INTO t VALUES ('กงเกวียนกำเกวียน')","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","insert","",0,"INSERT INTO t VALUES ('กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน กงเกวียนกำเกวียน ')","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","insert","",0,"INSERT IGNORE INTO t VALUES ('𦉘𦟌𦧲')","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","create_db","",0,"CREATE DATABASE 𦉘𦟌𦧲","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","show_databases","",0,"SHOW DATABASES","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","change_db","",0,"use 𦉘𦟌𦧲","root[root] @ localhost []","localhost","","","???" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","???" -+"Query","","","change_db","",0,"use ฐานข้อมูล","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","select","",0,"SELECT * FROM t WHERE txt LIKE 'ขุนนาง%'","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","change_db","",0,"use test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT * FROM ฐานข้อมูล.t LIMIT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"use ฐานข้อมูล","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","drop_db","",0,"DROP DATABASE ฐานข้อมูล","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","drop_db","",0,"DROP DATABASE `???`","root[root] @ localhost []","localhost","","","ฐานข้อมูล" -+"Query","","","change_db","",0,"use test","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET @@character_set_client=cp1256","root[root] @ localhost []","localhost","","","test" -+"Query","","","error","",1064,"CREATE t \217\355ف?\355ف?\355\335(\217\260\241\217\260\241\217\260\241 char) DEFAULT CHARSET=ujis engine=TokuDB","root[root] @ localhost []","localhost","","","test" -+=================================================================== -diff --git a/plugin/audit_log/tests/mtr/audit_log_charset.test b/plugin/audit_log/tests/mtr/audit_log_charset.test -new file mode 100644 -index 00000000000..a549832c020 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_charset.test -@@ -0,0 +1,64 @@ -+# test encodings suppport by audit plugin -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+ -+set names tis620; -+ -+--disable_query_log -+--disable_result_log -+ -+let $db=`SELECT x'b0d2b9a2e9cdc1d9c5'`; -+let $text1=`SELECT x'a2d8b9b9d2a7e3aae8bee8cde1c1e820cbd4b9e1a7e8e3aae8b5d2c2d2c2'`; -+let $text2=`SELECT x'a1a7e0a1c7d5c2b9a1d3e0a1c7d5c2b9'`; -+let $very_long_text=`SELECT REPEAT('$text2 ', 400)`; -+ -+eval SELECT '$db'; -+ -+eval CREATE DATABASE `$db`; -+ -+eval use `$db`; -+ -+CREATE TABLE t (txt TEXT) charset='utf8'; -+ -+eval INSERT INTO t VALUES ('$text1'); -+eval INSERT INTO t VALUES ('$text2'); -+eval INSERT INTO t VALUES ('$very_long_text'); -+ -+--enable_query_log -+--enable_result_log -+ -+SET NAMES utf8mb4; -+ -+INSERT IGNORE INTO t VALUES ('𦉘𦟌𦧲'); -+CREATE DATABASE 𦉘𦟌𦧲; -+ -+SHOW DATABASES; -+ -+use 𦉘𦟌𦧲; -+ -+use ฐานข้อมูล; -+ -+SET NAMES utf8; -+ -+SELECT * FROM t WHERE txt LIKE 'ขุนนาง%'; -+ -+use test; -+ -+SELECT * FROM ฐานข้อมูล.t LIMIT 1; -+ -+use ฐานข้อมูล; -+ -+DROP DATABASE ฐานข้อมูล; -+DROP DATABASE `???`; -+ -+use test; -+ -+SET @@character_set_client=cp1256; -+--error ER_PARSE_ERROR -+CREATE t \217\355ݏ\355ݏ\355\335(\217\260\241\217\260\241\217\260\241 char) DEFAULT CHARSET=ujis engine=TokuDB; -+ -+--source audit_log_echo.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_csv-master.opt b/plugin/audit_log/tests/mtr/audit_log_csv-master.opt -new file mode 100644 -index 00000000000..fb919dedf07 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_csv-master.opt -@@ -0,0 +1,3 @@ -+--audit_log_file=test_audit.log -+--audit-log-format=CSV -+--audit_log_strategy=SEMISYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_csv.result b/plugin/audit_log/tests/mtr/audit_log_csv.result -new file mode 100644 -index 00000000000..c57dc1d19bc ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_csv.result -@@ -0,0 +1,97 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+CREATE TABLE t1 -+(c1 INT, -+c2 CHAR(20)); -+ERROR 42S01: Table 't1' already exists -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+SELECT * FROM t1; -+c1 c2 -+1 a -+2 b -+3 c -+SELECT * FROM t2; -+ERROR 42S02: Table 'test.t2' doesn't exist -+DROP TABLE t1; -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+1 -+1 -+SHOW STATUS LIKE 'audit_log%'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+DEALLOCATE PREPARE stmt1; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format CSV -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); -+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+id -+1 -+2 -+alter table t1 rename renamed_t1; -+select * from t_doesnt_exist; -+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist -+syntax_error_query; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1 -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format CSV -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+create database sa_db; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+id2 -+1 -+2 -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+select '&;&&&""""<><<>>>>'; -+&;&&&""""<><<>>>> -+&;&&&""""<><<>>>> -+set global audit_log_flush= ON; -diff --git a/plugin/audit_log/tests/mtr/audit_log_csv.test b/plugin/audit_log/tests/mtr/audit_log_csv.test -new file mode 100644 -index 00000000000..9cec7df3449 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_csv.test -@@ -0,0 +1,23 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_events.inc -+ -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_csv.log -+set global audit_log_flush= ON; -+perl; -+ eval "use Text::CSV; 1" or exit 0; -+ my $p = Text::CSV->new({ binary => 1, sep_char => ',' }); -+ open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_csv.log' or die "Could not open log: $!"; -+ while ($p->getline($file)) {}; -+ if (not $p->eof) { -+ die "CSV parse error " . $p->error_diag(); -+ } -+ close $file; -+EOF -+--remove_file $MYSQLD_DATADIR/test_audit.log -+--remove_file $MYSQLD_DATADIR/test_audit_csv.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_default_db-master.opt b/plugin/audit_log/tests/mtr/audit_log_default_db-master.opt -new file mode 100644 -index 00000000000..033178764ec ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_default_db-master.opt -@@ -0,0 +1,4 @@ -+--audit_log_file=test_audit.log -+--audit_log_policy=ALL -+--audit-log-format=CSV -+--audit_log_strategy=SYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_default_db.result b/plugin/audit_log/tests/mtr/audit_log_default_db.result -new file mode 100644 -index 00000000000..aa17314b17a ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_default_db.result -@@ -0,0 +1,102 @@ -+set names utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+CREATE USER 'user1'@'%' IDENTIFIED BY '111'; -+CREATE USER 'user2'@'%' IDENTIFIED BY '111'; -+CREATE DATABASE db1; -+CREATE DATABASE db2; -+CREATE DATABASE `ąžąžąžą`; -+CREATE TABLE db1.t (a VARCHAR(100)); -+CREATE TABLE db2.t (a VARCHAR(100)); -+CREATE TABLE ąžąžąžą.t (a VARCHAR(100)) charset=utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+INSERT INTO db1.t VALUES ('db1'); -+INSERT INTO db2.t VALUES ('db2'); -+INSERT INTO ąžąžąžą.t VALUES ('ąžąžąžą'); -+GRANT ALL PRIVILEGES ON db1.* TO 'user1'@'%'; -+GRANT ALL PRIVILEGES ON db2.* TO 'user1'@'%'; -+GRANT ALL PRIVILEGES ON db2.* TO 'user2'@'%'; -+GRANT ALL PRIVILEGES ON ąžąžąžą.* TO 'user1'@'%'; -+GRANT ALL PRIVILEGES ON ąžąžąžą.* TO 'user2'@'%'; -+UNINSTALL PLUGIN audit_log; -+Warnings: -+Warning 1620 Plugin is busy and will be uninstalled on shutdown -+INSTALL PLUGIN audit_log SONAME 'audit_log.so'; -+SELECT * FROM t; -+a -+db2 -+use `db1`; -+ERROR 42000: Access denied for user 'user2'@'%' to database 'db1' -+connect(localhost,user2,111,db1,MASTER_MYPORT,MASTER_MYSOCK); -+ERROR 42000: Access denied for user 'user2'@'%' to database 'db1' -+connect(localhost,user2,112,db2,MASTER_MYPORT,MASTER_MYSOCK); -+ERROR 28000: Access denied for user 'user2'@'localhost' (using password: YES) -+connect(localhost,user3,111,db2,MASTER_MYPORT,MASTER_MYSOCK); -+ERROR 28000: Access denied for user 'user3'@'localhost' (using password: YES) -+set names utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+SELECT * FROM t; -+a -+db2 -+use `db1`; -+ERROR 42000: Access denied for user 'user2'@'%' to database 'db1' -+SELECT * FROM t; -+a -+db2 -+set names utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+SELECT * FROM t; -+a -+db1 -+use `db2`; -+SELECT * FROM t; -+a -+db2 -+use ąžąžąžą; -+SELECT * FROM t; -+a -+ąžąžąžą -+a -+db1 -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","install_plugin","",0,"INSTALL PLUGIN audit_log SONAME 'audit_log.so'","root[root] @ localhost []","localhost","","","" -+"Quit","","","",0,"root","root","","","localhost","","test" -+"Connect","","","",0,"user1","user1","","","localhost","","db2" -+"Query","","","select","",0,"SELECT * FROM t","user1[user1] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"use `db1`","user1[user1] @ localhost []","localhost","","","db1" -+"Change user","","","",1044,"user2","user2","","","localhost","","" -+"Quit","","","",0,"user1","user1","","","localhost","","db1" -+"Connect","","","",1044,"user2","user2","","","localhost","","" -+"Connect","","","",1045,"user2","user2","","","localhost","","" -+"Connect","","","",1045,"user3","","","","localhost","","" -+"Connect","","","",0,"user2","user2","","","localhost","","db2" -+"Query","","","set_option","",0,"set names utf8","user2[user2] @ localhost []","localhost","","","db2" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","user2[user2] @ localhost []","localhost","","","db2" -+"Query","","","select","",0,"SELECT * FROM t","user2[user2] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",1044,"use `db1`","user2[user2] @ localhost []","localhost","","","db2" -+"Query","","","select","",0,"SELECT * FROM t","user2[user2] @ localhost []","localhost","","","db2" -+"Change user","","","",0,"user1","user1","","","localhost","","db1" -+"Query","","","set_option","",0,"set names utf8","user1[user1] @ localhost []","localhost","","","db1" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","user1[user1] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM t","user1[user1] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"use `db2`","user1[user1] @ localhost []","localhost","","","db2" -+"Query","","","select","",0,"SELECT * FROM t","user1[user1] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"use ąžąžąžą","user1[user1] @ localhost []","localhost","","","ąžąžąžą" -+"Query","","","select","",0,"SELECT * FROM t","user1[user1] @ localhost []","localhost","","","ąžąžąžą" -+"Quit","","","",0,"user1","user1","","","localhost","","ąžąžąžą" -+"Connect","","","",0,"user1","user1","","","localhost","","test" -+"Query","","","select","",0,"select @@version_comment limit 1","user1[user1] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT DATABASE()","user1[user1] @ localhost []","localhost","","","test" -+"Init DB","","","init db","",0,"","user1[user1] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT * FROM t","user1[user1] @ localhost []","localhost","","","test" -+"Quit","","","",0,"user1","user1","","","localhost","","db1" -+=================================================================== -+DROP DATABASE db1; -+DROP DATABASE db2; -+DROP DATABASE ąžąžąžą; -+DROP USER user1; -+DROP USER user2; -diff --git a/plugin/audit_log/tests/mtr/audit_log_default_db.test b/plugin/audit_log/tests/mtr/audit_log_default_db.test -new file mode 100644 -index 00000000000..e17e298e67d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_default_db.test -@@ -0,0 +1,100 @@ -+# test correctness of default_db field -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+set names utf8; -+ -+CREATE USER 'user1'@'%' IDENTIFIED BY '111'; -+CREATE USER 'user2'@'%' IDENTIFIED BY '111'; -+ -+CREATE DATABASE db1; -+CREATE DATABASE db2; -+CREATE DATABASE `ąžąžąžą`; -+ -+CREATE TABLE db1.t (a VARCHAR(100)); -+CREATE TABLE db2.t (a VARCHAR(100)); -+CREATE TABLE ąžąžąžą.t (a VARCHAR(100)) charset=utf8; -+INSERT INTO db1.t VALUES ('db1'); -+INSERT INTO db2.t VALUES ('db2'); -+INSERT INTO ąžąžąžą.t VALUES ('ąžąžąžą'); -+ -+GRANT ALL PRIVILEGES ON db1.* TO 'user1'@'%'; -+ -+GRANT ALL PRIVILEGES ON db2.* TO 'user1'@'%'; -+GRANT ALL PRIVILEGES ON db2.* TO 'user2'@'%'; -+ -+GRANT ALL PRIVILEGES ON ąžąžąžą.* TO 'user1'@'%'; -+GRANT ALL PRIVILEGES ON ąžąžąžą.* TO 'user2'@'%'; -+ -+# truncate audit log -+UNINSTALL PLUGIN audit_log; -+--source include/disconnect_connections.inc -+let $wait_condition= -+ SELECT count(*) = 0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'audit_log'; -+--source include/wait_condition.inc -+--remove_file $log_file -+ -+--source include/count_sessions.inc -+connect (root,localhost,root,,,); -+connection root; -+INSTALL PLUGIN audit_log SONAME 'audit_log.so'; -+disconnect root; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connect (test,localhost,user1,111,db2,); -+connection test; -+SELECT * FROM t; -+ -+use `db1`; -+--error ER_DBACCESS_DENIED_ERROR -+change_user user2,111,db1,do_not_reconnect_on_fail; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -+--error ER_DBACCESS_DENIED_ERROR -+connect (test,localhost,user2,111,db1,); -+connection default; -+--source include/wait_until_count_sessions.inc -+--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -+--error ER_ACCESS_DENIED_ERROR -+connect (test,localhost,user2,112,db2,); -+connection default; -+--source include/wait_until_count_sessions.inc -+--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -+--error ER_ACCESS_DENIED_ERROR -+connect (test,localhost,user3,111,db2,); -+connection default; -+--source include/wait_until_count_sessions.inc -+connect (test,localhost,user2,111,db2,); -+connection test; -+set names utf8; -+SELECT * FROM t; -+--error ER_DBACCESS_DENIED_ERROR -+use `db1`; -+SELECT * FROM t; -+change_user user1,111,db1; -+set names utf8; -+SELECT * FROM t; -+use `db2`; -+SELECT * FROM t; -+use ąžąžąžą; -+SELECT * FROM t; -+disconnect test; -+connection default; -+ -+--source include/wait_until_count_sessions.inc -+--exec $MYSQL --user=user1 --password=111 test -e "use db1; SELECT * FROM t;" -+--source include/wait_until_count_sessions.inc -+ -+--source audit_log_echo.inc -+ -+DROP DATABASE db1; -+DROP DATABASE db2; -+DROP DATABASE ąžąžąžą; -+ -+DROP USER user1; -+DROP USER user2; -+ -diff --git a/plugin/audit_log/tests/mtr/audit_log_echo.inc b/plugin/audit_log/tests/mtr/audit_log_echo.inc -new file mode 100644 -index 00000000000..8c92903349d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_echo.inc -@@ -0,0 +1,47 @@ -+# Echo the contents of the audit log (in CSV format) -+# log_file is the name of the log file -+ -+--move_file $log_file $log_file.copy -+set global audit_log_flush= ON; -+let log_file=$log_file; -+perl; -+ print "===================================================================\n"; -+ open my $file, $ENV{'log_file'} . '.copy' or die "Can not open log: $!"; -+ while ($line = <$file>) { -+ if ($line =~ /SET NAMES/) { -+ # change_user does automatic reconnect and messing up 'SET NAMES' around -+ next; -+ } -+ if ($line =~ /Threads_connected/ || $line =~ /SELECT \d <= \d/ -+ || /SELECT.*FROM.*INFORMATION_SCHEMA.PLUGINS/) { -+ # part of wait_until_count_sessions.inc and wait_condition.inc scripts -+ next; -+ } -+ if ($line =~ /^"Audit"/) { -+ # skip opening log record and disconnect record -+ next; -+ } -+ if ($line =~ /SELECT count\(\*\)=1 FROM t WHERE a=7/) { -+ # skip checking for event shot -+ next; -+ } -+ if ($line =~ /INSERT INTO t VALUES \(7\)/) { -+ # don't show the last statement of the event -+ next; -+ } -+ if ($line =~ /SELECT 600 \* 10/) { -+ # skip checking for event shot -+ next; -+ } -+ $line =~ s/"([a-zA-Z_ ]*)","([0-9]+)_[0-9_ :T-]*","[0-9_ :A-Z-]*"/"$1","",""/; -+ $line =~ s/"(Connect|Quit|Change user)","","","[0-9]+"/"$1","","",""/; -+ $line =~ s/"([A-Za-z ]+)","","","(init db|[a-z_]+)","[0-9]+"/"$1","","","$2",""/; -+ if ($line =~ /SET GLOBAL .*_accounts/) { -+ print "*************************************************************\n"; -+ } -+ print "$line"; -+ }; -+ close $file; -+ print "===================================================================\n"; -+EOF -+--remove_file $log_file.copy -diff --git a/plugin/audit_log/tests/mtr/audit_log_events.inc b/plugin/audit_log/tests/mtr/audit_log_events.inc -new file mode 100644 -index 00000000000..980252ade27 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_events.inc -@@ -0,0 +1,102 @@ -+# produce some events for audit log -+ -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+--error ER_TABLE_EXISTS_ERROR -+CREATE TABLE t1 -+ (c1 INT, -+ c2 CHAR(20)); -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+-- if ($test_control_chars) { -+INSERT INTO `t1` VALUES (4,NULL); -+# can't add the zero ascii character, as that's a syntax error in MySQL -+INSERT INTO `t1` VALUES (6,''); -+INSERT INTO `t1` VALUES (7,''); -+INSERT INTO `t1` VALUES (8,''); -+INSERT INTO `t1` VALUES (9,''); -+INSERT INTO `t1` VALUES (10,''); -+INSERT INTO `t1` VALUES (11,''); -+INSERT INTO `t1` VALUES (12,''); -+INSERT INTO `t1` VALUES (13,''); -+INSERT INTO `t1` VALUES (14,' '); -+INSERT INTO `t1` VALUES (15,' -+'); -+INSERT INTO `t1` VALUES (16,' '); -+INSERT INTO `t1` VALUES (17,' '); -+INSERT INTO `t1` VALUES (18,' '); -+INSERT INTO `t1` VALUES (19,''); -+INSERT INTO `t1` VALUES (20,''); -+INSERT INTO `t1` VALUES (21,''); -+INSERT INTO `t1` VALUES (22,''); -+INSERT INTO `t1` VALUES (23,''); -+INSERT INTO `t1` VALUES (24,''); -+INSERT INTO `t1` VALUES (25,''); -+INSERT INTO `t1` VALUES (26,''); -+INSERT INTO `t1` VALUES (27,''); -+INSERT INTO `t1` VALUES (28,''); -+INSERT INTO `t1` VALUES (29,''); -+INSERT INTO `t1` VALUES (30,''); -+INSERT INTO `t1` VALUES (31,''); -+INSERT INTO `t1` VALUES (32,''); -+INSERT INTO `t1` VALUES (33,''); -+INSERT INTO `t1` VALUES (34,''); -+INSERT INTO `t1` VALUES (35,''); -+INSERT INTO `t1` VALUES (36,''); -+-- } -+SELECT * FROM t1; -+--error ER_NO_SUCH_TABLE -+SELECT * FROM t2; -+DROP TABLE t1; -+ -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+SHOW STATUS LIKE 'audit_log%'; -+ -+DEALLOCATE PREPARE stmt1; -+ -+show variables like 'audit_log%'; -+--source include/count_sessions.inc -+connect (con1,localhost,root,,mysql); -+connection default; -+disconnect con1; -+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT -+--error ER_ACCESS_DENIED_ERROR -+connect (con1,localhost,no_such_user,,mysql); -+connection default; -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+# query is longer than 4k -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+alter table t1 rename renamed_t1; -+--error ER_NO_SUCH_TABLE -+select * from t_doesnt_exist; -+--error 1064 -+syntax_error_query; -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+create database sa_db; -+connect (con1,localhost,root,,test); -+connection con1; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+connection default; -+# IDENTIFIED BY will be logged as IDENTIFIED ... AS, containing control chars -+if ($test_control_chars) { -+ create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass'; -+ drop user 'jeffrey'@'localhost'; -+} -+select '&;&&&""""<><<>>>>'; -+if ($test_control_chars) { -+ let $str=`SELECT x'2009080c0a0d2f225c5c'`; -+ eval select '$str'; -+} -+disconnect con1; -+--source include/wait_until_count_sessions.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_commands-master.opt b/plugin/audit_log/tests/mtr/audit_log_filter_commands-master.opt -new file mode 100644 -index 00000000000..ad7f91c65bd ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_commands-master.opt -@@ -0,0 +1,6 @@ -+$AUDIT_LOG_OPT -+$AUDIT_LOG_LOAD -+--audit_log_file=test_audit.log -+--audit_log_policy=ALL -+--audit-log-format=CSV -+--audit_log_strategy=SYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_commands.result b/plugin/audit_log/tests/mtr/audit_log_filter_commands.result -new file mode 100644 -index 00000000000..f0647dc21f2 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_commands.result -@@ -0,0 +1,217 @@ -+SET GLOBAL audit_log_include_commands= 'create_table,create_procedure,create_trigger,insert'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+create_table,create_procedure,create_trigger,insert NULL -+SET GLOBAL audit_log_exclude_commands= 'alter_db_upgrade,change_db,drop_table,drop_db'; -+ERROR 42000: Variable 'audit_log_exclude_commands' can't be set to the value of 'alter_db_upgrade,change_db,drop_table,drop_db' -+SET GLOBAL audit_log_exclude_commands= NULL; -+ERROR 42000: Variable 'audit_log_exclude_commands' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+create_table,create_procedure,create_trigger,insert NULL -+SET GLOBAL audit_log_include_commands= 'alter_db_upgrade,change_db,drop_table,drop_db'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+alter_db_upgrade,change_db,drop_table,drop_db NULL -+SET GLOBAL audit_log_include_commands= ''; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+ NULL -+SET GLOBAL audit_log_exclude_commands= 'insert,call_procedure,call_procedure,set_option,assign_to_keycache'; -+ERROR 42000: Variable 'audit_log_exclude_commands' can't be set to the value of 'insert,call_procedure,call_procedure,set_option,assign_to_keycache' -+SET GLOBAL audit_log_include_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL NULL -+SET GLOBAL audit_log_exclude_commands= "insert,call_procedure,call_procedure,set_option,assign_to_keycache"; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL insert,call_procedure,call_procedure,set_option,assign_to_keycache -+SET GLOBAL audit_log_include_commands= 'change_db,drop_table@localhost'; -+ERROR 42000: Variable 'audit_log_include_commands' can't be set to the value of 'change_db,drop_table@localhost' -+SET GLOBAL audit_log_include_commands= NULL; -+ERROR 42000: Variable 'audit_log_include_commands' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL insert,call_procedure,call_procedure,set_option,assign_to_keycache -+SET GLOBAL audit_log_exclude_commands= 'change_db,drop_table'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL change_db,drop_table -+SET GLOBAL audit_log_exclude_commands= ''; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL -+SET GLOBAL audit_log_include_commands= 'change_db'; -+ERROR 42000: Variable 'audit_log_include_commands' can't be set to the value of 'change_db' -+SET GLOBAL audit_log_exclude_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+@@audit_log_include_commands @@audit_log_exclude_commands -+NULL NULL -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_exclude_commands= NULL; -+SET GLOBAL audit_log_include_commands= NULL; -+CREATE DATABASE db1 DEFAULT CHARACTER SET latin1; -+USE db1; -+CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM; -+CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB; -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END// -+CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b); -+INSERT INTO t1 VALUES (5,5); -+CALL p1(); -+SET GLOBAL keycache1.key_buffer_size=128*1024; -+Warnings: -+Warning 1287 keycache1.key_buffer_size syntax is deprecated and will be removed in a future release -+CACHE INDEX t1 IN keycache1; -+Table Op Msg_type Msg_text -+db1.t1 assign_to_keycache status OK -+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+USE test; -+DROP TABLE db1.t1; -+DROP DATABASE db1; -+SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,CREATE_TABLE,CREATE_TABLE,CREATE_PROCEDURE,CREATE_TRIGger,insert,insert,insert,call_procedure,call_procedure,set_option,assign_to_keycache,alter_db,alter_db_upgrade,change_db,drop_table,drop_db'; -+CREATE DATABASE db1 DEFAULT CHARACTER SET latin1; -+USE db1; -+CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM; -+CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB; -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END// -+CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b); -+INSERT INTO t1 VALUES (5,5); -+CALL p1(); -+SET GLOBAL keycache1.key_buffer_size=128*1024; -+Warnings: -+Warning 1287 keycache1.key_buffer_size syntax is deprecated and will be removed in a future release -+CACHE INDEX t1 IN keycache1; -+Table Op Msg_type Msg_text -+db1.t1 assign_to_keycache status OK -+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+USE test; -+DROP TABLE db1.t1; -+DROP DATABASE db1; -+SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,assign_to_keycache,alter_db,alter_db_upgrade'; -+CREATE DATABASE db1 DEFAULT CHARACTER SET latin1; -+USE db1; -+CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM; -+CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB; -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END// -+CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b); -+INSERT INTO t1 VALUES (5,5); -+CALL p1(); -+SET GLOBAL keycache1.key_buffer_size=128*1024; -+Warnings: -+Warning 1287 keycache1.key_buffer_size syntax is deprecated and will be removed in a future release -+CACHE INDEX t1 IN keycache1; -+Table Op Msg_type Msg_text -+db1.t1 assign_to_keycache status OK -+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+USE test; -+DROP TABLE db1.t1; -+DROP DATABASE db1; -+SET GLOBAL audit_log_include_commands= NULL; -+SET GLOBAL audit_log_exclude_commands= 'set_option,create_db,change_db,create_table,create_table,create_prOCEDURE,CREATE_TRIGGER,INSERT,INSERT,INSERT,CALL_PROCEDURE,CALL_PROCEDUre,set_option,assign_to_keycache,alter_db,alter_db_upgrade,change_db,drop_table,drop_db'; -+CREATE DATABASE db1 DEFAULT CHARACTER SET latin1; -+USE db1; -+CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM; -+CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB; -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END// -+CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b); -+INSERT INTO t1 VALUES (5,5); -+CALL p1(); -+SET GLOBAL keycache1.key_buffer_size=128*1024; -+Warnings: -+Warning 1287 keycache1.key_buffer_size syntax is deprecated and will be removed in a future release -+CACHE INDEX t1 IN keycache1; -+Table Op Msg_type Msg_text -+db1.t1 assign_to_keycache status OK -+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8; -+Warnings: -+Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. -+USE test; -+DROP TABLE db1.t1; -+DROP DATABASE db1; -+SET GLOBAL audit_log_exclude_commands= NULL; -+SET GLOBAL audit_log_include_commands= NULL; -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_commands= NULL","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands= NULL","root[root] @ localhost []","localhost","","","test" -+"Ping","","","ping","",0,"","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_db","",0,"CREATE DATABASE db1 DEFAULT CHARACTER SET latin1","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t1 VALUES (5,5)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO t1 (a, b) VALUES (1, 1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET GLOBAL keycache1.key_buffer_size=128*1024","root[root] @ localhost []","localhost","","","db1" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","db1" -+"Query","","","assign_to_keycache","",0,"CACHE INDEX t1 IN keycache1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","alter_db","",0,"ALTER DATABASE db1 DEFAULT CHARACTER SET utf8","root[root] @ localhost []","localhost","","","db1" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_db","",0,"DROP DATABASE db1","root[root] @ localhost []","localhost","","","test" -+"Ping","","","ping","",0,"","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,CREATE_TABLE,CREATE_TABLE,CREATE_PROCEDURE,CREATE_TRIGger,insert,insert,insert,call_procedure,call_procedure,set_option,assign_to_keycache,alter_db,alter_db_upgrade,change_db,drop_table,drop_db'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_db","",0,"CREATE DATABASE db1 DEFAULT CHARACTER SET latin1","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO t1 (a, b) VALUES (1, 1); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t1 VALUES (5,5)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t2 (a, b) VALUES (new.a, new.b)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO t1 (a, b) VALUES (1, 1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET GLOBAL keycache1.key_buffer_size=128*1024","root[root] @ localhost []","localhost","","","db1" -+"Query","","","assign_to_keycache","",0,"CACHE INDEX t1 IN keycache1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","alter_db","",0,"ALTER DATABASE db1 DEFAULT CHARACTER SET utf8","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_db","",0,"DROP DATABASE db1","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,assign_to_keycache,alter_db,alter_db_upgrade'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_db","",0,"CREATE DATABASE db1 DEFAULT CHARACTER SET latin1","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET GLOBAL keycache1.key_buffer_size=128*1024","root[root] @ localhost []","localhost","","","db1" -+"Query","","","assign_to_keycache","",0,"CACHE INDEX t1 IN keycache1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","alter_db","",0,"ALTER DATABASE db1 DEFAULT CHARACTER SET utf8","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands= NULL","root[root] @ localhost []","localhost","","","test" -+"Ping","","","ping","",0,"","root[root] @ localhost []","localhost","","","test" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","db1" -+"Query","","","show_warnings","",0,"SHOW WARNINGS","root[root] @ localhost []","localhost","","","db1" -+"Ping","","","ping","",0,"","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_commands= NULL","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands= NULL","root[root] @ localhost []","localhost","","","test" -+=================================================================== -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_commands.test b/plugin/audit_log/tests/mtr/audit_log_filter_commands.test -new file mode 100644 -index 00000000000..efbb73524d3 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_commands.test -@@ -0,0 +1,71 @@ -+# test filtering by sql_command -+ -+# test set/unset filters -+ -+SET GLOBAL audit_log_include_commands= 'create_table,create_procedure,create_trigger,insert'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_commands= 'alter_db_upgrade,change_db,drop_table,drop_db'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+SET GLOBAL audit_log_include_commands= 'alter_db_upgrade,change_db,drop_table,drop_db'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+SET GLOBAL audit_log_include_commands= ''; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_commands= 'insert,call_procedure,call_procedure,set_option,assign_to_keycache'; -+SET GLOBAL audit_log_include_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+ -+SET GLOBAL audit_log_exclude_commands= "insert,call_procedure,call_procedure,set_option,assign_to_keycache"; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_commands= 'change_db,drop_table@localhost'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+SET GLOBAL audit_log_exclude_commands= 'change_db,drop_table'; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+SET GLOBAL audit_log_exclude_commands= ''; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_commands= 'change_db'; -+SET GLOBAL audit_log_exclude_commands= NULL; -+SELECT @@audit_log_include_commands, @@audit_log_exclude_commands; -+ -+# test filtering -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+ -+# log everything -+SET GLOBAL audit_log_exclude_commands= NULL; -+SET GLOBAL audit_log_include_commands= NULL; -+ -+--source audit_log_filter_commands_events.inc -+ -+# log everything once again -+SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,CREATE_TABLE,CREATE_TABLE,CREATE_PROCEDURE,CREATE_TRIGger,insert,insert,insert,call_procedure,call_procedure,set_option,assign_to_keycache,alter_db,alter_db_upgrade,change_db,drop_table,drop_db'; -+ -+--source audit_log_filter_commands_events.inc -+ -+# log some of the commands -+SET GLOBAL audit_log_include_commands= 'set_option,creaTE_DB,CHANGE_DB,assign_to_keycache,alter_db,alter_db_upgrade'; -+ -+--source audit_log_filter_commands_events.inc -+ -+# log nothing -+SET GLOBAL audit_log_include_commands= NULL; -+SET GLOBAL audit_log_exclude_commands= 'set_option,create_db,change_db,create_table,create_table,create_prOCEDURE,CREATE_TRIGGER,INSERT,INSERT,INSERT,CALL_PROCEDURE,CALL_PROCEDUre,set_option,assign_to_keycache,alter_db,alter_db_upgrade,change_db,drop_table,drop_db'; -+ -+--source audit_log_filter_commands_events.inc -+ -+SET GLOBAL audit_log_exclude_commands= NULL; -+SET GLOBAL audit_log_include_commands= NULL; -+ -+--source audit_log_echo.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_commands_events.inc b/plugin/audit_log/tests/mtr/audit_log_filter_commands_events.inc -new file mode 100644 -index 00000000000..362d4adbc05 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_commands_events.inc -@@ -0,0 +1,28 @@ -+ -+PING; -+CREATE DATABASE db1 DEFAULT CHARACTER SET latin1; -+USE db1; -+CREATE TABLE t1 (a INT, b INT, KEY(b)) engine=MyISAM; -+CREATE TABLE t2 (a INT, b INT, KEY(b)) engine=InnoDB; -+ -+DELIMITER //; -+CREATE PROCEDURE p1() -+BEGIN -+ INSERT INTO t1 (a, b) VALUES (1, 1); -+END// -+DELIMITER ;// -+ -+CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 (a, b) VALUES (new.a, new.b); -+ -+INSERT INTO t1 VALUES (5,5); -+CALL p1(); -+ -+SET GLOBAL keycache1.key_buffer_size=128*1024; -+CACHE INDEX t1 IN keycache1; -+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8; -+ -+USE test; -+DROP TABLE db1.t1; -+DROP DATABASE db1; -+ -+PING; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_db-master.opt b/plugin/audit_log/tests/mtr/audit_log_filter_db-master.opt -new file mode 100644 -index 00000000000..0adac3307e3 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_db-master.opt -@@ -0,0 +1,5 @@ -+--audit_log_file=test_audit.log -+--audit_log_policy=ALL -+--audit-log-format=CSV -+--audit_log_strategy=SYNCHRONOUS -+--thread_stack=16777216 -\ No newline at end of file -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_db.result b/plugin/audit_log/tests/mtr/audit_log_filter_db.result -new file mode 100644 -index 00000000000..0e2869d31b5 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_db.result -@@ -0,0 +1,1582 @@ -+CREATE DATABASE db1; -+CREATE DATABASE db2; -+CREATE DATABASE ```db3"`; -+CREATE DATABASE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+SHOW DATABASES; -+Database -+`db3" -+db1 -+db2 -+information_schema -+mtr -+mysql -+performance_schema -+some_very_long,database_na'me`some_very_long_database_n"ame____q -+sys -+test -+SET GLOBAL audit_log_include_databases= '`some_very_long,database_na\'me``some_very_long_database_n"ame____q`,```db1"`,db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+`some_very_long,database_na'me``some_very_long_database_n"ame____q`,```db1"`,db3 NULL -+SET GLOBAL audit_log_exclude_databases= 'db2'; -+ERROR 42000: Variable 'audit_log_exclude_databases' can't be set to the value of 'db2' -+SET GLOBAL audit_log_exclude_databases= NULL; -+ERROR 42000: Variable 'audit_log_exclude_databases' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+`some_very_long,database_na'me``some_very_long_database_n"ame____q`,```db1"`,db3 NULL -+SET GLOBAL audit_log_include_databases= 'db1, db2, db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+db1, db2, db3 NULL -+SET GLOBAL audit_log_include_databases= ''; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+ NULL -+SET GLOBAL audit_log_exclude_databases= 'db1'; -+ERROR 42000: Variable 'audit_log_exclude_databases' can't be set to the value of 'db1' -+SET GLOBAL audit_log_include_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL NULL -+SET GLOBAL audit_log_exclude_databases= 'db2,`db3 `'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL db2,`db3 ` -+SET GLOBAL audit_log_include_databases= 'db1, db2, db3'; -+ERROR 42000: Variable 'audit_log_include_databases' can't be set to the value of 'db1, db2, db3' -+SET GLOBAL audit_log_include_databases= NULL; -+ERROR 42000: Variable 'audit_log_include_databases' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL db2,`db3 ` -+SET GLOBAL audit_log_exclude_databases= 'db1, db2, db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL db1, db2, db3 -+SET GLOBAL audit_log_exclude_databases= ''; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL -+SET GLOBAL audit_log_include_databases= 'db2'; -+ERROR 42000: Variable 'audit_log_include_databases' can't be set to the value of 'db2' -+SET GLOBAL audit_log_exclude_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+@@audit_log_include_databases @@audit_log_exclude_databases -+NULL NULL -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_include_databases= 'db1,```db3"`'; -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+CREATE TABLE db1.words (id INT, word TEXT); -+USE db1; -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END// -+CALL p1(); -+CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+CREATE TABLE a0 (a INT); -+CREATE TABLE a1 (a INT); -+CREATE TABLE a2 (a INT); -+CREATE TABLE a3 (a INT); -+CREATE TABLE a4 (a INT); -+CREATE TABLE a5 (a INT); -+CREATE TABLE a6 (a INT); -+CREATE TABLE a7 (a INT); -+CREATE TABLE a8 (a INT); -+CREATE TABLE a9 (a INT); -+CREATE TABLE a10 (a INT); -+CREATE TABLE a11 (a INT); -+CREATE TABLE a12 (a INT); -+CREATE TABLE a13 (a INT); -+CREATE TABLE a14 (a INT); -+CREATE TABLE a15 (a INT); -+CREATE TABLE a16 (a INT); -+CREATE TABLE a17 (a INT); -+CREATE TABLE a18 (a INT); -+CREATE TABLE a19 (a INT); -+CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a); -+CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a); -+CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a); -+CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a); -+CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a); -+CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a); -+CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a); -+CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a); -+CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a); -+CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a); -+CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a); -+CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a); -+CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a); -+CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a); -+CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a); -+CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a); -+CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a); -+CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a); -+CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a); -+CREATE TABLE b0 (a INT); -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+INSERT INTO a19 VALUES (1); -+INSERT INTO b0 VALUES (1); -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+a id word a -+77 NULL NULL NULL -+7 NULL NULL NULL -+1 NULL NULL 2 -+2 2 two NULL -+3 3 three NULL -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+s a -+3 3 -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+s a -+3 3 -+SELECT * FROM vmat; -+s -+3 -+SELECT a FROM vjoin; -+a -+3 -+SELECT s FROM vjoin; -+s -+3 -+SELECT a,s FROM vjoin; -+a s -+3 3 -+SELECT s FROM vmat; -+s -+3 -+SELECT a FROM vup; -+a -+207 -+210 -+101 -+102 -+103 -+1 -+2 -+3 -+6 -+1 -+2 -+1 -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+USE test; -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+a -+1 -+2 -+SELECT 1; -+1 -+1 -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+DROP TABLE db1.a0; -+DROP TABLE db1.a1; -+DROP TABLE db1.a2; -+DROP TABLE db1.a3; -+DROP TABLE db1.a4; -+DROP TABLE db1.a5; -+DROP TABLE db1.a6; -+DROP TABLE db1.a7; -+DROP TABLE db1.a8; -+DROP TABLE db1.a9; -+DROP TABLE db1.a10; -+DROP TABLE db1.a11; -+DROP TABLE db1.a12; -+DROP TABLE db1.a13; -+DROP TABLE db1.a14; -+DROP TABLE db1.a15; -+DROP TABLE db1.a16; -+DROP TABLE db1.a17; -+DROP TABLE db1.a18; -+DROP TABLE db1.a19; -+DROP TABLE db1.b0; -+SET GLOBAL audit_log_include_databases= 'db2,```db3"`'; -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+CREATE TABLE db1.words (id INT, word TEXT); -+USE db1; -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END// -+CALL p1(); -+CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+CREATE TABLE a0 (a INT); -+CREATE TABLE a1 (a INT); -+CREATE TABLE a2 (a INT); -+CREATE TABLE a3 (a INT); -+CREATE TABLE a4 (a INT); -+CREATE TABLE a5 (a INT); -+CREATE TABLE a6 (a INT); -+CREATE TABLE a7 (a INT); -+CREATE TABLE a8 (a INT); -+CREATE TABLE a9 (a INT); -+CREATE TABLE a10 (a INT); -+CREATE TABLE a11 (a INT); -+CREATE TABLE a12 (a INT); -+CREATE TABLE a13 (a INT); -+CREATE TABLE a14 (a INT); -+CREATE TABLE a15 (a INT); -+CREATE TABLE a16 (a INT); -+CREATE TABLE a17 (a INT); -+CREATE TABLE a18 (a INT); -+CREATE TABLE a19 (a INT); -+CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a); -+CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a); -+CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a); -+CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a); -+CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a); -+CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a); -+CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a); -+CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a); -+CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a); -+CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a); -+CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a); -+CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a); -+CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a); -+CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a); -+CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a); -+CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a); -+CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a); -+CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a); -+CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a); -+CREATE TABLE b0 (a INT); -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+INSERT INTO a19 VALUES (1); -+INSERT INTO b0 VALUES (1); -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+a id word a -+77 NULL NULL NULL -+7 NULL NULL NULL -+1 NULL NULL 2 -+2 2 two NULL -+3 3 three NULL -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+s a -+3 3 -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+s a -+3 3 -+SELECT * FROM vmat; -+s -+3 -+SELECT a FROM vjoin; -+a -+3 -+SELECT s FROM vjoin; -+s -+3 -+SELECT a,s FROM vjoin; -+a s -+3 3 -+SELECT s FROM vmat; -+s -+3 -+SELECT a FROM vup; -+a -+207 -+210 -+101 -+102 -+103 -+1 -+2 -+3 -+6 -+1 -+2 -+1 -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+USE test; -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+a -+1 -+2 -+SELECT 1; -+1 -+1 -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+DROP TABLE db1.a0; -+DROP TABLE db1.a1; -+DROP TABLE db1.a2; -+DROP TABLE db1.a3; -+DROP TABLE db1.a4; -+DROP TABLE db1.a5; -+DROP TABLE db1.a6; -+DROP TABLE db1.a7; -+DROP TABLE db1.a8; -+DROP TABLE db1.a9; -+DROP TABLE db1.a10; -+DROP TABLE db1.a11; -+DROP TABLE db1.a12; -+DROP TABLE db1.a13; -+DROP TABLE db1.a14; -+DROP TABLE db1.a15; -+DROP TABLE db1.a16; -+DROP TABLE db1.a17; -+DROP TABLE db1.a18; -+DROP TABLE db1.a19; -+DROP TABLE db1.b0; -+SET GLOBAL audit_log_include_databases= NULL; -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+CREATE TABLE db1.words (id INT, word TEXT); -+USE db1; -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END// -+CALL p1(); -+CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+CREATE TABLE a0 (a INT); -+CREATE TABLE a1 (a INT); -+CREATE TABLE a2 (a INT); -+CREATE TABLE a3 (a INT); -+CREATE TABLE a4 (a INT); -+CREATE TABLE a5 (a INT); -+CREATE TABLE a6 (a INT); -+CREATE TABLE a7 (a INT); -+CREATE TABLE a8 (a INT); -+CREATE TABLE a9 (a INT); -+CREATE TABLE a10 (a INT); -+CREATE TABLE a11 (a INT); -+CREATE TABLE a12 (a INT); -+CREATE TABLE a13 (a INT); -+CREATE TABLE a14 (a INT); -+CREATE TABLE a15 (a INT); -+CREATE TABLE a16 (a INT); -+CREATE TABLE a17 (a INT); -+CREATE TABLE a18 (a INT); -+CREATE TABLE a19 (a INT); -+CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a); -+CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a); -+CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a); -+CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a); -+CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a); -+CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a); -+CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a); -+CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a); -+CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a); -+CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a); -+CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a); -+CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a); -+CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a); -+CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a); -+CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a); -+CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a); -+CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a); -+CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a); -+CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a); -+CREATE TABLE b0 (a INT); -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+INSERT INTO a19 VALUES (1); -+INSERT INTO b0 VALUES (1); -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+a id word a -+77 NULL NULL NULL -+7 NULL NULL NULL -+1 NULL NULL 2 -+2 2 two NULL -+3 3 three NULL -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+s a -+3 3 -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+s a -+3 3 -+SELECT * FROM vmat; -+s -+3 -+SELECT a FROM vjoin; -+a -+3 -+SELECT s FROM vjoin; -+s -+3 -+SELECT a,s FROM vjoin; -+a s -+3 3 -+SELECT s FROM vmat; -+s -+3 -+SELECT a FROM vup; -+a -+207 -+210 -+101 -+102 -+103 -+1 -+2 -+3 -+6 -+1 -+2 -+1 -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+USE test; -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+a -+1 -+2 -+SELECT 1; -+1 -+1 -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+DROP TABLE db1.a0; -+DROP TABLE db1.a1; -+DROP TABLE db1.a2; -+DROP TABLE db1.a3; -+DROP TABLE db1.a4; -+DROP TABLE db1.a5; -+DROP TABLE db1.a6; -+DROP TABLE db1.a7; -+DROP TABLE db1.a8; -+DROP TABLE db1.a9; -+DROP TABLE db1.a10; -+DROP TABLE db1.a11; -+DROP TABLE db1.a12; -+DROP TABLE db1.a13; -+DROP TABLE db1.a14; -+DROP TABLE db1.a15; -+DROP TABLE db1.a16; -+DROP TABLE db1.a17; -+DROP TABLE db1.a18; -+DROP TABLE db1.a19; -+DROP TABLE db1.b0; -+SET GLOBAL audit_log_exclude_databases= 'db1,`some_very_long,database_na\'me``some_very_long_database_n"ame____q`'; -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+CREATE TABLE db1.words (id INT, word TEXT); -+USE db1; -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END// -+CALL p1(); -+CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+CREATE TABLE a0 (a INT); -+CREATE TABLE a1 (a INT); -+CREATE TABLE a2 (a INT); -+CREATE TABLE a3 (a INT); -+CREATE TABLE a4 (a INT); -+CREATE TABLE a5 (a INT); -+CREATE TABLE a6 (a INT); -+CREATE TABLE a7 (a INT); -+CREATE TABLE a8 (a INT); -+CREATE TABLE a9 (a INT); -+CREATE TABLE a10 (a INT); -+CREATE TABLE a11 (a INT); -+CREATE TABLE a12 (a INT); -+CREATE TABLE a13 (a INT); -+CREATE TABLE a14 (a INT); -+CREATE TABLE a15 (a INT); -+CREATE TABLE a16 (a INT); -+CREATE TABLE a17 (a INT); -+CREATE TABLE a18 (a INT); -+CREATE TABLE a19 (a INT); -+CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a); -+CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a); -+CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a); -+CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a); -+CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a); -+CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a); -+CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a); -+CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a); -+CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a); -+CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a); -+CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a); -+CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a); -+CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a); -+CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a); -+CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a); -+CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a); -+CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a); -+CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a); -+CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a); -+CREATE TABLE b0 (a INT); -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+INSERT INTO a19 VALUES (1); -+INSERT INTO b0 VALUES (1); -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+a id word a -+77 NULL NULL NULL -+7 NULL NULL NULL -+1 NULL NULL 2 -+2 2 two NULL -+3 3 three NULL -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+s a -+3 3 -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+s a -+3 3 -+SELECT * FROM vmat; -+s -+3 -+SELECT a FROM vjoin; -+a -+3 -+SELECT s FROM vjoin; -+s -+3 -+SELECT a,s FROM vjoin; -+a s -+3 3 -+SELECT s FROM vmat; -+s -+3 -+SELECT a FROM vup; -+a -+207 -+210 -+101 -+102 -+103 -+1 -+2 -+3 -+6 -+1 -+2 -+1 -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+USE test; -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+a -+1 -+2 -+SELECT 1; -+1 -+1 -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+DROP TABLE db1.a0; -+DROP TABLE db1.a1; -+DROP TABLE db1.a2; -+DROP TABLE db1.a3; -+DROP TABLE db1.a4; -+DROP TABLE db1.a5; -+DROP TABLE db1.a6; -+DROP TABLE db1.a7; -+DROP TABLE db1.a8; -+DROP TABLE db1.a9; -+DROP TABLE db1.a10; -+DROP TABLE db1.a11; -+DROP TABLE db1.a12; -+DROP TABLE db1.a13; -+DROP TABLE db1.a14; -+DROP TABLE db1.a15; -+DROP TABLE db1.a16; -+DROP TABLE db1.a17; -+DROP TABLE db1.a18; -+DROP TABLE db1.a19; -+DROP TABLE db1.b0; -+SET GLOBAL audit_log_exclude_databases= 'db1,db2'; -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+CREATE TABLE db1.words (id INT, word TEXT); -+USE db1; -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END// -+CALL p1(); -+CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+CREATE TABLE a0 (a INT); -+CREATE TABLE a1 (a INT); -+CREATE TABLE a2 (a INT); -+CREATE TABLE a3 (a INT); -+CREATE TABLE a4 (a INT); -+CREATE TABLE a5 (a INT); -+CREATE TABLE a6 (a INT); -+CREATE TABLE a7 (a INT); -+CREATE TABLE a8 (a INT); -+CREATE TABLE a9 (a INT); -+CREATE TABLE a10 (a INT); -+CREATE TABLE a11 (a INT); -+CREATE TABLE a12 (a INT); -+CREATE TABLE a13 (a INT); -+CREATE TABLE a14 (a INT); -+CREATE TABLE a15 (a INT); -+CREATE TABLE a16 (a INT); -+CREATE TABLE a17 (a INT); -+CREATE TABLE a18 (a INT); -+CREATE TABLE a19 (a INT); -+CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a); -+CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a); -+CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a); -+CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a); -+CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a); -+CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a); -+CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a); -+CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a); -+CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a); -+CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a); -+CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a); -+CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a); -+CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a); -+CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a); -+CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a); -+CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a); -+CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a); -+CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a); -+CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a); -+CREATE TABLE b0 (a INT); -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+INSERT INTO a19 VALUES (1); -+INSERT INTO b0 VALUES (1); -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+a id word a -+77 NULL NULL NULL -+7 NULL NULL NULL -+1 NULL NULL 2 -+2 2 two NULL -+3 3 three NULL -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+s a -+3 3 -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+s a -+3 3 -+SELECT * FROM vmat; -+s -+3 -+SELECT a FROM vjoin; -+a -+3 -+SELECT s FROM vjoin; -+s -+3 -+SELECT a,s FROM vjoin; -+a s -+3 3 -+SELECT s FROM vmat; -+s -+3 -+SELECT a FROM vup; -+a -+207 -+210 -+101 -+102 -+103 -+1 -+2 -+3 -+6 -+1 -+2 -+1 -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+USE test; -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+a -+1 -+2 -+SELECT 1; -+1 -+1 -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+DROP TABLE db1.a0; -+DROP TABLE db1.a1; -+DROP TABLE db1.a2; -+DROP TABLE db1.a3; -+DROP TABLE db1.a4; -+DROP TABLE db1.a5; -+DROP TABLE db1.a6; -+DROP TABLE db1.a7; -+DROP TABLE db1.a8; -+DROP TABLE db1.a9; -+DROP TABLE db1.a10; -+DROP TABLE db1.a11; -+DROP TABLE db1.a12; -+DROP TABLE db1.a13; -+DROP TABLE db1.a14; -+DROP TABLE db1.a15; -+DROP TABLE db1.a16; -+DROP TABLE db1.a17; -+DROP TABLE db1.a18; -+DROP TABLE db1.a19; -+DROP TABLE db1.b0; -+SET GLOBAL audit_log_exclude_databases= NULL; -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_databases= 'db1,```db3""`'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.trig (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db2.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE ```db3""`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.words (id INT, word TEXT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vup AS SELECT * FROM db2.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"INSERT INTO t VALUES (77)","root[root] @ localhost [localhost]","localhost","","localhost","" -+"Query","","","create_trigger","",0,"CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET max_sp_recursion_depth = 20","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p2(10)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO trig VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three')","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a1 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a2 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a3 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a4 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a5 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a6 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a7 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a8 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a9 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a10 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a11 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a12 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a13 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a14 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a15 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a16 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a17 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a18 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a19 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE b0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a19 VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @tmp=1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @abc='cba'","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO b0 VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE db2","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert_select","",0,"INSERT INTO t SELECT * FROM db1.t","root[root] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"USE ```db3""`","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","change_db","",0,"USE `some_very_long,database_na'me``some_very_long_database_n""ame____q`","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","change_db","",0,"use db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a,s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vmat","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vjoin SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t)","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.words","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.trig","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db2.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE ```db3""`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vmat","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vup","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vjoin","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a0","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a3","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a4","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a5","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a6","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a7","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a8","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a9","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a10","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a11","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a12","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a13","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a14","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a15","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a16","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a17","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a18","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a19","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.b0","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_databases= 'db2,```db3""`'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.trig (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db2.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE ```db3""`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.words (id INT, word TEXT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vup AS SELECT * FROM db2.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (207)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET max_sp_recursion_depth = 20","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (200 + a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p2(10)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO trig VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a1 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a2 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a3 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a4 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a5 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a6 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a7 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a8 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a9 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a10 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a11 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a12 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a13 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a14 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a15 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a16 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a17 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a18 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a19 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE b0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @tmp=1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @abc='cba'","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE db2","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3), (6)","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert_select","",0,"INSERT INTO t SELECT * FROM db1.t","root[root] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"USE ```db3""`","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","change_db","",0,"USE `some_very_long,database_na'me``some_very_long_database_n""ame____q`","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","change_db","",0,"use db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO vup VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a,s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vup","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vup SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vjoin SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.words","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.trig","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db2.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE ```db3""`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vmat","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vup","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vjoin","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a0","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a3","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a4","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a5","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a6","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a7","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a8","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a9","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a10","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a11","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a12","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a13","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a14","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a15","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a16","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a17","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a18","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a19","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.b0","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_databases= NULL","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.trig (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db2.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE ```db3""`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.words (id INT, word TEXT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vup AS SELECT * FROM db2.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"INSERT INTO t VALUES (77)","root[root] @ localhost [localhost]","localhost","","localhost","" -+"Query","","","create_trigger","",0,"CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (207)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET max_sp_recursion_depth = 20","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (200 + a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p2(10)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO trig VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three')","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a1 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a2 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a3 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a4 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a5 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a6 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a7 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a8 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a9 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a10 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a11 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a12 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a13 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a14 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a15 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a16 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a17 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a18 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a19 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE b0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO a19 VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @tmp=1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @abc='cba'","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO b0 VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE db2","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3), (6)","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert_select","",0,"INSERT INTO t SELECT * FROM db1.t","root[root] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"USE ```db3""`","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","change_db","",0,"USE `some_very_long,database_na'me``some_very_long_database_n""ame____q`","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","change_db","",0,"use db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO vup VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a,s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vmat","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vup","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vup SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vjoin SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t)","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.words","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.trig","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db2.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE ```db3""`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vmat","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vup","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vjoin","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a0","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a3","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a4","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a5","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a6","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a7","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a8","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a9","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a10","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a11","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a12","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a13","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a14","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a15","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a16","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a17","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a18","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a19","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.b0","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_databases= 'db1,`some_very_long,database_na\'me``some_very_long_database_n""ame____q`'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.trig (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db2.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE ```db3""`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.words (id INT, word TEXT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vup AS SELECT * FROM db2.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (207)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET max_sp_recursion_depth = 20","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"INSERT INTO db2.t VALUES (200 + a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p2(10)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO trig VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a1 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a2 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a3 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a4 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a5 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a6 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a7 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a8 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a9 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a10 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a11 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a12 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a13 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a14 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a15 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a16 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a17 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a18 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a19 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE b0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @tmp=1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @abc='cba'","root[root] @ localhost []","localhost","","","db1" -+"Query","","","delete_multi","",0,"DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE db2","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3), (6)","root[root] @ localhost []","localhost","","","db2" -+"Query","","","insert_select","",0,"INSERT INTO t SELECT * FROM db1.t","root[root] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"USE ```db3""`","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","change_db","",0,"USE `some_very_long,database_na'me``some_very_long_database_n""ame____q`","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","change_db","",0,"use db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"INSERT INTO vup VALUES (1)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a,s FROM vjoin","root[root] @ localhost []","localhost","","","db1" -+"Query","","","select","",0,"SELECT a FROM vup","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vup SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","update","",0,"UPDATE vjoin SET a=a+1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.words","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.trig","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db2.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE ```db3""`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vmat","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vup","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vjoin","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a0","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a3","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a4","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a5","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a6","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a7","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a8","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a9","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a10","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a11","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a12","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a13","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a14","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a15","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a16","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a17","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a18","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a19","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.b0","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_databases= 'db1,db2'","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.trig (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db2.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE ```db3""`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t (a INT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","create_table","",0,"CREATE TABLE db1.words (id INT, word TEXT)","root[root] @ localhost []","localhost","","","test" -+"Query","","","change_db","",0,"USE db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vup AS SELECT * FROM db2.t","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_view","",0,"CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p1() -+BEGIN -+INSERT INTO db2.t VALUES (207); -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p1()","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_procedure","",0,"CREATE PROCEDURE p2(a INT) -+BEGIN -+INSERT INTO db2.t VALUES (200 + a); -+IF a = 0 THEN -+CALL p2(a - 1); -+END IF; -+END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","set_option","",0,"SET max_sp_recursion_depth = 20","root[root] @ localhost []","localhost","","","db1" -+"Query","","","call_procedure","",0,"CALL p2(10)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a1 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a2 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a3 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a4 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a5 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a6 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a7 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a8 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a9 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a10 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a11 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a12 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a13 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a14 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a15 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a16 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a17 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a18 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE a19 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr1 BEFORE INSERT ON a1 FOR EACH ROW INSERT INTO a0 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr2 BEFORE INSERT ON a2 FOR EACH ROW INSERT INTO a1 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr3 BEFORE INSERT ON a3 FOR EACH ROW INSERT INTO a2 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr4 BEFORE INSERT ON a4 FOR EACH ROW INSERT INTO a3 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr5 BEFORE INSERT ON a5 FOR EACH ROW INSERT INTO a4 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr6 BEFORE INSERT ON a6 FOR EACH ROW INSERT INTO a5 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr7 BEFORE INSERT ON a7 FOR EACH ROW INSERT INTO a6 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr8 BEFORE INSERT ON a8 FOR EACH ROW INSERT INTO a7 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr9 BEFORE INSERT ON a9 FOR EACH ROW INSERT INTO a8 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr10 BEFORE INSERT ON a10 FOR EACH ROW INSERT INTO a9 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr11 BEFORE INSERT ON a11 FOR EACH ROW INSERT INTO a10 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr12 BEFORE INSERT ON a12 FOR EACH ROW INSERT INTO a11 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr13 BEFORE INSERT ON a13 FOR EACH ROW INSERT INTO a12 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr14 BEFORE INSERT ON a14 FOR EACH ROW INSERT INTO a13 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr15 BEFORE INSERT ON a15 FOR EACH ROW INSERT INTO a14 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr16 BEFORE INSERT ON a16 FOR EACH ROW INSERT INTO a15 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr17 BEFORE INSERT ON a17 FOR EACH ROW INSERT INTO a16 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr18 BEFORE INSERT ON a18 FOR EACH ROW INSERT INTO a17 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr19 BEFORE INSERT ON a19 FOR EACH ROW INSERT INTO a18 VALUES (new.a)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_table","",0,"CREATE TABLE b0 (a INT)","root[root] @ localhost []","localhost","","","db1" -+"Query","","","create_trigger","",0,"CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @tmp=1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","insert","",0,"SET @abc='cba'","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE db2","root[root] @ localhost []","localhost","","","db2" -+"Query","","","change_db","",0,"USE ```db3""`","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","``db3""" -+"Query","","","change_db","",0,"USE `some_very_long,database_na'me``some_very_long_database_n""ame____q`","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","insert","",0,"INSERT INTO t VALUES (1), (2), (3)","root[root] @ localhost []","localhost","","","some_very_long,database_na'me``some_very_long_database_n""ame____q" -+"Query","","","change_db","",0,"use db1","root[root] @ localhost []","localhost","","","db1" -+"Query","","","change_db","",0,"USE test","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t)","root[root] @ localhost []","localhost","","","test" -+"Query","","","select","",0,"SELECT 1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.words","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.trig","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db2.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE ```db3""`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE `some_very_long,database_na'me``some_very_long_database_n""ame____q`.t","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_procedure","",0,"DROP PROCEDURE db1.p2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vmat","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vup","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_view","",0,"DROP VIEW db1.vjoin","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a0","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a1","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a2","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a3","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a4","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a5","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a6","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a7","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a8","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a9","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a10","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a11","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a12","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a13","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a14","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a15","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a16","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a17","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a18","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.a19","root[root] @ localhost []","localhost","","","test" -+"Query","","","drop_table","",0,"DROP TABLE db1.b0","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_databases= NULL","root[root] @ localhost []","localhost","","","test" -+=================================================================== -+DROP DATABASE db1; -+DROP DATABASE db2; -+DROP DATABASE ```db3"`; -+DROP DATABASE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_db.test b/plugin/audit_log/tests/mtr/audit_log_filter_db.test -new file mode 100644 -index 00000000000..39c24cbbb09 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_db.test -@@ -0,0 +1,85 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+# setup some databases -+ -+CREATE DATABASE db1; -+CREATE DATABASE db2; -+CREATE DATABASE ```db3"`; -+CREATE DATABASE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+ -+SHOW DATABASES; -+ -+# test set/unset filters -+ -+SET GLOBAL audit_log_include_databases= '`some_very_long,database_na\'me``some_very_long_database_n"ame____q`,```db1"`,db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_databases= 'db2'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+SET GLOBAL audit_log_include_databases= 'db1, db2, db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+SET GLOBAL audit_log_include_databases= ''; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_databases= 'db1'; -+SET GLOBAL audit_log_include_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+ -+SET GLOBAL audit_log_exclude_databases= 'db2,`db3 `'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_databases= 'db1, db2, db3'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+SET GLOBAL audit_log_exclude_databases= 'db1, db2, db3'; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+SET GLOBAL audit_log_exclude_databases= ''; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_databases= 'db2'; -+SET GLOBAL audit_log_exclude_databases= NULL; -+SELECT @@audit_log_include_databases, @@audit_log_exclude_databases; -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+# testing include -+SET GLOBAL audit_log_include_databases= 'db1,```db3"`'; -+ -+--source audit_log_filter_db_events.inc -+ -+SET GLOBAL audit_log_include_databases= 'db2,```db3"`'; -+ -+--source audit_log_filter_db_events.inc -+ -+# log everything -+SET GLOBAL audit_log_include_databases= NULL; -+ -+--source audit_log_filter_db_events.inc -+ -+# testing exclude -+SET GLOBAL audit_log_exclude_databases= 'db1,`some_very_long,database_na\'me``some_very_long_database_n"ame____q`'; -+ -+--source audit_log_filter_db_events.inc -+ -+SET GLOBAL audit_log_exclude_databases= 'db1,db2'; -+ -+--source audit_log_filter_db_events.inc -+ -+SET GLOBAL audit_log_exclude_databases= NULL; -+ -+--source audit_log_echo.inc -+ -+# cleanup databases -+DROP DATABASE db1; -+DROP DATABASE db2; -+DROP DATABASE ```db3"`; -+DROP DATABASE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_db_events.inc b/plugin/audit_log/tests/mtr/audit_log_filter_db_events.inc -new file mode 100644 -index 00000000000..7bf2d4dbfb7 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_db_events.inc -@@ -0,0 +1,119 @@ -+CREATE TABLE db1.t (a INT); -+CREATE TABLE db1.trig (a INT); -+CREATE TABLE db2.t (a INT); -+CREATE TABLE ```db3"`.t (a INT); -+CREATE TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t (a INT); -+ -+CREATE TABLE db1.words (id INT, word TEXT); -+ -+USE db1; -+ -+CREATE VIEW vmat AS SELECT SUM(a) AS s FROM db1.t; -+CREATE VIEW vup AS SELECT * FROM db2.t; -+CREATE VIEW vjoin AS SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+ -+DELIMITER //; -+CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO BEGIN INSERT INTO t VALUES (77); INSERT INTO t VALUES (7); END// -+DELIMITER ;// -+let $wait_condition=SELECT count(*)=1 FROM t WHERE a=7; -+let $wait_timeout=600; -+--source include/wait_condition.inc -+CREATE TRIGGER ins_tring BEFORE INSERT ON db1.trig FOR EACH ROW INSERT INTO db2.t VALUES (new.a + 100); -+INSERT INTO t VALUES (1), (2), (3); -+DELIMITER //; -+CREATE PROCEDURE p1() -+BEGIN -+ INSERT INTO db2.t VALUES (207); -+END// -+DELIMITER ;// -+CALL p1(); -+DELIMITER //; -+CREATE PROCEDURE p2(a INT) -+BEGIN -+ INSERT INTO db2.t VALUES (200 + a); -+ IF a = 0 THEN -+ CALL p2(a - 1); -+ END IF; -+END// -+DELIMITER ;// -+SET max_sp_recursion_depth = 20; -+CALL p2(10); -+INSERT INTO trig VALUES (1), (2), (3); -+INSERT INTO words VALUES (0, 'one'), (2, 'two'), (3, 'three'); -+ -+let $i=0; -+while ($i < 20) -+{ -+eval CREATE TABLE a$i (a INT); -+inc $i; -+} -+ -+let $i=1; -+let $j=0; -+while ($i < 20) -+{ -+eval CREATE TRIGGER tr$i BEFORE INSERT ON a$i FOR EACH ROW INSERT INTO a$j VALUES (new.a); -+inc $i; -+inc $j; -+} -+ -+CREATE TABLE b0 (a INT); -+DELIMITER //; -+CREATE TRIGGER tr_b_0 BEFORE INSERT ON b0 FOR EACH ROW BEGIN SET @tmp=1; SET @abc='cba'; END// -+DELIMITER ;// -+ -+INSERT INTO a19 VALUES (1); -+ -+INSERT INTO b0 VALUES (1); -+ -+SELECT * FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN t q ON t.a = q.a / 2 WHERE t.a > 2; -+DELETE t, q, words FROM t LEFT JOIN words ON t.a = words.id LEFT JOIN db2.t q ON t.a = q.a / 2 WHERE t.a > 2; -+ -+USE db2; -+INSERT INTO t VALUES (1), (2), (3), (6); -+INSERT INTO t SELECT * FROM db1.t; -+ -+USE ```db3"`; -+INSERT INTO t VALUES (1), (2), (3); -+ -+USE `some_very_long,database_na'me``some_very_long_database_n"ame____q`; -+INSERT INTO t VALUES (1), (2), (3); -+ -+use db1; -+INSERT INTO vup VALUES (1); -+SELECT * FROM vjoin; -+SELECT * FROM vmat JOIN vup ON vmat.s=vup.a; -+SELECT * FROM vmat; -+SELECT a FROM vjoin; -+SELECT s FROM vjoin; -+SELECT a,s FROM vjoin; -+SELECT s FROM vmat; -+SELECT a FROM vup; -+UPDATE vup SET a=a+1; -+UPDATE vjoin SET a=a+1; -+ -+USE test; -+ -+SELECT * FROM db1.t WHERE a IN (SELECT a FROM `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t); -+ -+SELECT 1; -+ -+DROP TABLE db1.t; -+DROP TABLE db1.words; -+DROP TABLE db1.trig; -+DROP TABLE db2.t; -+DROP TABLE ```db3"`.t; -+DROP TABLE `some_very_long,database_na'me``some_very_long_database_n"ame____q`.t; -+DROP PROCEDURE db1.p1; -+DROP PROCEDURE db1.p2; -+DROP VIEW db1.vmat; -+DROP VIEW db1.vup; -+DROP VIEW db1.vjoin; -+let $i=0; -+while ($i < 20) -+{ -+eval DROP TABLE db1.a$i; -+inc $i; -+} -+DROP TABLE db1.b0; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_events.inc b/plugin/audit_log/tests/mtr/audit_log_filter_events.inc -new file mode 100644 -index 00000000000..9103f954a69 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_events.inc -@@ -0,0 +1,43 @@ -+--source include/count_sessions.inc -+ -+connect (test,127.0.0.1,user1,password1,,$MASTER_PORT,); -+connection test; -+SELECT 'user1'; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connect (test,localhost,user22,password1,,); -+connection test; -+SELECT 'user22'; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connect (test,localhost,22user,password1,,); -+connection test; -+SELECT '22user'; -+change_user user22,password1; -+SELECT 'user22'; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connect (test,127.0.0.1,admin,password1,,$MASTER_PORT,); -+connection test; -+SELECT 'admin'; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connect (test,localhost,"us,er1",password1,,); -+connection test; -+SELECT 'us,er1'; -+disconnect test; -+connection default; -+--source include/wait_until_count_sessions.inc -+ -+connection default; -+ -+connection default; -+--source include/wait_until_count_sessions.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt-master.opt b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt-master.opt -new file mode 100644 -index 00000000000..37223c16b20 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt-master.opt -@@ -0,0 +1,6 @@ -+$AUDIT_LOG_OPT -+$AUDIT_LOG_LOAD -+--audit_log_file=test_audit.log -+--audit_log_policy=QUERIES -+--audit-log-format=csv -+--audit_log_strategy=SYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.result b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.result -new file mode 100644 -index 00000000000..901cd97760e ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.result -@@ -0,0 +1,33 @@ -+# -+# PS-1116 : Audit plugin reports "command_class=error" for server-side prepared statements -+# -+CREATE USER prepare_test IDENTIFIED BY 'mysql'; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_exclude_commands= 'set_option,prepare_sql,execute_sql'; -+PREPARE pstmt FROM 'SHOW GLOBAL VARIABLES WHERE Variable_name = ?'; -+SET @pvar='max_allowed_packet'; -+EXECUTE pstmt USING @pvar; -+Variable_name Value -+max_allowed_packet 67108864 -+SET GLOBAL audit_log_exclude_commands = NULL; -+SET GLOBAL audit_log_include_commands = NULL; -+PREPARE pstmt1 FROM 'SHOW GLOBAL VARIABLES WHERE Variable_name = ?'; -+SET @pvar1 = 'max_allowed_packet'; -+EXECUTE pstmt1 USING @pvar1; -+Variable_name Value -+max_allowed_packet 67108864 -+SET GLOBAL audit_log_flush=ON; -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_commands = NULL","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_commands = NULL","root[root] @ localhost []","localhost","","","test" -+"Query","","","prepare_sql","",0,"PREPARE pstmt1 FROM ...","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET @pvar1 = 'max_allowed_packet'","root[root] @ localhost []","localhost","","","test" -+"Query","","","execute_sql","",0,"SHOW GLOBAL VARIABLES WHERE Variable_name = 'max_allowed_packet'","root[root] @ localhost []","localhost","","","test" -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+=================================================================== -+DEALLOCATE PREPARE pstmt; -+DEALLOCATE PREPARE pstmt1; -+DROP USER prepare_test; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.test b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.test -new file mode 100644 -index 00000000000..a689588b37e ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_prepare_stmt.test -@@ -0,0 +1,35 @@ -+--echo # -+--echo # PS-1116 : Audit plugin reports "command_class=error" for server-side prepared statements -+--echo # -+ -+CREATE USER prepare_test IDENTIFIED BY 'mysql'; -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file= $MYSQLD_DATADIR/test_audit.log; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+ -+#Filter by excluding select command -+SET GLOBAL audit_log_exclude_commands= 'set_option,prepare_sql,execute_sql'; -+ -+PREPARE pstmt FROM 'SHOW GLOBAL VARIABLES WHERE Variable_name = ?'; -+SET @pvar='max_allowed_packet'; -+EXECUTE pstmt USING @pvar; -+ -+#Allow everything -+SET GLOBAL audit_log_exclude_commands = NULL; -+SET GLOBAL audit_log_include_commands = NULL; -+ -+PREPARE pstmt1 FROM 'SHOW GLOBAL VARIABLES WHERE Variable_name = ?'; -+SET @pvar1 = 'max_allowed_packet'; -+EXECUTE pstmt1 USING @pvar1; -+ -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_echo.inc -+ -+DEALLOCATE PREPARE pstmt; -+DEALLOCATE PREPARE pstmt1; -+DROP USER prepare_test; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_users-master.opt b/plugin/audit_log/tests/mtr/audit_log_filter_users-master.opt -new file mode 100644 -index 00000000000..033178764ec ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_users-master.opt -@@ -0,0 +1,4 @@ -+--audit_log_file=test_audit.log -+--audit_log_policy=ALL -+--audit-log-format=CSV -+--audit_log_strategy=SYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_users.result b/plugin/audit_log/tests/mtr/audit_log_filter_users.result -new file mode 100644 -index 00000000000..50f350175f6 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_users.result -@@ -0,0 +1,213 @@ -+CREATE USER 'user1'@'127.0.0.1' IDENTIFIED BY 'password1'; -+CREATE USER 'user22'@'%' IDENTIFIED BY 'password1'; -+CREATE USER '22user'@'LOCALHOST' IDENTIFIED BY 'password1'; -+CREATE USER 'admin'@'%' IDENTIFIED BY 'password1'; -+CREATE USER 'us,er1'@'localhost' IDENTIFIED BY 'password1'; -+SET GLOBAL audit_log_include_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+user1@localhost,, user22@127.0.0.1,admin@% NULL -+SET GLOBAL audit_log_exclude_accounts= '22useer@localhost'; -+ERROR 42000: Variable 'audit_log_exclude_accounts' can't be set to the value of '22useer@localhost' -+SET GLOBAL audit_log_exclude_accounts= NULL; -+ERROR 42000: Variable 'audit_log_exclude_accounts' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+user1@localhost,, user22@127.0.0.1,admin@% NULL -+SET GLOBAL audit_log_include_accounts= 'user1@localhost, user2@localhost, user3@localhost'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+user1@localhost, user2@localhost, user3@localhost NULL -+SET GLOBAL audit_log_include_accounts= ''; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+ NULL -+SET GLOBAL audit_log_exclude_accounts= '22useer@localhost'; -+ERROR 42000: Variable 'audit_log_exclude_accounts' can't be set to the value of '22useer@localhost' -+SET GLOBAL audit_log_include_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL NULL -+SET GLOBAL audit_log_exclude_accounts= "'us,er1'@'localhost',, user22@127.0.0.1,admin@%"; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL 'us,er1'@'localhost',, user22@127.0.0.1,admin@% -+SET GLOBAL audit_log_include_accounts= '22useer@localhost'; -+ERROR 42000: Variable 'audit_log_include_accounts' can't be set to the value of '22useer@localhost' -+SET GLOBAL audit_log_include_accounts= NULL; -+ERROR 42000: Variable 'audit_log_include_accounts' can't be set to the value of 'NULL' -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL 'us,er1'@'localhost',, user22@127.0.0.1,admin@% -+SET GLOBAL audit_log_exclude_accounts= 'user1@localhost, user2@localhost, user3@localhost'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL user1@localhost, user2@localhost, user3@localhost -+SET GLOBAL audit_log_exclude_accounts= ''; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL -+SET GLOBAL audit_log_include_accounts= '22useer@localhost'; -+ERROR 42000: Variable 'audit_log_include_accounts' can't be set to the value of '22useer@localhost' -+SET GLOBAL audit_log_exclude_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+@@audit_log_include_accounts @@audit_log_exclude_accounts -+NULL NULL -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_include_accounts= ''; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_include_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%,veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooongusername@veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooonghostname'; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_include_accounts= NULL; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_exclude_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%'; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_exclude_accounts= NULL; -+SET GLOBAL audit_log_include_accounts= '22user@LocalHost,User22@%'; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_include_accounts= NULL; -+set global audit_log_flush= ON; -+=================================================================== -+"Query","","","set_option","",0,"SET GLOBAL audit_log_flush=ON","root[root] @ localhost []","localhost","","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_accounts= ''","root[root] @ localhost []","localhost","","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%,veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooongusername@veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooonghostname'","root[root] @ localhost []","localhost","","","test" -+"Connect","","","",0,"admin","admin","","","localhost","127.0.0.1","test" -+"Query","","","select","",0,"SELECT 'admin'","admin[admin] @ localhost [127.0.0.1]","localhost","","127.0.0.1","test" -+"Quit","","","",0,"admin","admin","","","localhost","127.0.0.1","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_accounts= NULL","root[root] @ localhost []","localhost","","","test" -+"Connect","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+"Query","","","select","",0,"SELECT 'user1'","user1[user1] @ localhost [127.0.0.1]","localhost","","127.0.0.1","test" -+"Quit","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+"Connect","","","",0,"user22","user22","","","localhost","","test" -+"Query","","","select","",0,"SELECT 'user22'","user22[user22] @ localhost []","localhost","","","test" -+"Quit","","","",0,"user22","user22","","","localhost","","test" -+"Connect","","","",0,"22user","22user","","","localhost","","test" -+"Query","","","select","",0,"SELECT '22user'","22user[22user] @ localhost []","localhost","","","test" -+"Change user","","","",0,"user22","user22","","","localhost","","" -+"Query","","","select","",0,"SELECT 'user22'","user22[user22] @ localhost []","localhost","","","" -+"Quit","","","",0,"user22","user22","","","localhost","","" -+"Connect","","","",0,"admin","admin","","","localhost","127.0.0.1","test" -+"Query","","","select","",0,"SELECT 'admin'","admin[admin] @ localhost [127.0.0.1]","localhost","","127.0.0.1","test" -+"Quit","","","",0,"admin","admin","","","localhost","127.0.0.1","test" -+"Connect","","","",0,"us,er1","us,er1","","","localhost","","test" -+"Query","","","select","",0,"SELECT 'us,er1'","us,er1[us,er1] @ localhost []","localhost","","","test" -+"Quit","","","",0,"us,er1","us,er1","","","localhost","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%'","root[root] @ localhost []","localhost","","","test" -+"Connect","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+"Query","","","select","",0,"SELECT 'user1'","user1[user1] @ localhost [127.0.0.1]","localhost","","127.0.0.1","test" -+"Quit","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+"Connect","","","",0,"user22","user22","","","localhost","","test" -+"Query","","","select","",0,"SELECT 'user22'","user22[user22] @ localhost []","localhost","","","test" -+"Quit","","","",0,"user22","user22","","","localhost","","test" -+"Connect","","","",0,"22user","22user","","","localhost","","test" -+"Query","","","select","",0,"SELECT '22user'","22user[22user] @ localhost []","localhost","","","test" -+"Change user","","","",0,"user22","user22","","","localhost","","" -+"Query","","","select","",0,"SELECT 'user22'","user22[user22] @ localhost []","localhost","","","" -+"Quit","","","",0,"user22","user22","","","localhost","","" -+"Connect","","","",0,"us,er1","us,er1","","","localhost","","test" -+"Query","","","select","",0,"SELECT 'us,er1'","us,er1[us,er1] @ localhost []","localhost","","","test" -+"Quit","","","",0,"us,er1","us,er1","","","localhost","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_exclude_accounts= NULL","root[root] @ localhost []","localhost","","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_accounts= '22user@LocalHost,User22@%'","root[root] @ localhost []","localhost","","","test" -+"Connect","","","",0,"22user","22user","","","localhost","","test" -+"Query","","","select","",0,"SELECT '22user'","22user[22user] @ localhost []","localhost","","","test" -+************************************************************* -+"Query","","","set_option","",0,"SET GLOBAL audit_log_include_accounts= NULL","root[root] @ localhost []","localhost","","","test" -+=================================================================== -+DROP USER 'user1'@'127.0.0.1'; -+DROP USER 'user22'@'%'; -+DROP USER '22user'@'localhost'; -+DROP USER 'admin'@'%'; -+DROP USER 'us,er1'@'localhost'; -diff --git a/plugin/audit_log/tests/mtr/audit_log_filter_users.test b/plugin/audit_log/tests/mtr/audit_log_filter_users.test -new file mode 100644 -index 00000000000..f8b915c76a9 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_filter_users.test -@@ -0,0 +1,86 @@ -+# setup some user accounts -+ -+CREATE USER 'user1'@'127.0.0.1' IDENTIFIED BY 'password1'; -+CREATE USER 'user22'@'%' IDENTIFIED BY 'password1'; -+CREATE USER '22user'@'LOCALHOST' IDENTIFIED BY 'password1'; -+CREATE USER 'admin'@'%' IDENTIFIED BY 'password1'; -+CREATE USER 'us,er1'@'localhost' IDENTIFIED BY 'password1'; -+ -+# test set/unset filters -+ -+SET GLOBAL audit_log_include_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_accounts= '22useer@localhost'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+SET GLOBAL audit_log_include_accounts= 'user1@localhost, user2@localhost, user3@localhost'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+SET GLOBAL audit_log_include_accounts= ''; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_exclude_accounts= '22useer@localhost'; -+SET GLOBAL audit_log_include_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+ -+SET GLOBAL audit_log_exclude_accounts= "'us,er1'@'localhost',, user22@127.0.0.1,admin@%"; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_accounts= '22useer@localhost'; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+SET GLOBAL audit_log_exclude_accounts= 'user1@localhost, user2@localhost, user3@localhost'; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+SET GLOBAL audit_log_exclude_accounts= ''; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+--error ER_WRONG_VALUE_FOR_VAR -+SET GLOBAL audit_log_include_accounts= '22useer@localhost'; -+SET GLOBAL audit_log_exclude_accounts= NULL; -+SELECT @@audit_log_include_accounts, @@audit_log_exclude_accounts; -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+ -+# log nothing -+SET GLOBAL audit_log_include_accounts= ''; -+ -+--source audit_log_filter_events.inc -+ -+# testing include -+SET GLOBAL audit_log_include_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%,veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooongusername@veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooonghostname'; -+ -+--source audit_log_filter_events.inc -+ -+# log everything -+SET GLOBAL audit_log_include_accounts= NULL; -+ -+--source audit_log_filter_events.inc -+ -+# testing exclude -+SET GLOBAL audit_log_exclude_accounts= 'user1@localhost,, user22@127.0.0.1,admin@%'; -+ -+--source audit_log_filter_events.inc -+ -+SET GLOBAL audit_log_exclude_accounts= NULL; -+ -+# testing case sensitivity -+SET GLOBAL audit_log_include_accounts= '22user@LocalHost,User22@%'; -+ -+--source audit_log_filter_events.inc -+ -+SET GLOBAL audit_log_include_accounts= NULL; -+ -+--source audit_log_echo.inc -+ -+# cleanup users -+DROP USER 'user1'@'127.0.0.1'; -+DROP USER 'user22'@'%'; -+DROP USER '22user'@'localhost'; -+DROP USER 'admin'@'%'; -+DROP USER 'us,er1'@'localhost'; -diff --git a/plugin/audit_log/tests/mtr/audit_log_install_bug1435606-master.opt b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606-master.opt -new file mode 100644 -index 00000000000..af01e3de44d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606-master.opt -@@ -0,0 +1 @@ -+--audit_log_file=/path/does/not/exist/audit.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.result b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.result -new file mode 100644 -index 00000000000..773641dd159 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.result -@@ -0,0 +1,7 @@ -+call mtr.add_suppression("Plugin 'audit_log' init function returned error"); -+call mtr.add_suppression("Plugin 'audit_log' registration as a AUDIT failed"); -+call mtr.add_suppression("Plugin audit_log reported: 'Cannot open file"); -+call mtr.add_suppression("Plugin audit_log reported: 'Error: No such file or directory'"); -+SELECT COUNT(*) AS should_be_0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'audit_log'; -+should_be_0 -+0 -diff --git a/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.test b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.test -new file mode 100644 -index 00000000000..2d205893c18 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_install_bug1435606.test -@@ -0,0 +1,9 @@ -+# Bug1435606: server crashes if audit log plugin cannot create file -+ -+call mtr.add_suppression("Plugin 'audit_log' init function returned error"); -+call mtr.add_suppression("Plugin 'audit_log' registration as a AUDIT failed"); -+call mtr.add_suppression("Plugin audit_log reported: 'Cannot open file"); -+call mtr.add_suppression("Plugin audit_log reported: 'Error: No such file or directory'"); -+ -+# Should have failed to install -+SELECT COUNT(*) AS should_be_0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'audit_log'; -diff --git a/plugin/audit_log/tests/mtr/audit_log_json-master.opt b/plugin/audit_log/tests/mtr/audit_log_json-master.opt -new file mode 100644 -index 00000000000..0e988b238f8 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_json-master.opt -@@ -0,0 +1,3 @@ -+--audit_log_file=test_audit.log -+--audit-log-format=JSON -+--audit_log_strategy=SEMISYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_json.result b/plugin/audit_log/tests/mtr/audit_log_json.result -new file mode 100644 -index 00000000000..5a5c1002250 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_json.result -@@ -0,0 +1,170 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+CREATE TABLE t1 -+(c1 INT, -+c2 CHAR(20)); -+ERROR 42S01: Table 't1' already exists -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+INSERT INTO `t1` VALUES (4,NULL); -+INSERT INTO `t1` VALUES (6,''); -+INSERT INTO `t1` VALUES (7,''); -+INSERT INTO `t1` VALUES (8,''); -+INSERT INTO `t1` VALUES (9,''); -+INSERT INTO `t1` VALUES (10,''); -+INSERT INTO `t1` VALUES (11,''); -+INSERT INTO `t1` VALUES (12,''); -+INSERT INTO `t1` VALUES (13,''); -+INSERT INTO `t1` VALUES (14,' '); -+INSERT INTO `t1` VALUES (15,' -+'); -+INSERT INTO `t1` VALUES (16,' '); -+INSERT INTO `t1` VALUES (17,' '); -+INSERT INTO `t1` VALUES (18,' '); -+INSERT INTO `t1` VALUES (19,''); -+INSERT INTO `t1` VALUES (20,''); -+INSERT INTO `t1` VALUES (21,''); -+INSERT INTO `t1` VALUES (22,''); -+INSERT INTO `t1` VALUES (23,''); -+INSERT INTO `t1` VALUES (24,''); -+INSERT INTO `t1` VALUES (25,''); -+INSERT INTO `t1` VALUES (26,''); -+INSERT INTO `t1` VALUES (27,''); -+INSERT INTO `t1` VALUES (28,''); -+INSERT INTO `t1` VALUES (29,''); -+INSERT INTO `t1` VALUES (30,''); -+INSERT INTO `t1` VALUES (31,''); -+INSERT INTO `t1` VALUES (32,''); -+INSERT INTO `t1` VALUES (33,''); -+INSERT INTO `t1` VALUES (34,''); -+INSERT INTO `t1` VALUES (35,''); -+INSERT INTO `t1` VALUES (36,''); -+SELECT * FROM t1; -+c1 c2 -+1 a -+2 b -+3 c -+4 NULL -+6  -+7  -+8  -+9  -+10  -+11  -+12  -+13  -+14 -+15 -+ -+16 -+17 -+18 -+19  -+20  -+21  -+22  -+23  -+24  -+25  -+26  -+27  -+28  -+29  -+30  -+31  -+32  -+33  -+34  -+35  -+36  -+SELECT * FROM t2; -+ERROR 42S02: Table 'test.t2' doesn't exist -+DROP TABLE t1; -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+1 -+1 -+SHOW STATUS LIKE 'audit_log%'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+DEALLOCATE PREPARE stmt1; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format JSON -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); -+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+id -+1 -+2 -+alter table t1 rename renamed_t1; -+select * from t_doesnt_exist; -+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist -+syntax_error_query; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1 -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format JSON -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+create database sa_db; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+id2 -+1 -+2 -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+create user 'jeffrey'@'localhost' IDENTIFIED BY 'mypass'; -+drop user 'jeffrey'@'localhost'; -+select '&;&&&""""<><<>>>>'; -+&;&&&""""<><<>>>> -+&;&&&""""<><<>>>> -+select '  -+ /"\\'; -+/"\ -+  -+ /"\ -+set global audit_log_flush= ON; -diff --git a/plugin/audit_log/tests/mtr/audit_log_json.test b/plugin/audit_log/tests/mtr/audit_log_json.test -new file mode 100644 -index 00000000000..f1760f22a14 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_json.test -@@ -0,0 +1,45 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+--let $test_control_chars=1; -+--source audit_log_events.inc -+ -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_json.log -+set global audit_log_flush= ON; -+perl; -+ eval "use JSON qw(decode_json); 1" or exit 0; -+ open my $file, $ENV{'MYSQLD_DATADIR'} . '/test_audit_json.log' or die "Could not open log: $!"; -+ my $found_1st_control_char = 0; -+ my $last_control_char = 0; -+ my $control_char_count = 0; -+ while (my $line = <$file>) { -+ my $json = decode_json($line); -+ my $entry_type = $json->{audit_record}->{name}; -+ if($entry_type eq "Query") { -+ my $query = $json->{audit_record}->{sqltext}; -+ my @query_chars = sort($query =~ /./sg); -+ my $minimum_character = ord($query_chars[0]); -+ if ($minimum_character == 1) { -+ $found_1st_control_char = 1; -+ } -+ if ($found_1st_control_char && $control_char_count < 31) { -+ $control_char_count = $control_char_count + 1; -+ my $expected = $last_control_char + 1; -+ if ($expected != $minimum_character) { -+ print "Incorrect control character in output: Expected $expected, got $minimum_character\n"; -+ exit l; -+ } -+ $last_control_char = $minimum_character; -+ } -+ } -+ } -+ if ($control_char_count != 31) { -+ print "Missing control characters from the output. Expected 31, got $control_char_count\n"; -+ exit 2; -+ } -+ close $file; -+EOF -diff --git a/plugin/audit_log/tests/mtr/audit_log_long_records-master.opt b/plugin/audit_log/tests/mtr/audit_log_long_records-master.opt -new file mode 100644 -index 00000000000..1a976d9f607 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_long_records-master.opt -@@ -0,0 +1,4 @@ -+--audit_log_file=test_audit.log -+--audit_log_buffer_size=8192 -+--audit_log_strategy=ASYNCHRONOUS -+--audit_log_format=OLD -diff --git a/plugin/audit_log/tests/mtr/audit_log_long_records.result b/plugin/audit_log/tests/mtr/audit_log_long_records.result -new file mode 100644 -index 00000000000..62cad62a652 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_long_records.result -@@ -0,0 +1,3 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush= ON; -diff --git a/plugin/audit_log/tests/mtr/audit_log_long_records.test b/plugin/audit_log/tests/mtr/audit_log_long_records.test -new file mode 100644 -index 00000000000..220cd7d4495 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_long_records.test -@@ -0,0 +1,40 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+let $i= 2; -+let $xx= xx; -+while ($i < 3500) -+{ -+let $xx= x$xx; -+inc $i; -+} -+--disable_query_log -+--disable_result_log -+while ($i < 8500) -+{ -+eval SELECT '$xx'; -+let $xx= x$xx; -+inc $i; -+} -+while ($i < 9000) -+{ -+eval SELECT '$xx'; -+let $xx= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx$xx; -+inc $i; -+} -+--enable_query_log -+--enable_result_log -+ -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_long.log -+SET GLOBAL audit_log_flush= ON; -+perl; -+ eval "use XML::Parser; 1" or exit 0; -+ $p = new XML::Parser; -+ $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_long.log'); -+EOF -+--remove_file $MYSQLD_DATADIR/test_audit.log -+--remove_file $MYSQLD_DATADIR/test_audit_long.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_many_connections.result b/plugin/audit_log/tests/mtr/audit_log_many_connections.result -new file mode 100644 -index 00000000000..395d3a6bffa ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_many_connections.result -@@ -0,0 +1,7 @@ -+SET @saved_max_connections = @@global.max_connections; -+SET GLOBAL max_connections = 2; -+connect(localhost,root,,test,MYSQL_PORT,MYSQL_SOCK); -+ERROR HY000: Too many connections -+connect(localhost,root,,test,MYSQL_PORT,MYSQL_SOCK); -+ERROR HY000: Too many connections -+SET GLOBAL max_connections= @saved_max_connections; -diff --git a/plugin/audit_log/tests/mtr/audit_log_many_connections.test b/plugin/audit_log/tests/mtr/audit_log_many_connections.test -new file mode 100644 -index 00000000000..8fcd7350e2b ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_many_connections.test -@@ -0,0 +1,31 @@ -+# -+# Bug #1633988: Assertion `thd == _current_thd()' failed -+# -+# Test audit log handling of too many connections error -+# -+ -+--disable_query_log -+call mtr.add_suppression("Too many connections"); -+--enable_query_log -+ -+--source include/count_sessions.inc -+ -+SET @saved_max_connections = @@global.max_connections; -+SET GLOBAL max_connections = 2; -+ -+--connect (con1, localhost, root) -+--connect (con2, localhost, root) -+--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -+--error ER_CON_COUNT_ERROR -+--connect (con3, localhost, root) -+--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -+--error ER_CON_COUNT_ERROR -+--connect (con4, localhost, root) -+ -+connection default; -+SET GLOBAL max_connections= @saved_max_connections; -+ -+--disconnect con2 -+--disconnect con1 -+ -+--source include/wait_until_count_sessions.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_memory_consumption-master.opt b/plugin/audit_log/tests/mtr/audit_log_memory_consumption-master.opt -new file mode 100644 -index 00000000000..81851bec7cf ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_memory_consumption-master.opt -@@ -0,0 +1,4 @@ -+$AUDIT_LOG_OPT -+$AUDIT_LOG_LOAD -+--audit_log_file=test_audit.log -+--max-allowed-packet=1G -diff --git a/plugin/audit_log/tests/mtr/audit_log_memory_consumption.result b/plugin/audit_log/tests/mtr/audit_log_memory_consumption.result -new file mode 100644 -index 00000000000..e5bfad924bd ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_memory_consumption.result -@@ -0,0 +1,3 @@ -+SET GLOBAL audit_log_flush=ON; -+include/assert.inc [Memory usage is less than 100M] -+DROP TABLE test; -diff --git a/plugin/audit_log/tests/mtr/audit_log_memory_consumption.test b/plugin/audit_log/tests/mtr/audit_log_memory_consumption.test -new file mode 100644 -index 00000000000..7cf2feee7ba ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_memory_consumption.test -@@ -0,0 +1,20 @@ -+--let $MYSQLD_DATADIR= `SELECT @@datadir` -+--let $log_file=$MYSQLD_DATADIR/test_audit.log -+ -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+--disable_query_log -+--disable_result_log -+UPDATE performance_schema.setup_instruments -+SET ENABLED = 'YES' -+WHERE NAME LIKE 'memory/%'; -+CREATE TABLE test (col1 LONGBLOB NOT NULL); -+# 10M query -+--let $very_long_text=`SELECT REPEAT('a', 10485760)` -+eval INSERT INTO test (col1) VALUES ('$very_long_text'); -+--enable_query_log -+--enable_result_log -+--let $assert_text = Memory usage is less than 100M -+--let $assert_cond= "[SELECT current_alloc FROM sys.memory_global_by_current_bytes WHERE event_name = \'memory/sql/THD::variables\']" <= 100 -+--source include/assert.inc -+DROP TABLE test; -diff --git a/plugin/audit_log/tests/mtr/audit_log_new-master.opt b/plugin/audit_log/tests/mtr/audit_log_new-master.opt -new file mode 100644 -index 00000000000..d4fdcdc4194 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_new-master.opt -@@ -0,0 +1,4 @@ -+--audit_log_file=test_audit.log -+--audit_log_policy=LOGINS -+--audit-log-format=NEW -+--audit_log_strategy=SEMISYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_new.result b/plugin/audit_log/tests/mtr/audit_log_new.result -new file mode 100644 -index 00000000000..ceb921cf3c6 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_new.result -@@ -0,0 +1,97 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+CREATE TABLE t1 -+(c1 INT, -+c2 CHAR(20)); -+ERROR 42S01: Table 't1' already exists -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+SELECT * FROM t1; -+c1 c2 -+1 a -+2 b -+3 c -+SELECT * FROM t2; -+ERROR 42S02: Table 'test.t2' doesn't exist -+DROP TABLE t1; -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+1 -+1 -+SHOW STATUS LIKE 'audit_log%'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+DEALLOCATE PREPARE stmt1; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format NEW -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy LOGINS -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); -+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+id -+1 -+2 -+alter table t1 rename renamed_t1; -+select * from t_doesnt_exist; -+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist -+syntax_error_query; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1 -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format NEW -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy LOGINS -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy SEMISYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+create database sa_db; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+id2 -+1 -+2 -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+select '&;&&&""""<><<>>>>'; -+&;&&&""""<><<>>>> -+&;&&&""""<><<>>>> -+set global audit_log_flush= ON; -diff --git a/plugin/audit_log/tests/mtr/audit_log_new.test b/plugin/audit_log/tests/mtr/audit_log_new.test -new file mode 100644 -index 00000000000..fafd6881f2d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_new.test -@@ -0,0 +1,18 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_events.inc -+ -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log -+set global audit_log_flush= ON; -+perl; -+ eval "use XML::Parser; 1" or exit 0; -+ $p = new XML::Parser; -+ $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_new.log'); -+EOF -+--remove_file $MYSQLD_DATADIR/test_audit.log -+--remove_file $MYSQLD_DATADIR/test_audit_new.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_old-master.opt b/plugin/audit_log/tests/mtr/audit_log_old-master.opt -new file mode 100644 -index 00000000000..2524574eb92 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_old-master.opt -@@ -0,0 +1,3 @@ -+--audit_log_file=test_audit.log -+--audit_log_buffer_size=4096 -+--audit_log_strategy=ASYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_old.result b/plugin/audit_log/tests/mtr/audit_log_old.result -new file mode 100644 -index 00000000000..539b5f49ae6 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_old.result -@@ -0,0 +1,97 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+CREATE TABLE t1 -+(c1 INT, -+c2 CHAR(20)); -+ERROR 42S01: Table 't1' already exists -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+SELECT * FROM t1; -+c1 c2 -+1 a -+2 b -+3 c -+SELECT * FROM t2; -+ERROR 42S02: Table 'test.t2' doesn't exist -+DROP TABLE t1; -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+1 -+1 -+SHOW STATUS LIKE 'audit_log%'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+DEALLOCATE PREPARE stmt1; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 4096 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format OLD -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy ASYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); -+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+id -+1 -+2 -+alter table t1 rename renamed_t1; -+select * from t_doesnt_exist; -+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist -+syntax_error_query; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1 -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 4096 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file test_audit.log -+audit_log_flush OFF -+audit_log_format OLD -+audit_log_handler FILE -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy ASYNCHRONOUS -+audit_log_syslog_facility LOG_USER -+audit_log_syslog_ident percona-audit -+audit_log_syslog_priority LOG_INFO -+create database sa_db; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+id2 -+1 -+2 -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+select '&;&&&""""<><<>>>>'; -+&;&&&""""<><<>>>> -+&;&&&""""<><<>>>> -+set global audit_log_flush= ON; -diff --git a/plugin/audit_log/tests/mtr/audit_log_old.test b/plugin/audit_log/tests/mtr/audit_log_old.test -new file mode 100644 -index 00000000000..ad312e99e59 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_old.test -@@ -0,0 +1,18 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_events.inc -+ -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_old.log -+set global audit_log_flush= ON; -+perl; -+ eval "use XML::Parser; 1" or exit 0; -+ $p = new XML::Parser; -+ $p->parsefile($ENV{'MYSQLD_DATADIR'} . '/test_audit_old.log'); -+EOF -+# --remove_file $MYSQLD_DATADIR/test_audit.log -+# --remove_file $MYSQLD_DATADIR/test_audit_old.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate-master.opt b/plugin/audit_log/tests/mtr/audit_log_rotate-master.opt -new file mode 100644 -index 00000000000..36b97341b9e ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate-master.opt -@@ -0,0 +1,6 @@ -+--audit_log_file=test_audit.log -+--audit_log_format=JSON -+--audit_log_strategy=SEMISYNCHRONOUS -+--audit_log_rotate_on_size=4096 -+--audit_log_buffer_size=5000 -+--audit_log_rotations=10 -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate.result b/plugin/audit_log/tests/mtr/audit_log_rotate.result -new file mode 100644 -index 00000000000..c66c32f360e ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate.result -@@ -0,0 +1,14 @@ -+# -+# Rotate with "rotations" and "size" given as startup options -+# -+success -+# -+# PS-4950: Invalid audit log file size when audit_log_rotations is changed during runtime -+# -+SET @audit_log_rotations_orig = @@audit_log_rotations; -+SET @audit_log_rotate_on_size_orig = @@audit_log_rotate_on_size; -+SET GLOBAL audit_log_rotations = 3; -+SET GLOBAL audit_log_rotate_on_size = 4096; -+SET GLOBAL audit_log_rotations = @audit_log_rotations_orig; -+SET GLOBAL audit_log_rotate_on_size = @audit_log_rotate_on_size_orig; -+success -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate.test b/plugin/audit_log/tests/mtr/audit_log_rotate.test -new file mode 100644 -index 00000000000..c8bc53e9a1d ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate.test -@@ -0,0 +1,67 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+--echo # -+--echo # Rotate with "rotations" and "size" given as startup options -+--echo # -+ -+--disable_result_log -+--disable_query_log -+--source audit_log_events.inc -+--source audit_log_events.inc -+--source audit_log_events.inc -+--source audit_log_events.inc -+--enable_query_log -+--enable_result_log -+ -+perl; -+ eval "use JSON qw(decode_json); 1" or exit 0; -+ my @files = glob ($ENV{'MYSQLD_DATADIR'} . "/test_audit.log.[0-9][0-9]"); -+ foreach (@files) { -+ open my $file, $_ or die "Could not open log: $!"; -+ while (my $line = <$file>) { -+ decode_json($line); -+ } -+ close $file; -+ } -+ die "Rotation doesn't work!" unless scalar(@files) > 1 -+EOF -+ -+--echo success -+ -+--echo # -+--echo # PS-4950: Invalid audit log file size when audit_log_rotations is changed during runtime -+--echo # -+ -+SET @audit_log_rotations_orig = @@audit_log_rotations; -+SET @audit_log_rotate_on_size_orig = @@audit_log_rotate_on_size; -+SET GLOBAL audit_log_rotations = 3; -+SET GLOBAL audit_log_rotate_on_size = 4096; -+ -+--remove_files_wildcard $MYSQLD_DATADIR test_audit.log.* -+ -+--disable_result_log -+--disable_query_log -+--source audit_log_events.inc -+--source audit_log_events.inc -+--source audit_log_events.inc -+--source audit_log_events.inc -+--enable_query_log -+--enable_result_log -+ -+perl; -+ my @files = glob ($ENV{'MYSQLD_DATADIR'} . "/test_audit.log.[0-9][0-9]"); -+ foreach (@files) { -+ my $size = -s $_; -+ print $_; -+ die "Files are too small!" unless $size >= 4096; -+ } -+ die "Too many rotations!" unless scalar(@files) <= 3; -+EOF -+ -+SET GLOBAL audit_log_rotations = @audit_log_rotations_orig; -+SET GLOBAL audit_log_rotate_on_size = @audit_log_rotate_on_size_orig; -+ -+--remove_files_wildcard $MYSQLD_DATADIR test_audit.log* -+ -+--echo success -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush-master.opt b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush-master.opt -new file mode 100644 -index 00000000000..6e65700f11b ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush-master.opt -@@ -0,0 +1,5 @@ -+--audit_log_file=test_audit.log -+--audit_log_format=JSON -+--audit_log_strategy=SEMISYNCHRONOUS -+--audit_log_rotate_on_size=4096 -+--audit_log_rotations=1 -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.result b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.result -new file mode 100644 -index 00000000000..606d202dede ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.result -@@ -0,0 +1,5 @@ -+# -+# PS-1098: 'SET GLOBAL audit_log_flush=1' reopens wrong file after auto rotation -+# -+SET GLOBAL audit_log_flush=1; -+success -diff --git a/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.test b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.test -new file mode 100644 -index 00000000000..5680e559e53 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_rotate_with_flush.test -@@ -0,0 +1,25 @@ -+--echo # -+--echo # PS-1098: 'SET GLOBAL audit_log_flush=1' reopens wrong file after auto rotation -+--echo # -+ -+--disable_result_log -+--disable_query_log -+--source audit_log_events.inc -+--enable_query_log -+--enable_result_log -+ -+SET GLOBAL audit_log_flush=1; -+ -+let MYSQLD_DATADIR= `select @@datadir`; -+ -+perl; -+ my $current_log_size = -s $ENV{'MYSQLD_DATADIR'} . "/test_audit.log"; -+ my $rotated_log_size = -s $ENV{'MYSQLD_DATADIR'} . "/test_audit.log.1"; -+ -+ die "Current log file rewritten!" if ($current_log_size == 0); -+ die "Already rotated file reopened!" if ($rotated_log_size < 4096); -+EOF -+ -+--remove_files_wildcard $MYSQLD_DATADIR test_audit.log* -+ -+--echo success -diff --git a/plugin/audit_log/tests/mtr/audit_log_startup.result b/plugin/audit_log/tests/mtr/audit_log_startup.result -new file mode 100644 -index 00000000000..c49a551253e ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_startup.result -@@ -0,0 +1,29 @@ -+call mtr.add_suppression("Plugin 'audit_log' init function returned error."); -+call mtr.add_suppression("Plugin 'audit_log' registration as a AUDIT failed."); -+call mtr.add_suppression("Plugin audit_log reported: 'Both"); -+call mtr.add_suppression("Plugin audit_log reported: 'Cannot open file"); -+call mtr.add_suppression("Plugin audit_log reported: 'Error: No such file or directory'"); -+# restart: --audit_log_exclude_accounts=user@localhost -+SET GLOBAL audit_log_exclude_accounts='info@localhost'; -+# restart: --audit_log_include_accounts=user@localhost -+SET GLOBAL audit_log_include_accounts='info@localhost'; -+# restart: --audit_log_exclude_commands=alter_table -+SET GLOBAL audit_log_exclude_commands='insert'; -+# restart: --audit_log_include_commands=alter_table -+SET GLOBAL audit_log_include_commands='insert'; -+# restart: --audit_log_exclude_databases=test -+SET GLOBAL audit_log_exclude_databases='mysql'; -+# restart: --audit_log_include_databases=test -+SET GLOBAL audit_log_include_databases='mysql'; -+# restart: --audit_log_exclude_accounts=user@localhost --audit_log_include_accounts=user@localhost -+SHOW VARIABLES LIKE 'audit_log%'; -+Variable_name Value -+# restart: --audit_log_exclude_commands=delete --audit_log_include_commands=delete -+SHOW VARIABLES LIKE 'audit_log%'; -+Variable_name Value -+# restart: --audit_log_exclude_databases=test --audit_log_include_databases=test -+SHOW VARIABLES LIKE 'audit_log%'; -+Variable_name Value -+# restart: --audit_log_exclude_accounts=user@localhost --audit_log_file=./directory/file -+SHOW VARIABLES LIKE 'audit_log%'; -+Variable_name Value -diff --git a/plugin/audit_log/tests/mtr/audit_log_startup.test b/plugin/audit_log/tests/mtr/audit_log_startup.test -new file mode 100644 -index 00000000000..f11302b23a5 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_startup.test -@@ -0,0 +1,70 @@ -+# Bug 1641910: Trying to set audit_log_exclude_accounts crashes server. -+ -+call mtr.add_suppression("Plugin 'audit_log' init function returned error."); -+call mtr.add_suppression("Plugin 'audit_log' registration as a AUDIT failed."); -+call mtr.add_suppression("Plugin audit_log reported: 'Both"); -+call mtr.add_suppression("Plugin audit_log reported: 'Cannot open file"); -+call mtr.add_suppression("Plugin audit_log reported: 'Error: No such file or directory'"); -+ -+--let $restart_parameters="restart: --audit_log_exclude_accounts='user@localhost'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_exclude_accounts='info@localhost'; -+ -+ -+--let $restart_parameters="restart: --audit_log_include_accounts='user@localhost'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_include_accounts='info@localhost'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_commands='alter_table'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_exclude_commands='insert'; -+ -+ -+--let $restart_parameters="restart: --audit_log_include_commands='alter_table'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_include_commands='insert'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_databases='test'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_exclude_databases='mysql'; -+ -+ -+--let $restart_parameters="restart: --audit_log_include_databases='test'" -+--source include/restart_mysqld.inc -+ -+SET GLOBAL audit_log_include_databases='mysql'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_accounts='user@localhost' --audit_log_include_accounts='user@localhost'" -+--source include/restart_mysqld.inc -+ -+# there should be no audit_log% variables shown -+SHOW VARIABLES LIKE 'audit_log%'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_commands='delete' --audit_log_include_commands='delete'" -+--source include/restart_mysqld.inc -+ -+# there should be no audit_log% variables shown -+SHOW VARIABLES LIKE 'audit_log%'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_databases='test' --audit_log_include_databases='test'" -+--source include/restart_mysqld.inc -+ -+# there should be no audit_log% variables shown -+SHOW VARIABLES LIKE 'audit_log%'; -+ -+ -+--let $restart_parameters="restart: --audit_log_exclude_accounts='user@localhost' --audit_log_file=./directory/file" -+--source include/restart_mysqld.inc -+ -+# there should be no audit_log% variables shown -+SHOW VARIABLES LIKE 'audit_log%'; -diff --git a/plugin/audit_log/tests/mtr/audit_log_syslog-master.opt b/plugin/audit_log/tests/mtr/audit_log_syslog-master.opt -new file mode 100644 -index 00000000000..eb692e1c268 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_syslog-master.opt -@@ -0,0 +1,5 @@ -+--audit-log-format=CSV -+--audit_log_handler=SYSLOG -+--audit_log_syslog_ident=test_audit -+--audit_log_syslog_facility=LOG_AUTH -+--audit_log_syslog_priority=LOG_INFO -diff --git a/plugin/audit_log/tests/mtr/audit_log_syslog.result b/plugin/audit_log/tests/mtr/audit_log_syslog.result -new file mode 100644 -index 00000000000..ce98ce44f01 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_syslog.result -@@ -0,0 +1,94 @@ -+CREATE TABLE t1 (c1 INT, c2 CHAR(20)); -+CREATE TABLE t1 -+(c1 INT, -+c2 CHAR(20)); -+ERROR 42S01: Table 't1' already exists -+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); -+SELECT * FROM t1; -+c1 c2 -+1 a -+2 b -+3 c -+SELECT * FROM t2; -+ERROR 42S02: Table 'test.t2' doesn't exist -+DROP TABLE t1; -+PREPARE stmt1 FROM 'SELECT 1'; -+EXECUTE stmt1; -+1 -+1 -+SHOW STATUS LIKE 'audit_log%'; -+Variable_name Value -+Audit_log_buffer_size_overflow 0 -+DEALLOCATE PREPARE stmt1; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file audit.log -+audit_log_flush OFF -+audit_log_format CSV -+audit_log_handler SYSLOG -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy ASYNCHRONOUS -+audit_log_syslog_facility LOG_AUTH -+audit_log_syslog_ident test_audit -+audit_log_syslog_priority LOG_INFO -+connect(localhost,no_such_user,,mysql,MASTER_PORT,MASTER_SOCKET); -+ERROR 28000: Access denied for user 'no_such_user'@'localhost' (using password: NO) -+create table t1 (id int); -+create table t2 (id int); -+insert into t1 values (1), (2); -+insert into t2 values (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2), (1), (2); -+select * from t1; -+id -+1 -+2 -+alter table t1 rename renamed_t1; -+select * from t_doesnt_exist; -+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist -+syntax_error_query; -+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax_error_query' at line 1 -+drop table renamed_t1, t2; -+show variables like 'audit_log%'; -+Variable_name Value -+audit_log_buffer_size 1048576 -+audit_log_exclude_accounts -+audit_log_exclude_commands -+audit_log_exclude_databases -+audit_log_file audit.log -+audit_log_flush OFF -+audit_log_format CSV -+audit_log_handler SYSLOG -+audit_log_include_accounts -+audit_log_include_commands -+audit_log_include_databases -+audit_log_policy ALL -+audit_log_rotate_on_size 0 -+audit_log_rotations 0 -+audit_log_strategy ASYNCHRONOUS -+audit_log_syslog_facility LOG_AUTH -+audit_log_syslog_ident test_audit -+audit_log_syslog_priority LOG_INFO -+create database sa_db; -+create table t1 (id2 int); -+insert into t1 values (1), (2); -+select * from t1; -+id2 -+1 -+2 -+drop table t1; -+use sa_db; -+create table sa_t1(id int); -+insert into sa_t1 values (1), (2); -+drop table sa_t1; -+drop database sa_db; -+select '&;&&&""""<><<>>>>'; -+&;&&&""""<><<>>>> -+&;&&&""""<><<>>>> -diff --git a/plugin/audit_log/tests/mtr/audit_log_syslog.test b/plugin/audit_log/tests/mtr/audit_log_syslog.test -new file mode 100644 -index 00000000000..20cded3282a ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_syslog.test -@@ -0,0 +1 @@ -+--source audit_log_events.inc -diff --git a/plugin/audit_log/tests/mtr/audit_log_threadpool-master.opt b/plugin/audit_log/tests/mtr/audit_log_threadpool-master.opt -new file mode 100644 -index 00000000000..7aae3717b96 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_threadpool-master.opt -@@ -0,0 +1,3 @@ -+--audit_log_strategy=SYNCHRONOUS -+--audit_log_file=test_audit_threadpool.log -+--thread_handling=pool-of-threads -diff --git a/plugin/audit_log/tests/mtr/audit_log_threadpool.result b/plugin/audit_log/tests/mtr/audit_log_threadpool.result -new file mode 100644 -index 00000000000..f78eb60b346 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_threadpool.result -@@ -0,0 +1,10 @@ -+set global audit_log_flush= ON; -+set global audit_log_flush= ON; -+select 1; -+1 -+1 -+select '1more'; -+1more -+1more -+set global audit_log_flush= ON; -+1 connects, 2 disconnects -diff --git a/plugin/audit_log/tests/mtr/audit_log_threadpool.test b/plugin/audit_log/tests/mtr/audit_log_threadpool.test -new file mode 100644 -index 00000000000..2f3c4faae70 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_threadpool.test -@@ -0,0 +1,38 @@ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let MYSQLD_DATADIR= $MYSQLD_DATADIR; -+ -+set global audit_log_flush= ON; -+--remove_file $MYSQLD_DATADIR/test_audit_threadpool.log -+set global audit_log_flush= ON; -+ -+--source include/count_sessions.inc -+connect (con1,localhost,root,,mysql); -+select 1; -+connection default; -+disconnect con1; -+--source include/wait_until_count_sessions.inc -+ -+connection default; -+select '1more'; -+ -+--move_file $MYSQLD_DATADIR/test_audit_threadpool.log $MYSQLD_DATADIR/test_audit_threadpool_done.log -+set global audit_log_flush= ON; -+ -+perl; -+ use strict; -+ use warnings; -+ -+ my $logfile = $ENV{'MYSQLD_DATADIR'} . '/test_audit_threadpool_done.log'; -+ -+ open(FILE, $logfile) or die "cannot open $logfile!"; -+ my @buf = ; -+ close(FILE); -+ -+ my $connect_count = grep(/Connect/, @buf); -+ my $disconnect_count = grep(/Quit/, @buf); -+ -+ print "$connect_count connects, $disconnect_count disconnects\n"; -+EOF -+ -+--remove_file $MYSQLD_DATADIR/test_audit_threadpool.log -+--remove_file $MYSQLD_DATADIR/test_audit_threadpool_done.log -diff --git a/plugin/audit_log/tests/mtr/audit_log_xml_escape-master.opt b/plugin/audit_log/tests/mtr/audit_log_xml_escape-master.opt -new file mode 100644 -index 00000000000..5db58a723e3 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_xml_escape-master.opt -@@ -0,0 +1,4 @@ -+--audit_log_file=test_audit.log -+--audit_log_policy=QUERIES -+--audit-log-format=NEW -+--audit_log_strategy=SEMISYNCHRONOUS -diff --git a/plugin/audit_log/tests/mtr/audit_log_xml_escape.result b/plugin/audit_log/tests/mtr/audit_log_xml_escape.result -new file mode 100644 -index 00000000000..868241b4a39 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_xml_escape.result -@@ -0,0 +1,10 @@ -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+CREATE TABLE a (id int) ENGINE = InnoDB; -+INSERT INTO a -+VALUES (1); -+INSERT INTO a VALUES (2); -+INSERT INTO a VALUES (3); -+set global audit_log_flush= ON; -+Escape rules Ok -+DROP TABLE a; -diff --git a/plugin/audit_log/tests/mtr/audit_log_xml_escape.test b/plugin/audit_log/tests/mtr/audit_log_xml_escape.test -new file mode 100644 -index 00000000000..d1a115611ea ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/audit_log_xml_escape.test -@@ -0,0 +1,62 @@ -+--let $MYSQL_TMP_DIR = `select @@tmpdir` -+--let $MYSQLD_DATADIR = `select @@datadir` -+--let $TMP_QUERY_FILE = $MYSQL_TMP_DIR/tmp_query -+ -+--let MYSQLD_DATADIR = $MYSQLD_DATADIR -+--let TMP_QUERY_FILE = $TMP_QUERY_FILE -+ -+--perl -+ use strict; -+ use warnings; -+ -+ my $query_file = $ENV{'TMP_QUERY_FILE'} or die "TMP_QUERY_FILE not set"; -+ open(my $fh, ">", $query_file) or die "Can't open < $query_file: $!"; -+ -+ print $fh "CREATE TABLE a (id int) ENGINE = InnoDB;\n"; -+ print $fh "INSERT INTO a \nVALUES (1);\n"; -+ print $fh "INSERT INTO a \tVALUES (2);\n"; -+ print $fh "INSERT INTO a \rVALUES (3);\n"; -+ -+ close($fh); -+EOF -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $MYSQLD_DATADIR/test_audit.log -+SET GLOBAL audit_log_flush=ON; -+ -+--source $TMP_QUERY_FILE -+--move_file $MYSQLD_DATADIR/test_audit.log $MYSQLD_DATADIR/test_audit_new.log -+set global audit_log_flush= ON; -+ -+perl; -+ use strict; -+ use warnings; -+ -+ my $log_file = "$ENV{MYSQLD_DATADIR}/test_audit_new.log"; -+ open(my $fh, "<", $log_file) or die "Can't open < $log_file: $!"; -+ -+ my $escape_seq_count = 0; -+ my $expected_escape_seq_count = 3; -+ -+ while (my $line = <$fh>) { -+ if ($line =~ m/INSERT\sINTO\sa\s VALUES\s\(1\)/ -+ || $line =~ m/INSERT\sINTO\sa\s VALUES\s\(2\)/ -+ || $line =~ m/INSERT\sINTO\sa\s VALUES\s\(3\)/) { -+ ++$escape_seq_count; -+ } -+ } -+ -+ if ($escape_seq_count == $expected_escape_seq_count) { -+ print "Escape rules Ok\n"; -+ } -+ else { -+ print "Found $escape_seq_count escape sequences, expected $expected_escape_seq_count\n"; -+ } -+ -+ close($fh); -+EOF -+ -+--remove_file $MYSQLD_DATADIR/test_audit.log -+--remove_file $MYSQLD_DATADIR/test_audit_new.log -+ -+DROP TABLE a; -diff --git a/plugin/audit_log/tests/mtr/percona_bug_ps3867.result b/plugin/audit_log/tests/mtr/percona_bug_ps3867.result -new file mode 100644 -index 00000000000..ee83ce6f8a4 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/percona_bug_ps3867.result -@@ -0,0 +1,37 @@ -+CREATE USER 'user1'@'127.0.0.1' IDENTIFIED BY 'password1'; -+CREATE USER 'user22'@'%' IDENTIFIED BY 'password1'; -+CREATE USER '22user'@'LOCALHOST' IDENTIFIED BY 'password1'; -+CREATE USER 'admin'@'%' IDENTIFIED BY 'password1'; -+CREATE USER 'us,er1'@'localhost' IDENTIFIED BY 'password1'; -+SET GLOBAL audit_log_flush=ON; -+SET GLOBAL audit_log_flush=ON; -+SELECT 'user1'; -+user1 -+user1 -+SELECT 'user22'; -+user22 -+user22 -+SELECT '22user'; -+22user -+22user -+SELECT 'user22'; -+user22 -+user22 -+SELECT 'admin'; -+admin -+admin -+SELECT 'us,er1'; -+us,er1 -+us,er1 -+SET GLOBAL audit_log_flush=ON; -+set global audit_log_flush= ON; -+=================================================================== -+"Connect","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+"Query","","","select","",0,"SELECT 'user1'","user1[user1] @ localhost [127.0.0.1]","localhost","","127.0.0.1","test" -+"Quit","","","",0,"user1","user1","","","localhost","127.0.0.1","test" -+=================================================================== -+DROP USER 'user1'@'127.0.0.1'; -+DROP USER 'user22'@'%'; -+DROP USER '22user'@'localhost'; -+DROP USER 'admin'@'%'; -+DROP USER 'us,er1'@'localhost'; -diff --git a/plugin/audit_log/tests/mtr/percona_bug_ps3867.test b/plugin/audit_log/tests/mtr/percona_bug_ps3867.test -new file mode 100644 -index 00000000000..5a9d8a2876c ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/percona_bug_ps3867.test -@@ -0,0 +1,35 @@ -+# PS-3867: audit_log_include_accunts was incorrect when set on the command line -+ -+# setup some user accounts -+ -+CREATE USER 'user1'@'127.0.0.1' IDENTIFIED BY 'password1'; -+CREATE USER 'user22'@'%' IDENTIFIED BY 'password1'; -+CREATE USER '22user'@'LOCALHOST' IDENTIFIED BY 'password1'; -+CREATE USER 'admin'@'%' IDENTIFIED BY 'password1'; -+CREATE USER 'us,er1'@'localhost' IDENTIFIED BY 'password1'; -+ -+let $MYSQLD_DATADIR= `select @@datadir`; -+let $log_file=$MYSQLD_DATADIR/test_audit.log; -+ -+ -+--disable_result_log -+--let $restart_parameters="restart: $AUDIT_LOG_OPT $AUDIT_LOG_LOAD --audit_log_include_accounts='user1@127.0.0.1' --audit_log_file=test_audit.log --audit_log_policy=ALL --audit-log-format=CSV --audit_log_strategy=SYNCHRONOUS" -+--source include/restart_mysqld.inc -+--enable_result_log -+ -+SET GLOBAL audit_log_flush=ON; -+--remove_file $log_file -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_filter_events.inc -+ -+SET GLOBAL audit_log_flush=ON; -+ -+--source audit_log_echo.inc -+ -+# cleanup users -+DROP USER 'user1'@'127.0.0.1'; -+DROP USER 'user22'@'%'; -+DROP USER '22user'@'localhost'; -+DROP USER 'admin'@'%'; -+DROP USER 'us,er1'@'localhost'; -diff --git a/plugin/audit_log/tests/mtr/percona_bug_ps8719-master.opt b/plugin/audit_log/tests/mtr/percona_bug_ps8719-master.opt -new file mode 100644 -index 00000000000..12f99a73d0c ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/percona_bug_ps8719-master.opt -@@ -0,0 +1,4 @@ -+--debug=+d,audit_log_write_full_buffer -+--audit_log_strategy=ASYNCHRONOUS -+--audit_log_buffer_size=4096 -+--audit_log_policy=ALL -diff --git a/plugin/audit_log/tests/mtr/percona_bug_ps8719.result b/plugin/audit_log/tests/mtr/percona_bug_ps8719.result -new file mode 100644 -index 00000000000..7d5802f5e05 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/percona_bug_ps8719.result -@@ -0,0 +1 @@ -+SET GLOBAL audit_log_flush=ON; -diff --git a/plugin/audit_log/tests/mtr/percona_bug_ps8719.test b/plugin/audit_log/tests/mtr/percona_bug_ps8719.test -new file mode 100644 -index 00000000000..60a09ab6329 ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/percona_bug_ps8719.test -@@ -0,0 +1,12 @@ -+# PS-8719: Audit log plugin stalls on flush -+--source include/have_debug.inc -+--source include/have_debug_sync.inc -+ -+--disable_query_log -+--disable_result_log -+SELECT "4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonjTjv4IHYyOZMEAUJcURiOO9nLoceKvbRi3HSZZObmonj"; -+--enable_result_log -+--enable_query_log -+ -+# Must not hung at this point -+SET GLOBAL audit_log_flush=ON; -diff --git a/plugin/audit_log/tests/mtr/suite.opt b/plugin/audit_log/tests/mtr/suite.opt -new file mode 100644 -index 00000000000..60755382b7b ---- /dev/null -+++ b/plugin/audit_log/tests/mtr/suite.opt -@@ -0,0 +1,2 @@ -+$AUDIT_LOG_OPT -+$AUDIT_LOG_LOAD