1# Replication of character sets.
2# This test will fail if the server/client does not support enough charsets.
3
4source include/master-slave.inc;
5set timestamp=1000000000;
6
7create database mysqltest2 character set latin2;
8set @@character_set_server=latin5;
9create database mysqltest3;
10--disable_query_log
11select "--- --master--" as "";
12--enable_query_log
13show create database mysqltest2;
14show create database mysqltest3;
15--source include/sync_slave_sql_with_master.inc
16--disable_query_log
17select "--- --slave--" as "";
18--enable_query_log
19show create database mysqltest2;
20show create database mysqltest3;
21
22connection master;
23set @@collation_server=armscii8_bin;
24drop database mysqltest3;
25create database mysqltest3;
26--disable_query_log
27select "--- --master--" as "";
28--enable_query_log
29show create database mysqltest3;
30--source include/sync_slave_sql_with_master.inc
31--disable_query_log
32select "--- --slave--" as "";
33--enable_query_log
34show create database mysqltest3;
35
36connection master;
37use mysqltest2;
38create table t1 (a int auto_increment primary key, b varchar(100));
39set character_set_client=cp850, collation_connection=latin2_croatian_ci;
40insert into t1 (b) values(@@character_set_server);
41insert into t1 (b) values(@@collation_server);
42# character_set_database and collation_database are not tested as they
43# needn't be replicated (Bar said in Jan 2005).
44insert into t1 (b) values(@@character_set_client);
45# collation_client does not exist
46insert into t1 (b) values(@@character_set_connection);
47insert into t1 (b) values(@@collation_connection);
48--echo --- --master--
49select * from t1 order by a;
50--source include/sync_slave_sql_with_master.inc
51--echo --- --slave--
52select * from mysqltest2.t1 order by a;
53
54connection master;
55set character_set_client=latin1, collation_connection=latin1_german1_ci;
56truncate table t1;
57insert into t1 (b) values(@@collation_connection);
58insert into t1 (b) values(LEAST("M�ller","Muffler"));
59set collation_connection=latin1_german2_ci;
60insert into t1 (b) values(@@collation_connection);
61insert into t1 (b) values(LEAST("M�ller","Muffler"));
62--echo --- --master--
63select * from t1 order by a;
64--source include/sync_slave_sql_with_master.inc
65--echo --- --slave--
66select * from mysqltest2.t1 order by a;
67
68# Presently charset info is not logged with LOAD DATA but it will
69# change in Jan 2005 when Dmitri pushes his new LOAD DATA,
70# before 5.0.3 goes out. When done, LOAD DATA INFILE should be tested
71# here.
72
73# See if user var is prefixed with collation in binlog and replicated well.
74# Note: replication of user variables is broken as far as derivation is
75# concerned. That's because when we store a user variable in the binlog,
76# we lose its derivation. So later on the slave, it's impossible to
77# know if the collation was explicit or not, so we use DERIVATION_NONE,
78# which provokes error messages (like 'Illegal mix of collation') when
79# we replay the master's INSERT/etc statements.
80connection master;
81set @a= _cp850 'M�ller' collate cp850_general_ci;
82truncate table t1;
83insert into t1 (b) values(collation(@a));
84--echo --- --master--
85select * from t1 order by a;
86--source include/sync_slave_sql_with_master.inc
87--echo --- --slave--
88select * from mysqltest2.t1 order by a;
89
90connection master;
91drop database mysqltest2;
92drop database mysqltest3;
93--source include/sync_slave_sql_with_master.inc
94
95# Check that we can change global.collation_server (since 5.0.3)
96
97set global character_set_server=latin2;
98set global character_set_server=latin1; # back
99connection master;
100set global character_set_server=latin2;
101set global character_set_server=latin1; # back
102
103# Test of wrong character set numbers;
104error 1115;
105set character_set_client=9999999;
106error 1273;
107set collation_server=9999998;
108
109# This one was contributed by Sergey Petrunia (BUG#3943)
110
111use test;
112CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255));
113SET CHARACTER_SET_CLIENT=koi8r,
114 CHARACTER_SET_CONNECTION=cp1251,
115 CHARACTER_SET_RESULTS=koi8r;
116INSERT INTO t1 (c1, c2) VALUES ('��, �� �������','��, �� �������');
117select hex(c1), hex(c2) from t1;
118--source include/sync_slave_sql_with_master.inc
119select hex(c1), hex(c2) from t1;
120
121connection master;
122drop table t1;
123--source include/sync_slave_sql_with_master.inc
124
125#
126#  BUG#6676: Derivation of variables must be correct on slave
127#
128connection master;
129eval create table `t1` (
130  `pk` varchar(10) not null default '',
131  primary key (`pk`)
132) engine=$engine_type default charset=latin1;
133set @p=_latin1 'test';
134update t1 set pk='test' where pk=@p;
135drop table t1;
136
137# End of 4.1 tests
138--source include/rpl_end.inc
139