[Commits] bea915f: MDEV-15965 Invisible columns and LOAD DATA don't work well together:...

sachin sachin.setiya at mariadb.com
Thu Apr 26 14:19:48 EEST 2018


revision-id: bea915f21a2a2771ce7f9e19dcb9d6893f33f7bd (mariadb-10.3.6-47-gbea915f)
parent(s): 326db1a2aaa9b275a1a21a863e8cd2d9fa1b1d5f
author: Sachin Setiya
committer: Sachin Setiya
timestamp: 2018-04-26 16:49:27 +0530
message:

MDEV-15965 Invisible columns and LOAD DATA don't work well together:...
ER_WARN_TOO_FEW_RECORDS

Fix mysql_load iterator to skip invisible fields.

---
 mysql-test/main/invisible_field.result | 61 ++++++++++++++++++++++++++++++++++
 mysql-test/main/invisible_field.test   | 25 ++++++++++++++
 sql/sql_load.cc                        |  2 ++
 3 files changed, 88 insertions(+)

diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result
index 5cea77f..876a808 100644
--- a/mysql-test/main/invisible_field.result
+++ b/mysql-test/main/invisible_field.result
@@ -556,3 +556,64 @@ INSERT INTO t1 (c,t) VALUES ('foo','2000-01-01 00:00:00');
 CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET @a= 1;
 INSERT INTO t1 SELECT * FROM t1;
 DROP TABLE t1;
+create or replace table t1 (a int, b int invisible);
+insert into t1 values (1),(2);
+select * from t1 into outfile 'f';
+load data infile 'f' into table t1;
+select a,b from t1;
+a	b
+1	NULL
+2	NULL
+1	NULL
+2	NULL
+load data infile 'f' into table t1 (a, at v) SET b=@v;
+select a,b from t1;
+a	b
+1	NULL
+2	NULL
+1	NULL
+2	NULL
+1	NULL
+2	NULL
+load data infile 'f' into table t1 (a, at v) SET b=a;
+select a,b from t1;
+a	b
+1	NULL
+2	NULL
+1	NULL
+2	NULL
+1	NULL
+2	NULL
+1	1
+2	2
+truncate table t1;
+insert into t1(a,b) values (1,1),(2,2);
+select a,b from t1 into outfile 'a';
+load data infile 'a' into table t1(a,b);
+select a,b from t1;
+a	b
+1	1
+2	2
+1	1
+2	2
+load data infile 'a' into table t1 (a, at v) SET b=@v;
+select a,b from t1;
+a	b
+1	1
+2	2
+1	1
+2	2
+1	1
+2	2
+load data infile 'a' into table t1 (a, at v) SET b=@v+2;
+select a,b from t1;
+a	b
+1	1
+2	2
+1	1
+2	2
+1	1
+2	2
+1	3
+2	4
+drop table t1;
diff --git a/mysql-test/main/invisible_field.test b/mysql-test/main/invisible_field.test
index cfe89d7..0e3994a 100644
--- a/mysql-test/main/invisible_field.test
+++ b/mysql-test/main/invisible_field.test
@@ -246,3 +246,28 @@ CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET @a= 1;
 INSERT INTO t1 SELECT * FROM t1;
 # Cleanup
 DROP TABLE t1;
+##LOAD DATA MDEV-15965 Invisible columns and LOAD DATA don't work well
+##  together: ER_WARN_TOO_FEW_RECORDS
+create or replace table t1 (a int, b int invisible);
+insert into t1 values (1),(2);
+
+select * from t1 into outfile 'f';
+load data infile 'f' into table t1;
+select a,b from t1;
+load data infile 'f' into table t1 (a, at v) SET b=@v;
+select a,b from t1;
+load data infile 'f' into table t1 (a, at v) SET b=a;
+select a,b from t1;
+truncate table t1;
+
+insert into t1(a,b) values (1,1),(2,2);
+select a,b from t1 into outfile 'a';
+load data infile 'a' into table t1(a,b);
+select a,b from t1;
+load data infile 'a' into table t1 (a, at v) SET b=@v;
+select a,b from t1;
+load data infile 'a' into table t1 (a, at v) SET b=@v+2;
+select a,b from t1;
+
+#cleanup
+drop table t1;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index cfa92f1..fbb3926 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -444,6 +444,8 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
     field_iterator.set(table_list);
     for (; !field_iterator.end_of_fields(); field_iterator.next())
     {
+      if (field_iterator.field()->invisible > VISIBLE)
+        continue;
       Item *item;
       if (!(item= field_iterator.create_item(thd)))
         DBUG_RETURN(TRUE);


More information about the commits mailing list