Skip to content

Commit 779d416

Browse files
committed
MDEV-10724 Assertion `vcol_table == 0 || vcol_table == table' failed in fill_record(THD*, TABLE*, List<Item>&, List<Item>&, bool, bool)
Attempt to insert in several tables now checked just by table map.
1 parent 4a27ab2 commit 779d416

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

mysql-test/r/view.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6278,5 +6278,19 @@ a
62786278
DROP VIEW v1;
62796279
DROP TABLE t1;
62806280
#
6281+
# MDEV-10724:Assertion `vcol_table == 0 || vcol_table == table'
6282+
# failed in fill_record(THD*, TABLE*, List<Item>&, List<Item>&,
6283+
# bool, bool)
6284+
#
6285+
CREATE TABLE t1 (f1 INT);
6286+
CREATE TABLE t2 (f2 INT);
6287+
CREATE TABLE t3 (f3 INT);
6288+
CREATE ALGORITHM = MERGE VIEW v AS SELECT f1, f3 FROM t1,
6289+
( SELECT f3 FROM t2, t3 ) AS sq;
6290+
INSERT INTO v (f1, f3) VALUES (1,1), (2,2);
6291+
ERROR HY000: Can not modify more than one base table through a join view 'test.v'
6292+
drop view v;
6293+
drop tables t1,t2,t3;
6294+
#
62816295
# End of 10.2 tests
62826296
#

mysql-test/t/view.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6019,6 +6019,26 @@ select * from v1;
60196019
DROP VIEW v1;
60206020

60216021
DROP TABLE t1;
6022+
6023+
--echo #
6024+
--echo # MDEV-10724:Assertion `vcol_table == 0 || vcol_table == table'
6025+
--echo # failed in fill_record(THD*, TABLE*, List<Item>&, List<Item>&,
6026+
--echo # bool, bool)
6027+
--echo #
6028+
6029+
CREATE TABLE t1 (f1 INT);
6030+
CREATE TABLE t2 (f2 INT);
6031+
CREATE TABLE t3 (f3 INT);
6032+
6033+
CREATE ALGORITHM = MERGE VIEW v AS SELECT f1, f3 FROM t1,
6034+
( SELECT f3 FROM t2, t3 ) AS sq;
6035+
6036+
--error ER_VIEW_MULTIUPDATE
6037+
INSERT INTO v (f1, f3) VALUES (1,1), (2,2);
6038+
6039+
drop view v;
6040+
drop tables t1,t2,t3;
6041+
60226042
--echo #
60236043
--echo # End of 10.2 tests
60246044
--echo #

sql/sql_insert.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "sql_audit.h"
7979
#include "sql_derived.h" // mysql_handle_derived
8080
#include "sql_prepare.h"
81+
#include <my_bit.h>
8182

8283
#include "debug_sync.h"
8384

@@ -127,6 +128,14 @@ static bool check_view_single_update(List<Item> &fields, List<Item> *values,
127128
while ((item= it++))
128129
tables|= item->used_tables();
129130

131+
/*
132+
Check that table is only one
133+
(we can not rely on check_single_table because it skips some
134+
types of tables)
135+
*/
136+
if (my_count_bits(tables) > 1)
137+
goto error;
138+
130139
if (values)
131140
{
132141
it.init(*values);

0 commit comments

Comments
 (0)