Skip to content

Commit 08c05b5

Browse files
author
Varun Gupta
committed
MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
For singe-table views, we need to find the bottom most base table in the embedded views and then update that table
1 parent eff71f3 commit 08c05b5

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

mysql-test/r/loaddata.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,27 @@ SELECT HEX(a) FROM t1;
550550
HEX(a)
551551
C3A4
552552
DROP TABLE t1;
553+
#
554+
# MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
555+
#
556+
create table t1 (a int, b int);
557+
CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
558+
CREATE VIEW v2 AS SELECT * FROM t2;
559+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
560+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
561+
select * from v2;
562+
a b
563+
2 2
564+
3 3
565+
4 4
566+
5 5
567+
6 6
568+
select * from t2;
569+
a b
570+
2 2
571+
3 3
572+
4 4
573+
5 5
574+
6 6
575+
DROP VIEW IF EXISTS v2,t2;
576+
DROP TABLE IF EXISTS t1;

mysql-test/t/loaddata.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,17 @@ CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
676676
LOAD DATA INFILE '../../std_data/loaddata/mdev-11631.txt' INTO TABLE t1 CHARACTER SET utf8;
677677
SELECT HEX(a) FROM t1;
678678
DROP TABLE t1;
679+
680+
--echo #
681+
--echo # MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
682+
--echo #
683+
684+
create table t1 (a int, b int);
685+
CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
686+
CREATE VIEW v2 AS SELECT * FROM t2;
687+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
688+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
689+
select * from v2;
690+
select * from t2;
691+
DROP VIEW IF EXISTS v2,t2;
692+
DROP TABLE IF EXISTS t1;

sql/sql_load.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
233233

234234
if (open_and_lock_tables(thd, table_list, TRUE, 0))
235235
DBUG_RETURN(TRUE);
236-
if (mysql_handle_single_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
237-
mysql_handle_single_derived(thd->lex, table_list, DT_PREPARE))
236+
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
237+
DBUG_RETURN(TRUE);
238+
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
238239
DBUG_RETURN(TRUE);
239240
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
240241
&thd->lex->select_lex.top_join_list,

0 commit comments

Comments
 (0)