[Commits] 1f548cba6ee: MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert

Varun varunraiko1803 at gmail.com
Mon Jan 28 13:44:28 EET 2019


revision-id: 1f548cba6eeb4833f077326e51682c52294468bc (mariadb-10.0.37-58-g1f548cba6ee)
parent(s): e6fcd7230954c6111bba63e7f7201fc81e50178e
author: Varun Gupta
committer: Varun Gupta
timestamp: 2019-01-28 17:12:05 +0530
message:

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.

---
 mysql-test/r/loaddata.result | 24 ++++++++++++++++++++++++
 mysql-test/t/loaddata.test   | 14 ++++++++++++++
 sql/sql_load.cc              |  5 +++--
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result
index f446a503317..7e3f8e91eb2 100644
--- a/mysql-test/r/loaddata.result
+++ b/mysql-test/r/loaddata.result
@@ -550,3 +550,27 @@ SELECT HEX(a) FROM t1;
 HEX(a)
 C3A4
 DROP TABLE t1;
+#
+# MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
+#
+create table t1 (a int, b int);
+CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+select * from v2;
+a      b
+2      2
+3      3
+4      4
+5      5
+6      6
+select * from t2;
+a      b
+2      2
+3      3
+4      4
+5      5
+6      6
+DROP VIEW IF EXISTS v2,t2;
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 8f8ff3520a2..50d5615e58c 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -676,3 +676,17 @@ CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
 LOAD DATA INFILE '../../std_data/loaddata/mdev-11631.txt' INTO TABLE t1 CHARACTER SET utf8;
 SELECT HEX(a) FROM t1;
 DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
+--echo #
+
+create table t1 (a int, b int);
+CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+     FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+select * from v2;
+select * from t2;
+DROP VIEW IF EXISTS v2,t2;
+DROP TABLE IF EXISTS t1;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 530f4379530..c369b040106 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -308,8 +308,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
 
   if (open_and_lock_tables(thd, table_list, TRUE, 0))
     DBUG_RETURN(TRUE);
-  if (mysql_handle_single_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
-      mysql_handle_single_derived(thd->lex, table_list, DT_PREPARE))
+  if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
+    DBUG_RETURN(TRUE);
+  if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
     DBUG_RETURN(TRUE);
   if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
                                     &thd->lex->select_lex.top_join_list,


More information about the commits mailing list