From 779d416a992f0d4a28dc2c2724d81bd3b780e2cb Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 16 Nov 2016 20:39:08 +0100 Subject: [PATCH] MDEV-10724 Assertion `vcol_table == 0 || vcol_table == table' failed in fill_record(THD*, TABLE*, List&, List&, bool, bool) Attempt to insert in several tables now checked just by table map. --- mysql-test/r/view.result | 14 ++++++++++++++ mysql-test/t/view.test | 20 ++++++++++++++++++++ sql/sql_insert.cc | 9 +++++++++ 3 files changed, 43 insertions(+) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index f615b10c59c..34b899b3f00 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -6278,5 +6278,19 @@ a DROP VIEW v1; DROP TABLE t1; # +# MDEV-10724:Assertion `vcol_table == 0 || vcol_table == table' +# failed in fill_record(THD*, TABLE*, List&, List&, +# bool, bool) +# +CREATE TABLE t1 (f1 INT); +CREATE TABLE t2 (f2 INT); +CREATE TABLE t3 (f3 INT); +CREATE ALGORITHM = MERGE VIEW v AS SELECT f1, f3 FROM t1, +( SELECT f3 FROM t2, t3 ) AS sq; +INSERT INTO v (f1, f3) VALUES (1,1), (2,2); +ERROR HY000: Can not modify more than one base table through a join view 'test.v' +drop view v; +drop tables t1,t2,t3; +# # End of 10.2 tests # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 8992f77c563..59ff87f0bad 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -6019,6 +6019,26 @@ select * from v1; DROP VIEW v1; DROP TABLE t1; + +--echo # +--echo # MDEV-10724:Assertion `vcol_table == 0 || vcol_table == table' +--echo # failed in fill_record(THD*, TABLE*, List&, List&, +--echo # bool, bool) +--echo # + +CREATE TABLE t1 (f1 INT); +CREATE TABLE t2 (f2 INT); +CREATE TABLE t3 (f3 INT); + +CREATE ALGORITHM = MERGE VIEW v AS SELECT f1, f3 FROM t1, +( SELECT f3 FROM t2, t3 ) AS sq; + +--error ER_VIEW_MULTIUPDATE +INSERT INTO v (f1, f3) VALUES (1,1), (2,2); + +drop view v; +drop tables t1,t2,t3; + --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 432f8b67378..7c0c1b68a2b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -78,6 +78,7 @@ #include "sql_audit.h" #include "sql_derived.h" // mysql_handle_derived #include "sql_prepare.h" +#include #include "debug_sync.h" @@ -127,6 +128,14 @@ static bool check_view_single_update(List &fields, List *values, while ((item= it++)) tables|= item->used_tables(); + /* + Check that table is only one + (we can not rely on check_single_table because it skips some + types of tables) + */ + if (my_count_bits(tables) > 1) + goto error; + if (values) { it.init(*values);