for master_1
for child2
child2_1
child2_2
child2_3
for child3

this test is for MDEV-20502

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 (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
val int(10) unsigned DEFAULT NULL,
PRIMARY KEY(id)
) ENGINE=Spider COMMENT='table "tbl_a", srv "s_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 (val) VALUES (1);

test 1
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT id, 0 AS const, val FROM tbl_a;
id	const	val
1	0	1
SELECT 1+2, id, 0 AS const, val, val+10, (SELECT tbl_a.val+1 FROM tbl_a) AS sq
FROM tbl_a;
1+2	id	const	val	val+10	sq
3	1	0	1	11	2
INSERT INTO tbl_a (val) VALUES (2), (1);
SELECT val+10, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq
FROM tbl_a GROUP BY val;
val+10	const	val	sq
11	0	1	2
12	0	2	2
SELECT MAX(id) AS m, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq
FROM tbl_a GROUP BY val;
m	const	val	sq
3	0	1	2
2	0	2	2
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`id` `id`,0 `const`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t0
select `id`,`val` from `auto_test_remote`.`tbl_a`
select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0
select `id`,`val` from `auto_test_remote`.`tbl_a` order by `id` desc limit 1 for update
select `val` from `auto_test_remote`.`tbl_a` group by `val`
select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1
select max(`id`),min(`id`),`val` from `auto_test_remote`.`tbl_a` group by `val`
select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT id, val FROM tbl_a ORDER BY id;
id	val
1	1
2	2
3	1

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;
for master_1
for child2
child2_1
child2_2
child2_3
for child3

end of test
