Skip to content

Commit

Permalink
MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_…
Browse files Browse the repository at this point in the history
…for_insert

For singe-table views, we need to find the bottom most base table in the embedded views
and then update that table
  • Loading branch information
Varun Gupta committed Jan 29, 2019
1 parent eff71f3 commit 08c05b5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
24 changes: 24 additions & 0 deletions mysql-test/r/loaddata.result
Expand Up @@ -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;
14 changes: 14 additions & 0 deletions mysql-test/t/loaddata.test
Expand Up @@ -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;
5 changes: 3 additions & 2 deletions sql/sql_load.cc
Expand Up @@ -233,8 +233,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,
Expand Down

0 comments on commit 08c05b5

Please sign in to comment.