mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
f169114042
Now one can use user variables as target for data loaded from file (besides table's columns). Also LOAD DATA got new SET-clause in which one can specify values for table columns as expressions. For example the following is possible: LOAD DATA INFILE 'words.dat' INTO TABLE t1 (a, @b) SET c = @b + 1; This patch also implements new way of replicating LOAD DATA. Now we do it similarly to other queries. We store LOAD DATA query in new Execute_load_query event (which is last in the sequence of events representing LOAD DATA). When we are executing this event we simply rewrite part of query which holds name of file (we use name of temporary file) and then execute it as usual query. In the beggining of this sequence we use Begin_load_query event which is almost identical to Append_file event
60 lines
1.9 KiB
Text
60 lines
1.9 KiB
Text
# See if "LOAD DATA LOCAL INFILE" is well replicated
|
|
# (LOAD DATA LOCAL INFILE is not written to the binlog
|
|
# the same way as LOAD DATA INFILE : Append_blocks are smaller).
|
|
# In MySQL 4.0 <4.0.12 there were 2 bugs with LOAD DATA LOCAL INFILE :
|
|
# - the loaded file was not written entirely to the master's binlog,
|
|
# only the first 4KB, 8KB or 16KB usually.
|
|
# - the loaded file's first line was not written entirely to the
|
|
# master's binlog (1st char was absent)
|
|
source include/master-slave.inc;
|
|
|
|
create table t1(a int);
|
|
let $1=10000;
|
|
disable_query_log;
|
|
set SQL_LOG_BIN=0;
|
|
while ($1)
|
|
{
|
|
#eval means expand $ expressions
|
|
eval insert into t1 values(1);
|
|
dec $1;
|
|
}
|
|
set SQL_LOG_BIN=1;
|
|
enable_query_log;
|
|
select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
|
|
#This will generate a 20KB file, now test LOAD DATA LOCAL
|
|
truncate table t1;
|
|
load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
|
|
system rm ./var/master-data/rpl_loaddatalocal.select_outfile ;
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
select a,count(*) from t1 group by a;
|
|
connection master;
|
|
drop table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
|
|
#
|
|
# Now let us test how well we replicate LOAD DATA LOCAL in situation when
|
|
# we met duplicates in tables to which we are adding rows.
|
|
# (It supposed that LOAD DATA LOCAL ignores such errors)
|
|
#
|
|
connection master;
|
|
create table t1(a int);
|
|
insert into t1 values (1), (2), (2), (3);
|
|
select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
|
|
drop table t1;
|
|
create table t1(a int primary key);
|
|
load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
|
|
system rm ./var/master-data/rpl_loaddatalocal.select_outfile ;
|
|
select * from t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
select * from t1;
|
|
connection master;
|
|
drop table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|