for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3

drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;

test select 1
SELECT 1;
1
1
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'f', '2008-07-01 10:21:39'),
(2, 'g', '2000-02-01 00:00:00'),
(3, 'j', '2007-05-04 20:03:11'),
(4, 'i', '2003-10-30 05:01:03'),
(5, 'h', '2001-10-31 23:59:59');

create table with partition and select test
CREATE TABLE ta_l2 (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
SELECT a, b, c FROM tb_l
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a	b	date_format(c, '%Y-%m-%d %H:%i:%s')
1	f	2008-07-01 10:21:39
2	g	2000-02-01 00:00:00
3	j	2007-05-04 20:03:11
4	i	2003-10-30 05:01:03
5	h	2001-10-31 23:59:59

select partition using pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.b = 'g' ORDER BY a.a;
a	b	date_format(a.c, '%Y-%m-%d %H:%i:%s')
2	g	2000-02-01 00:00:00

select partition using index pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.a > 0 AND a.b = 'g' ORDER BY a.a;
a	b	date_format(a.c, '%Y-%m-%d %H:%i:%s')
2	g	2000-02-01 00:00:00

update partition pushdown
UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a	b	date_format(c, '%Y-%m-%d %H:%i:%s')
1	f	2008-07-01 10:21:39
2	g	2000-02-01 00:00:00
3	e	2009-03-03 03:03:03
4	i	2003-10-30 05:01:03
5	h	2001-10-31 23:59:59

update partition index pushdown
UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a	b	date_format(c, '%Y-%m-%d %H:%i:%s')
1	f	2008-07-01 10:21:39
2	g	2000-02-01 00:00:00
3	j	2009-03-03 03:03:03
4	i	2003-10-30 05:01:03
5	h	2001-10-31 23:59:59

delete partition pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
DELETE FROM ta_l2 WHERE b = 'g';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a	b	date_format(c, '%Y-%m-%d %H:%i:%s')
1	f	2008-07-01 10:21:39
3	j	2007-05-04 20:03:11
4	i	2003-10-30 05:01:03
5	h	2001-10-31 23:59:59

delete partition index pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a	b	date_format(c, '%Y-%m-%d %H:%i:%s')
1	f	2008-07-01 10:21:39
3	j	2007-05-04 20:03:11
4	i	2003-10-30 05:01:03
5	h	2001-10-31 23:59:59

deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3

end of test
