1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
Sachin Setiya
2018-04-26 16:49:27 +05:30
committed by sachin
parent 46be31982a
commit 9ee5406e2f
3 changed files with 89 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);