for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection master_1;
set @old_spider_direct_dup_insert= @@spider_direct_dup_insert;
set session spider_direct_dup_insert= 0;

this test is for MDEV-18987

drop and create databases
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
CREATE DATABASE auto_test_remote;
USE auto_test_remote;

create table and insert
connection child2_1;
CHILD2_1_CREATE_TABLES
TRUNCATE TABLE mysql.general_log;
connection master_1;
CREATE TABLE tbl_a (
pkey int NOT NULL,
val int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
Warnings:
Warning	138	Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead.
INSERT INTO tbl_a (pkey,val) VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
SELECT pkey,val INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' FROM tbl_a ORDER BY pkey;
UPDATE tbl_a SET val = val + 1;

select test 1
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
LOAD DATA  INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a;
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%';
argument
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 0 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 0,`val` = 0 where `pkey` = 0 and `val` = 1 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 1,`val` = 1 where `pkey` = 1 and `val` = 2 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(2,2)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 2 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 2,`val` = 2 where `pkey` = 2 and `val` = 3 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(3,3)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 3 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 3,`val` = 3 where `pkey` = 3 and `val` = 4 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(4,4)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 4 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 4,`val` = 4 where `pkey` = 4 and `val` = 5 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(5,5)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 5 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 5,`val` = 5 where `pkey` = 5 and `val` = 6 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(6,6)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 6 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 6,`val` = 6 where `pkey` = 6 and `val` = 7 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 7 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 7,`val` = 7 where `pkey` = 7 and `val` = 8 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(8,8)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 8 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 8,`val` = 8 where `pkey` = 8 and `val` = 9 limit 1
insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9)
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 9 for update
update ignore `auto_test_remote`.`tbl_a` set `pkey` = 9,`val` = 9 where `pkey` = 9 and `val` = 10 limit 1
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'
SELECT pkey, val FROM tbl_a ORDER BY pkey;
pkey	val
0	0
1	1
2	2
3	3
4	4
5	5
6	6
7	7
8	8
9	9

deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;
connection master_1;
set session spider_direct_dup_insert= @old_spider_direct_dup_insert;
for master_1
for child2
child2_1
child2_2
child2_3
for child3

end of test
