2018-10-09 11:36:09 +02:00
|
|
|
--source have_federatedx.inc
|
|
|
|
--source include/federated.inc
|
|
|
|
|
2019-02-12 23:00:48 +01:00
|
|
|
connection default;
|
|
|
|
|
2019-02-12 22:11:32 +01:00
|
|
|
set global federated_pushdown=1;
|
|
|
|
|
2018-10-09 11:36:09 +02:00
|
|
|
connection slave;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS federated.t1;
|
|
|
|
|
|
|
|
CREATE TABLE federated.t1 (
|
|
|
|
id int(20) NOT NULL,
|
2019-02-10 07:54:26 +01:00
|
|
|
name varchar(16) NOT NULL default ''
|
2018-10-09 11:36:09 +02:00
|
|
|
)
|
|
|
|
DEFAULT CHARSET=latin1;
|
|
|
|
|
|
|
|
INSERT INTO federated.t1 VALUES
|
|
|
|
(3,'xxx'), (7,'yyy'), (4,'xxx'), (1,'zzz'), (5,'yyy');
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS federated.t2;
|
|
|
|
|
|
|
|
CREATE TABLE federated.t2 (
|
2019-02-10 07:54:26 +01:00
|
|
|
name varchar(16) NOT NULL default ''
|
2018-10-09 11:36:09 +02:00
|
|
|
)
|
|
|
|
DEFAULT CHARSET=latin1;
|
|
|
|
|
|
|
|
INSERT INTO federated.t2 VALUES
|
|
|
|
('yyy'), ('www'), ('yyy'), ('xxx'), ('www'), ('yyy'), ('www');
|
|
|
|
|
|
|
|
|
|
|
|
connection master;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS federated.t1;
|
|
|
|
|
|
|
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
|
|
|
eval
|
|
|
|
CREATE TABLE federated.t1 (
|
|
|
|
id int(20) NOT NULL,
|
2019-02-10 07:54:26 +01:00
|
|
|
name varchar(16) NOT NULL default ''
|
2018-10-09 11:36:09 +02:00
|
|
|
)
|
|
|
|
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
|
|
|
|
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS federated.t2;
|
|
|
|
|
|
|
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
|
|
|
eval
|
|
|
|
CREATE TABLE federated.t2 (
|
2019-02-10 07:54:26 +01:00
|
|
|
name varchar(16) NOT NULL default ''
|
2018-10-09 11:36:09 +02:00
|
|
|
)
|
|
|
|
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
|
|
|
|
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2';
|
|
|
|
|
|
|
|
SELECT * FROM federated.t1;
|
|
|
|
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
|
|
|
SELECT count(*), name FROM federated.t1 WHERE id < 5 GROUP BY name;
|
|
|
|
|
|
|
|
SELECT * FROM federated.t1, federated.t2
|
|
|
|
WHERE federated.t1.name = federated.t2.name;
|
|
|
|
|
|
|
|
SELECT * FROM federated.t1 LEFT JOIN federated.t2
|
|
|
|
ON federated.t1.name = federated.t2.name
|
|
|
|
WHERE federated.t1.id > 1;
|
|
|
|
|
|
|
|
SELECT * FROM federated.t1
|
|
|
|
WHERE id IN (SELECT count(*) FROM federated.t2 GROUP BY name);
|
|
|
|
|
|
|
|
EXPLAIN
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
|
|
|
EXPLAIN EXTENDED
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
|
|
|
EXPLAIN FORMAT=JSON
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
|
|
|
ANALYZE
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
2019-02-10 07:54:26 +01:00
|
|
|
--source include/analyze-format.inc
|
2018-10-09 11:36:09 +02:00
|
|
|
ANALYZE FORMAT=JSON
|
|
|
|
SELECT id FROM federated.t1 WHERE id < 5;
|
|
|
|
|
|
|
|
CREATE TABLE federated.t3 (
|
2019-02-10 07:54:26 +01:00
|
|
|
name varchar(16) NOT NULL default ''
|
2018-10-09 11:36:09 +02:00
|
|
|
)
|
|
|
|
DEFAULT CHARSET=latin1;
|
|
|
|
|
|
|
|
INSERT INTO federated.t3 VALUES
|
|
|
|
('yyy'), ('www'), ('yyy'), ('xxx'), ('www'), ('yyy'), ('www');
|
|
|
|
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
|
2019-02-10 07:54:26 +01:00
|
|
|
WHERE federated.t3.name=t.name;
|
2018-10-09 11:36:09 +02:00
|
|
|
|
|
|
|
EXPLAIN
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
|
2019-02-10 07:54:26 +01:00
|
|
|
WHERE federated.t3.name=t.name;
|
2018-10-09 11:36:09 +02:00
|
|
|
|
|
|
|
EXPLAIN FORMAT=JSON
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
|
2019-02-10 07:54:26 +01:00
|
|
|
WHERE federated.t3.name=t.name;
|
2018-10-09 11:36:09 +02:00
|
|
|
|
|
|
|
ANALYZE
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
|
2019-02-10 07:54:26 +01:00
|
|
|
WHERE federated.t3.name=t.name;
|
2018-10-09 11:36:09 +02:00
|
|
|
|
2019-02-10 07:54:26 +01:00
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT t1.name FROM federated.t1
|
|
|
|
WHERE id IN (SELECT count(*)
|
|
|
|
FROM federated.t2 GROUP BY name)) t
|
|
|
|
WHERE federated.t3.name=t.name;
|
2018-10-09 11:36:09 +02:00
|
|
|
|
2019-02-10 07:54:26 +01:00
|
|
|
EXPLAIN
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT t1.name FROM federated.t1
|
|
|
|
WHERE id IN (SELECT count(*)
|
|
|
|
FROM federated.t2 GROUP BY name)) t
|
|
|
|
WHERE federated.t3.name=t.name;
|
|
|
|
|
|
|
|
--source include/analyze-format.inc
|
|
|
|
ANALYZE FORMAT=JSON
|
|
|
|
SELECT *
|
|
|
|
FROM federated.t3, (SELECT t1.name FROM federated.t1
|
|
|
|
WHERE id IN (SELECT count(*)
|
|
|
|
FROM federated.t2 GROUP BY name)) t
|
|
|
|
WHERE federated.t3.name=t.name;
|
|
|
|
|
|
|
|
SELECT t.id, federated.t3.name
|
|
|
|
FROM federated.t3,
|
|
|
|
( SELECT * FROM federated.t1 WHERE id < 3
|
|
|
|
UNION
|
|
|
|
SELECT * FROM federated.t1 WHERE id >= 5) t
|
|
|
|
WHERE federated.t3.name=t.name;
|
|
|
|
|
|
|
|
EXPLAIN
|
|
|
|
SELECT t.id, federated.t3.name
|
|
|
|
FROM federated.t3,
|
|
|
|
( SELECT * FROM federated.t1 WHERE id < 3
|
|
|
|
UNION
|
|
|
|
SELECT * FROM federated.t1 WHERE id >= 5) t
|
|
|
|
WHERE federated.t3.name=t.name;
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE federated.t1, federated.t2, federated.t3;
|
|
|
|
|
|
|
|
connection slave;
|
2018-10-09 11:36:09 +02:00
|
|
|
DROP TABLE federated.t1, federated.t2;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
|
2019-02-12 23:00:48 +01:00
|
|
|
set global federated_pushdown=0;
|
|
|
|
|
2018-10-09 11:36:09 +02:00
|
|
|
source include/federated_cleanup.inc;
|
2019-02-12 22:11:32 +01:00
|
|
|
|