~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/r/rpl_user_variables.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
stop slave;
 
2
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 
3
reset master;
 
4
reset slave;
 
5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 
6
start slave;
 
7
reset master;
 
8
create table t1(n char(30));
 
9
set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
 
10
set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
 
11
set @n1:=null;
 
12
set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
 
13
insert into t1 values (@i1), (@i2), (@i3), (@i4);
 
14
insert into t1 values (@r1), (@r2);
 
15
insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
 
16
insert into t1 values (@n1);
 
17
insert into t1 values (@n2);
 
18
insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
 
19
insert into t1 values (@a+(@b:=@a+1));
 
20
set @q:='abc';
 
21
insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
 
22
set @a:=5;
 
23
insert into t1 values (@a),(@a);
 
24
select * from t1 where n = '<nonexistant>';
 
25
n
 
26
insert into t1 values (@a),(@a),(@a*5);
 
27
SELECT * FROM t1 ORDER BY n;
 
28
n
 
29
NULL
 
30
NULL
 
31
NULL
 
32
NULL
 
33
NULL
 
34
 
 
35
-1
 
36
-12.5
 
37
-12345678901234
 
38
0
 
39
0
 
40
1
 
41
12.5
 
42
12345678901234
 
43
2
 
44
5
 
45
5
 
46
5
 
47
abc
 
48
abc'def
 
49
abc'def
 
50
abcn1
 
51
abcn1n2
 
52
abc\def
 
53
This is a test
 
54
SELECT * FROM t1 ORDER BY n;
 
55
n
 
56
NULL
 
57
NULL
 
58
NULL
 
59
NULL
 
60
NULL
 
61
 
 
62
-1
 
63
-12.5
 
64
-12345678901234
 
65
0
 
66
0
 
67
1
 
68
12.5
 
69
12345678901234
 
70
2
 
71
5
 
72
5
 
73
5
 
74
abc
 
75
abc'def
 
76
abc'def
 
77
abcn1
 
78
abcn1n2
 
79
abc\def
 
80
This is a test
 
81
insert into t1 select * FROM (select @var1 union  select @var2) AS t2;
 
82
drop table t1;
 
83
End of 4.1 tests.
 
84
DROP TABLE IF EXISTS t20;
 
85
DROP TABLE IF EXISTS t21;
 
86
DROP PROCEDURE IF EXISTS test.insert;
 
87
CREATE TABLE t20 (a VARCHAR(20));
 
88
CREATE TABLE t21 (a VARCHAR(20));
 
89
CREATE PROCEDURE test.insert()
 
90
BEGIN
 
91
IF (@VAR)
 
92
THEN
 
93
INSERT INTO test.t20 VALUES ('SP_TRUE');
 
94
ELSE
 
95
INSERT INTO test.t20 VALUES ('SP_FALSE');
 
96
END IF;
 
97
END|
 
98
CREATE TRIGGER test.insert_bi BEFORE INSERT
 
99
ON test.t20 FOR EACH ROW
 
100
BEGIN
 
101
IF (@VAR)
 
102
THEN
 
103
INSERT INTO test.t21 VALUES ('TRIG_TRUE');
 
104
ELSE
 
105
INSERT INTO test.t21 VALUES ('TRIG_FALSE');
 
106
END IF;
 
107
END|
 
108
SET @VAR=0;
 
109
CALL test.insert();
 
110
SET @VAR=1;
 
111
CALL test.insert();
 
112
On master: Check the tables for correct data
 
113
SELECT * FROM t20;
 
114
a
 
115
SP_FALSE
 
116
SP_TRUE
 
117
SELECT * FROM t21;
 
118
a
 
119
TRIG_FALSE
 
120
TRIG_TRUE
 
121
On slave: Check the tables for correct data and it matches master
 
122
SELECT * FROM t20;
 
123
a
 
124
SP_FALSE
 
125
SP_TRUE
 
126
SELECT * FROM t21;
 
127
a
 
128
TRIG_FALSE
 
129
TRIG_TRUE
 
130
DROP TABLE t20;
 
131
DROP TABLE t21;
 
132
DROP PROCEDURE test.insert;
 
133
DROP TABLE IF EXISTS t1;
 
134
DROP FUNCTION IF EXISTS test.square;
 
135
CREATE TABLE t1 (i INT);
 
136
CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN 
 
137
(@var * @var);
 
138
SET @var = 1;
 
139
INSERT INTO t1 VALUES (square());
 
140
SET @var = 2;
 
141
INSERT INTO t1 VALUES (square());
 
142
SET @var = 3;
 
143
INSERT INTO t1 VALUES (square());
 
144
SET @var = 4;
 
