Skip to content

Commit 6092093

Browse files
author
Varun Gupta
committed
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.
1 parent 08c05b5 commit 6092093

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

mysql-test/r/loaddata.result

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,3 +574,29 @@ a b
574574
6 6
575575
DROP VIEW IF EXISTS v2,t2;
576576
DROP TABLE IF EXISTS t1;
577+
#
578+
# MDEV-15950: LOAD DATA INTO compex_view crashed
579+
#
580+
create table t1 (a int, b int);
581+
create table t0 (x int, y int);
582+
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
583+
CREATE VIEW v2 AS SELECT * FROM v1;
584+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
585+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
586+
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
587+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
588+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
589+
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
590+
DROP VIEW IF EXISTS v2,v1;
591+
DROP TABLE IF EXISTS t1,t0;
592+
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
593+
INSERT INTO t1 VALUES (1,1);
594+
CREATE TABLE t2 (c INT);
595+
CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
596+
SELECT a, b FROM t1 INTO OUTFILE '15645.data';
597+
LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
598+
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
599+
LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
600+
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
601+
drop table t1,t2;
602+
drop view v;

mysql-test/t/loaddata.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,34 @@ select * from v2;
690690
select * from t2;
691691
DROP VIEW IF EXISTS v2,t2;
692692
DROP TABLE IF EXISTS t1;
693+
694+
--echo #
695+
--echo # MDEV-15950: LOAD DATA INTO compex_view crashed
696+
--echo #
697+
create table t1 (a int, b int);
698+
create table t0 (x int, y int);
699+
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
700+
CREATE VIEW v2 AS SELECT * FROM v1;
701+
702+
--error ER_WRONG_USAGE
703+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
704+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
705+
706+
--error ER_WRONG_USAGE
707+
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
708+
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
709+
710+
DROP VIEW IF EXISTS v2,v1;
711+
DROP TABLE IF EXISTS t1,t0;
712+
713+
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
714+
INSERT INTO t1 VALUES (1,1);
715+
CREATE TABLE t2 (c INT);
716+
CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
717+
SELECT a, b FROM t1 INTO OUTFILE '15645.data';
718+
--error ER_WRONG_USAGE
719+
LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
720+
--error ER_WRONG_USAGE
721+
LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
722+
drop table t1,t2;
723+
drop view v;

sql/sql_load.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
251251
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD");
252252
DBUG_RETURN(TRUE);
253253
}
254+
if (table_list->is_multitable())
255+
{
256+
my_error(ER_WRONG_USAGE, MYF(0), "Multi-table VIEW", "LOAD");
257+
DBUG_RETURN(TRUE);
258+
}
254259
if (table_list->prepare_where(thd, 0, TRUE) ||
255260
table_list->prepare_check_option(thd))
256261
{

0 commit comments

Comments
 (0)