summaryrefslogtreecommitdiff
path: root/mysql-test/t/federated_server.test
blob: 3e47d9bc95d45221442523028c863ec6070dd04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# WL #3031 This test tests the new servers table as well as
# if federated can utilise the servers table
# should work with embedded server after mysqltest is fixed
-- source include/not_embedded.inc
source include/federated.inc;

connection slave;
create database first_db;
create database second_db;

use first_db;

DROP TABLE IF EXISTS first_db.t1;
CREATE TABLE first_db.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  DEFAULT CHARSET=latin1;

use second_db;
DROP TABLE IF EXISTS second_db.t1;
CREATE TABLE second_db.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  DEFAULT CHARSET=latin1;

connection master;

drop server if exists 'server_one';
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 'server_one' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'first_db',
  USER 'root',
  PASSWORD '',
  PORT $SLAVE_MYPORT,
  SOCKET '',
  OWNER 'root');

drop server if exists 'server_two';
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 'server_two' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'second_db',
  USER 'root',
  PASSWORD '',
  PORT $SLAVE_MYPORT,
  SOCKET '',
  OWNER 'root');

--replace_result $SLAVE_MYPORT SLAVE_PORT
eval select * from mysql.servers;

DROP TABLE IF EXISTS federated.old;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.old (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/first_db/t1';

INSERT INTO federated.old (id, name) values (1, 'federated.old url');

SELECT * FROM federated.old;

DROP TABLE IF EXISTS federated.old2;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.old2 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/second_db/t1';

INSERT INTO federated.old2 (id, name) values (1, 'federated.old2 url');

DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ''
    )
  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
  CONNECTION='server_one';

INSERT INTO federated.t1 (id, name) values (1, 'server_one, new scheme');

SELECT * FROM federated.t1;

ALTER SERVER 'server_one' options(DATABASE 'second_db');

flush tables;

INSERT INTO federated.t1 (id, name) values (1, 'server_two, new scheme');
SELECT * FROM federated.t1;

drop table federated.t1;

drop server 'server_one';
drop server 'server_two';
select * from mysql.servers;

connection slave;
drop table first_db.t1;
drop table second_db.t1;
drop database first_db;
drop database second_db;

source include/federated_cleanup.inc;