145
INSERT INTO t1 VALUES (square());
 
146
SET @var = 5;
 
147
INSERT INTO t1 VALUES (square());
 
148
On master: Retrieve the values from the table
 
149
SELECT * FROM t1;
 
150
i
 
151
1
 
152
4
 
153
9
 
154
16
 
155
25
 
156
On slave: Retrieve the values from the table and verify they are the same as on master
 
157
SELECT * FROM t1;
 
158
i
 
159
1
 
160
4
 
161
9
 
162
16
 
163
25
 
164
DROP TABLE t1;
 
165
DROP FUNCTION test.square;
 
166
DROP TABLE IF EXISTS t1;
 
167
DROP FUNCTION IF EXISTS f1;
 
168
DROP FUNCTION IF EXISTS f2;
 
169
CREATE TABLE t1(a int);
 
170
CREATE FUNCTION f1() returns int deterministic BEGIN
 
171
return @a;
 
172
END |
 
173
CREATE FUNCTION f2() returns int deterministic BEGIN
 
174
IF (@b > 0) then
 
175
SET @c = (@a + @b);
 
176
else
 
177
SET @c = (@a - 1);
 
178
END if;
 
179
return @c;
 
180
END |
 
181
SET @a=500;
 
182
INSERT INTO t1 values(f1());
 
183
SET @b = 125;
 
184
SET @c = 1;
 
185
INSERT INTO t1 values(f2());
 
186
On master: Retrieve the values from the table
 
187
SELECT * from t1;
 
188
a
 
189
500
 
190
625
 
191
On slave: Check the tables for correct data and it matches master
 
192
SELECT * from t1;
 
193
a
 
194
500
 
195
625
 
196
DROP TABLE t1;
 
197
DROP FUNCTION f1;
 
198
DROP FUNCTION f2;
 
199
DROP TABLE IF EXISTS t1;
 
200
DROP TABLE IF EXISTS t2;
 
201
CREATE TABLE t1 (i int);
 
202
CREATE TABLE t2 (k int);
 
203
CREATE trigger t1_bi before INSERT on t1 for each row BEGIN
 
204
INSERT INTO t2 values (@a);
 
205
SET @a:=42;
 
206
INSERT INTO t2 values (@a);
 
207
END |
 
208
SET @a:=100;
 
209
INSERT INTO t1 values (5);
 
210
On master: Check to see that data was inserted correctly in both tables
 
211
SELECT * from t1;
 
212
i
 
213
5
 
214
SELECT * from t2;
 
215
k
 
216
100
 
217
42
 
218
On slave: Check the tables for correct data and it matches master
 
219
SELECT * from t1;
 
220
i
 
221
5
 
222
SELECT * from t2;
 
223
k
 
224
100
 
225
42
 
226
drop table t1, t2;
 
227
create table t1(a int, b int);
 
228
prepare s1 from 'insert into t1 values (@x:=@x+1, ?)';
 
229
set @x=1;
 
230
execute s1 using @x;
 
231
select * from t1;
 
232
a       b
 
233
2       1
 
234
select * from t1;
 
235
a       b
 
236
2       1
 
237
drop table t1;
 
238
create table t1(a int);
 
239
insert into t1 values (1),(2);
 
240
prepare s1 from 'insert into t1 select a from t1 limit ?';
 
241
set @x='1.1';
 
242
execute s1 using @x;
 
243
select * from t1;
 
244
a
 
245
1
 
246
2
 
247
1
 
248
select * from t1;
 
249
a
 
250
1
 
251
2
 
252
1
 
253
drop table t1;
 
254
End of 5.0 tests.
 
255
DROP FUNCTION IF EXISTS f1;
 
256
DROP FUNCTION IF EXISTS f2;
 
257
CREATE TABLE t1 (i INT);
 
258
CREATE FUNCTION f1() RETURNS INT RETURN @a;
 
259
CREATE 
 
260
FUNCTION f2() RETURNS INT BEGIN
 
261
INSERT INTO t1 VALUES (10 + @a);
 
262
RETURN 0;
 
263
END|
 
264
SET @a:=123;
 
265
SELECT f1(), f2();
 
266
f1()    f2()
 
267
123     0
 
268
On master: Check to see that data was inserted correctly
 
269
INSERT INTO t1 VALUES(f1());
 
270
SELECT * FROM t1;
 
271
i
 
272
133
 
273
123
 
274
On slave: Check the table for correct data and it matches master
 
275
SELECT * FROM t1;
 
276
i
 
277
133
 
278
123
 
279
DROP FUNCTION f1;
 
280
DROP FUNCTION f2;
 
281
DROP TABLE t1;
 
282
stop slave;