revision-id: 95486e132c38d20d6666a7d783d67d86bdb67e87 (mariadb-10.0.35-43-g95486e132c3) parent(s): 3661d9882224dd485556ce937c1294eaeda02ef8 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-06-18 15:19:06 +0200 message: ccc --- mysql-test/t/test.test | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ sql/item_subselect.cc | 2 +- sql/sql_select.cc | 3 +++ sql/sql_update.cc | 18 ++++++++++++++-- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/mysql-test/t/test.test b/mysql-test/t/test.test new file mode 100644 index 00000000000..ac16d08c167 --- /dev/null +++ b/mysql-test/t/test.test @@ -0,0 +1,57 @@ +--source include/have_innodb.inc + +--connect (con2,localhost,root,,test) +CREATE TABLE t1 ( + f1_1 DATE, + f1_2 DATE NOT NULL, + f1_3 VARCHAR(10), + f1_4 INT UNSIGNED, + f_ind DATE NOT NULL, + KEY(f_ind) +) ENGINE=InnoDB; +CREATE OR REPLACE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (NULL, '0000-00-00', 'z', 2, '2001-03-01'), ('0000-00-00', '2001-08-25', 'p', 2, '2006-03-03'); + +CREATE TABLE t2 (f2 INT UNSIGNED) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(2); + +CREATE TABLE t3 ( + pk INT, + f3_1 VARCHAR(10), + f3_2 INT UNSIGNED, +primary key (pk) +) ENGINE=innodb; +CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t3 VALUES (1, NULL, 9), (2, 'v', 0); + +--connect (con1,localhost,root,,test) +SET DEBUG_SYNC= 'multi_update_before_loop1 SIGNAL update1 WAIT_FOR continue1'; +SET DEBUG_SYNC= 'multi_update_after_loop SIGNAL update3 WAIT_FOR continue3'; +--send +UPDATE t1, t2, t3 SET pk = -1; + +--connection con2 +SET DEBUG_SYNC= 'now WAIT_FOR update1'; +SET DEBUG_SYNC= 'multi_update_before_loop2 SIGNAL update2 WAIT_FOR continue2'; +--send +UPDATE v1 LEFT JOIN t1 ON (v1.f1_2 = t1.f1_1) SET v1.f1_4 = 1 WHERE EXISTS ( SELECT * FROM t2 INNER JOIN v3 ON (f3_2 = f2) WHERE f3_1 = t1.f1_3 OR f3_2 > f2 ); + +--connection default +SET DEBUG_SYNC= 'now WAIT_FOR update2'; +SET DEBUG_SYNC= 'now SIGNAL continue1'; +SET DEBUG_SYNC= 'now WAIT_FOR update3'; +SET DEBUG_SYNC= 'now SIGNAL continue3'; +--connection con1 +--error ER_DUP_ENTRY +--reap + +SET DEBUG_SYNC= 'now SIGNAL continue2'; + + +--connection con2 +--reap + +--connection default +SET DEBUG_SYNC= 'reset'; +drop view v1,v3; +drop table t1,t2,t3; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index a8dfdff9809..808cbf4a103 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -3781,7 +3781,7 @@ int subselect_single_select_engine::exec() } thd->where= save_where; thd->lex->current_select= save_select; - DBUG_RETURN(0); + DBUG_RETURN(join->error); } int subselect_union_engine::exec() diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f7f6287c3fd..8d6927cfac8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18155,6 +18155,9 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, DBUG_RETURN(NESTED_LOOP_OK); } } + /* check for errors evaluating the condition */ + if (join->thd->is_error()) + DBUG_RETURN(NESTED_LOOP_ERROR); } /* Check whether join_tab is not the last inner table diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 94fbe0924b6..b72ea886a0f 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -527,7 +527,7 @@ int mysql_update(THD *thd, DBUG_EXECUTE_IF("show_explain_probe_update_exec_start", dbug_serve_apcs(thd, 1);); - + if (!(select && select->quick)) status_var_increment(thd->status_var.update_scan_count); @@ -1589,6 +1589,8 @@ bool mysql_multi_update(THD *thd, thd->abort_on_warning= !ignore && thd->is_strict_mode(); List<Item> total_list; + DEBUG_SYNC(thd, "multi_update_before_loop1"); + DEBUG_SYNC(thd, "multi_update_before_loop2"); res= mysql_select(thd, &select_lex->ref_pointer_array, table_list, select_lex->with_wild, total_list, @@ -1597,6 +1599,7 @@ bool mysql_multi_update(THD *thd, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE, *result, unit, select_lex); + DEBUG_SYNC(thd, "multi_update_after_loop"); DBUG_PRINT("info",("res: %d report_error: %d", res, (int) thd->is_error())); res|= thd->is_error(); @@ -2151,11 +2154,22 @@ int multi_update::send_data(List<Item> ¬_used_values) } else { - if (error == HA_ERR_RECORD_IS_THE_SAME) + if (error == HA_ERR_RECORD_IS_THE_SAME || + (error && ignore && + !table->file->is_fatal_error(error, HA_CHECK_ALL))) { error= 0; updated--; } + else + { + if (error) + { + table->file->print_error(error, MYF(0)); + DBUG_RETURN(1); + } + } + /* non-transactional or transactional table got modified */ /* either multi_update class' flag is raised in its branch */ if (table->file->has_transactions())