Skip to content

Commit

Permalink
MDEV-15965 Invisible columns and LOAD DATA don't work well together:.…
Browse files Browse the repository at this point in the history
….. ER_WARN_TOO_FEW_RECORDS

Fix mysql_load iterator to skip invisible fields.
  • Loading branch information
SachinSetiya authored and sachin committed May 15, 2018
1 parent 46be319 commit 9ee5406
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
61 changes: 61 additions & 0 deletions mysql-test/main/invisible_field.result
Original file line number Diff line number Diff line change
Expand Up @@ -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,@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,@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,@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,@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;
25 changes: 25 additions & 0 deletions mysql-test/main/invisible_field.test
Original file line number Diff line number Diff line change
Expand Up @@ -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,@v) SET b=@v;
select a,b from t1;
load data infile 'f' into table t1 (a,@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,@v) SET b=@v;
select a,b from t1;
load data infile 'a' into table t1 (a,@v) SET b=@v+2;
select a,b from t1;

#cleanup
drop table t1;
3 changes: 3 additions & 0 deletions sql/sql_load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ 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() &&
field_iterator.field()->invisible > VISIBLE)
continue;
Item *item;
if (!(item= field_iterator.create_item(thd)))
DBUG_RETURN(TRUE);
Expand Down

0 comments on commit 9ee5406

Please sign in to comment.