diff options
-rw-r--r-- | mysql-test/r/mdev_5628.result | 6 | ||||
-rw-r--r-- | mysql-test/t/mdev_5628.test | 10 | ||||
-rw-r--r-- | sql/sql_update.cc | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/mdev_5628.result b/mysql-test/r/mdev_5628.result new file mode 100644 index 00000000000..5ab751b12ed --- /dev/null +++ b/mysql-test/r/mdev_5628.result @@ -0,0 +1,6 @@ +CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 1; +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); +UPDATE t1 SET a = 7 WHERE a = (select b from t2); +ERROR 21000: Subquery returns more than 1 row +drop table t1, t2; diff --git a/mysql-test/t/mdev_5628.test b/mysql-test/t/mdev_5628.test new file mode 100644 index 00000000000..8f4a23b6e2d --- /dev/null +++ b/mysql-test/t/mdev_5628.test @@ -0,0 +1,10 @@ +--source include/have_partition.inc + +CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 1; + +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET a = 7 WHERE a = (select b from t2); + +drop table t1, t2; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index e42f6a4ff76..c88b0d318cb 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -401,6 +401,10 @@ int mysql_update(THD *thd, if (prune_partitions(thd, table, conds)) { free_underlaid_joins(thd, select_lex); + //If we got error in SubSelect or because of any other reason + //Don't reset it (Mdev-5628) + if (thd->is_error()) + DBUG_RETURN(0); my_ok(thd); // No matching records DBUG_RETURN(0); } |