#
# MDEV-26247 Spider: Valid LEFT JOIN results in ERROR 1064
#
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection child2_1;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
CREATE TABLE t1 (a int) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE t2 (a int) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE t3 (a int) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1), (2);
INSERT INTO t3 VALUES (1), (2), (3);
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
CREATE TABLE t1 (a int) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='srv "s_2_1", table "t1"';
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.
CREATE TABLE t2 (a int) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='srv "s_2_1", table "t2"';
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.
CREATE TABLE t3 (a int) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='srv "s_2_1", table "t3"';
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.
select * from t3 left join t1 on t3.a = t1.a left join t2 on t3.a = t2.a;
a	a	a
1	1	1
2	NULL	2
3	NULL	NULL
select * from t1 left join t2 on t1.a = t2.a right join t3 on t3.a = t1.a;
a	a	a
1	1	1
NULL	NULL	2
NULL	NULL	3
select * from t3 left join (t1 left join t2 on t1.a = t2.a) on t3.a = t1.a;
a	a	a
1	1	1
2	NULL	NULL
3	NULL	NULL
drop table t1, t2, t3;
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
