From 389f7cdf3ccd11a6b4fb9b6346436790254e615c Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 19 Sep 2017 13:08:24 +0400 Subject: [PATCH 1/2] MDEV-13137 MySQL 5.6.23 Crashes when SET GLOBAL server_audit_logging=OFF; The MySQL 5.6 doesn't always send the MYSQL_AUDIT_GENERAL_LOG notification. So we have to suppress the log_current_query() in this case. --- plugin/server_audit/server_audit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index c4b6fa361a3..6a2ed16cb00 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -15,7 +15,7 @@ #define PLUGIN_VERSION 0x104 -#define PLUGIN_STR_VERSION "1.4.1" +#define PLUGIN_STR_VERSION "1.4.2" #define _my_thread_var loc_thread_var @@ -1089,6 +1089,7 @@ static void setup_connection_connect(struct connection_info *cn, const struct mysql_event_connection *event) { cn->query_id= 0; + cn->query_length= 0; cn->log_always= 0; cn->thread_id= event->thread_id; get_str_n(cn->db, &cn->db_length, sizeof(cn->db), @@ -1130,6 +1131,7 @@ static void setup_connection_initdb(struct connection_info *cn, cn->thread_id= event->general_thread_id; cn->query_id= 0; + cn->query_length= 0; cn->log_always= 0; get_str_n(cn->db, &cn->db_length, sizeof(cn->db), event->general_query, event->general_query_length); @@ -1162,6 +1164,7 @@ static void setup_connection_table(struct connection_info *cn, cn->thread_id= event->thread_id; cn->query_id= query_counter++; cn->log_always= 0; + cn->query_length= 0; get_str_n(cn->db, &cn->db_length, sizeof(cn->db), event->database, event->database_length); get_str_n(cn->user, &cn->user_length, sizeof(cn->db), @@ -1183,6 +1186,7 @@ static void setup_connection_query(struct connection_info *cn, cn->thread_id= event->general_thread_id; cn->query_id= query_counter++; cn->log_always= 0; + cn->query_length= 0; get_str_n(cn->db, &cn->db_length, sizeof(cn->db), "", 0); if (get_user_host(event->general_user, event->general_user_length, @@ -2007,6 +2011,7 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev) event_query_command(event)) { log_statement(cn, event, "QUERY"); + cn->query_length= 0; /* So the log_current_query() won't log this again. */ } } else if (event_class == MYSQL_AUDIT_TABLE_CLASS && FILTER(EVENT_TABLE) && cn) @@ -2522,7 +2527,8 @@ static void log_current_query(MYSQL_THD thd) if (!thd) return; cn= get_loc_info(thd); - if (!ci_needs_setup(cn) && FILTER(EVENT_QUERY) && do_log_user(cn->user)) + if (!ci_needs_setup(cn) && cn->query_length && + FILTER(EVENT_QUERY) && do_log_user(cn->user)) { log_statement_ex(cn, cn->query_time, thd_get_thread_id(thd), cn->query, cn->query_length, 0, "QUERY"); From 97c2a7354b68b4476ef77266c21b02bf72c53cdf Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Tue, 19 Sep 2017 15:55:59 +0200 Subject: [PATCH 2/2] MDEV-13290: Assertion Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' or `! is_set()' failed Check error status which can be set by conversion procedures. --- mysql-test/r/insert.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/insert.test | 29 +++++++++++++++++++++++++++++ sql/table.cc | 3 +++ 3 files changed, 60 insertions(+) diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 82f3977e231..8b03a3363de 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -717,3 +717,31 @@ insert ignore into t1 values (1,12); Warnings: Warning 1062 Duplicate entry '1' for key 'f1' DROP TABLE t1; +# +# MDEV-13290 Assertion Assertion `!is_set() || (m_status == DA_OK_BULK +# && is_bulk_op())' or `! is_set()' failed +# +SET @save_mode= @@sql_mode; +SET sql_mode= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (f1 INT DEFAULT 0, f2 INT); +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = 'x' WITH CHECK OPTION; +REPLACE INTO v1 SET f2 = 1; +ERROR 22007: Truncated incorrect DOUBLE value: 'x' +SELECT * from t1; +f1 f2 +drop view v1; +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = cast('' as decimal) WITH CHECK OPTION; +REPLACE INTO v1 SET f2 = 1; +ERROR 22007: Truncated incorrect DECIMAL value: '' +SELECT * from t1; +f1 f2 +drop view v1; +SELECT 0,0 INTO OUTFILE 't1.txt'; +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = 'x' WITH CHECK OPTION; +LOAD DATA INFILE 't1.txt' INTO TABLE v1; +ERROR 22007: Truncated incorrect DOUBLE value: 'x' +SELECT * from t1; +f1 f2 +drop view v1; +drop table t1; +SET @@sql_mode= @save_mode; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index ff8396fd7fd..e28eeb9f876 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -573,3 +573,32 @@ insert ignore into t1 values (1,12) on duplicate key update f2=13; set @@old_mode=""; insert ignore into t1 values (1,12); DROP TABLE t1; + +--echo # +--echo # MDEV-13290 Assertion Assertion `!is_set() || (m_status == DA_OK_BULK +--echo # && is_bulk_op())' or `! is_set()' failed +--echo # + +SET @save_mode= @@sql_mode; +SET sql_mode= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (f1 INT DEFAULT 0, f2 INT); +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = 'x' WITH CHECK OPTION; +--error ER_TRUNCATED_WRONG_VALUE +REPLACE INTO v1 SET f2 = 1; +SELECT * from t1; +drop view v1; +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = cast('' as decimal) WITH CHECK OPTION; +--error ER_TRUNCATED_WRONG_VALUE +REPLACE INTO v1 SET f2 = 1; +SELECT * from t1; +drop view v1; +SELECT 0,0 INTO OUTFILE 't1.txt'; +CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = 'x' WITH CHECK OPTION; +--error ER_TRUNCATED_WRONG_VALUE +LOAD DATA INFILE 't1.txt' INTO TABLE v1; +SELECT * from t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/t1.txt; +drop view v1; +drop table t1; +SET @@sql_mode= @save_mode; diff --git a/sql/table.cc b/sql/table.cc index 975d9d53882..ff9c4217b7d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4642,6 +4642,9 @@ int TABLE_LIST::view_check_option(THD *thd, bool ignore_failure) main_view->view_name.str); return(VIEW_CHECK_ERROR); } + /* We check thd->error() because it can be set by conversion problem. */ + if (thd->is_error()) + return(VIEW_CHECK_ERROR); return(VIEW_CHECK_OK); }