revision-id: a858163c050203cef3a6a1bd6c54e3138641321d (mariadb-10.0.37-59-ga858163c050) parent(s): 1f548cba6eeb4833f077326e51682c52294468bc author: Varun Gupta committer: Varun Gupta timestamp: 2019-01-29 16:08:59 +0530 message: MDEV-15950: LOAD DATA INTO compex_view crashed For multi-table views with LOAD, updates are not allowed, so we should just throw an error. --- mysql-test/r/loaddata.result | 26 ++++++++++++++++++++++++++ mysql-test/t/loaddata.test | 31 +++++++++++++++++++++++++++++++ sql/sql_load.cc | 5 +++++ 3 files changed, 62 insertions(+) diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 7e3f8e91eb2..d71032a0aca 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -574,3 +574,29 @@ a b 6 6 DROP VIEW IF EXISTS v2,t2; DROP TABLE IF EXISTS t1; +# +# MDEV-15950: LOAD DATA INTO compex_view crashed +# +create table t1 (a int, b int); +create table t0 (x int, y int); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0; +CREATE VIEW v2 AS SELECT * FROM v1; +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1 +FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; +ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2 +FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; +ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD +DROP VIEW IF EXISTS v2,v1; +DROP TABLE IF EXISTS t1,t0; +CREATE OR REPLACE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b)); +INSERT INTO t1 VALUES (1,1); +CREATE OR REPLACE TABLE t2 (c INT); +CREATE OR REPLACE VIEW v AS SELECT t1.* FROM t1 JOIN t2; +SELECT a, b FROM t1 INTO OUTFILE '15645.data'; +LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b); +ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD +LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b); +ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD +drop table t1,t2; +drop view v; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 50d5615e58c..66fe7073a37 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -690,3 +690,34 @@ select * from v2; select * from t2; DROP VIEW IF EXISTS v2,t2; DROP TABLE IF EXISTS t1; + +--echo # +--echo # MDEV-15950: LOAD DATA INTO compex_view crashed +--echo # +create table t1 (a int, b int); +create table t0 (x int, y int); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0; +CREATE VIEW v2 AS SELECT * FROM v1; + +--error ER_WRONG_USAGE +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1 +FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; + +--error ER_WRONG_USAGE +LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2 +FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; + +DROP VIEW IF EXISTS v2,v1; +DROP TABLE IF EXISTS t1,t0; + +CREATE OR REPLACE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b)); +INSERT INTO t1 VALUES (1,1); +CREATE OR REPLACE TABLE t2 (c INT); +CREATE OR REPLACE VIEW v AS SELECT t1.* FROM t1 JOIN t2; +SELECT a, b FROM t1 INTO OUTFILE '15645.data'; +--error ER_WRONG_USAGE +LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b); +--error ER_WRONG_USAGE +LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b); +drop table t1,t2; +drop view v; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c369b040106..5b805bbad90 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -326,6 +326,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD"); DBUG_RETURN(TRUE); } + if (table_list->is_multitable()) + { + my_error(ER_WRONG_USAGE, MYF(0), "Multi-table VIEW", "LOAD"); + DBUG_RETURN(TRUE); + } if (table_list->prepare_where(thd, 0, TRUE) || table_list->prepare_check_option(thd)) {