2
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
8
drop table if exists t1;
9
"*** Test 1) Test UDFs via loadable libraries ***
10
"Running on the master"
11
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
13
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
15
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
16
ERROR HY000: Can't find symbol 'myfunc_nonexist' in library
17
SELECT * FROM mysql.func ORDER BY name;
19
myfunc_double 1 UDF_LIB function
20
myfunc_int 2 UDF_LIB function
22
"Running on the slave"
23
SELECT * FROM mysql.func ORDER BY name;
25
myfunc_double 1 UDF_LIB function
26
myfunc_int 2 UDF_LIB function
28
"Running on the master"
29
CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM;
31
INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00));
33
INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00));
35
INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00));
37
INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00));
39
SELECT * FROM t1 ORDER BY sum;
46
"Running on the slave"
47
SELECT * FROM t1 ORDER BY sum;
54
SELECT myfunc_int(25);
58
SELECT myfunc_double(75.00);
62
"Running on the master"
63
DROP FUNCTION myfunc_double;
65
DROP FUNCTION myfunc_int;
67
SELECT * FROM mysql.func ORDER BY name;
70
"Running on the slave"
71
SELECT * FROM mysql.func ORDER BY name;
74
"Running on the master"
77
"*** Test 2) Test UDFs with SQL body ***
78
"Running on the master"
79
CREATE FUNCTION myfuncsql_int(i INT) RETURNS INTEGER DETERMINISTIC RETURN i;
81
CREATE FUNCTION myfuncsql_double(d DOUBLE) RETURNS INTEGER DETERMINISTIC RETURN d * 2.00;
83
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
84
db name type param_list body comment
85
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00
86
test myfuncsql_int FUNCTION i INT RETURN i
88
"Running on the slave"
89
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
90
db name type param_list body comment
91
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00
92
test myfuncsql_int FUNCTION i INT RETURN i
94
"Running on the master"
95
CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM;
97
INSERT INTO t1 VALUES(myfuncsql_int(100), myfuncsql_double(50.00));
99
INSERT INTO t1 VALUES(myfuncsql_int(10), myfuncsql_double(5.00));
101
INSERT INTO t1 VALUES(myfuncsql_int(200), myfuncsql_double(25.00));
103
INSERT INTO t1 VALUES(myfuncsql_int(1), myfuncsql_double(500.00));
105
SELECT * FROM t1 ORDER BY sum;
112
"Running on the slave"
113
SELECT * FROM t1 ORDER BY sum;
120
"Running on the master"
121
ALTER FUNCTION myfuncsql_int COMMENT "This was altered.";
123
ALTER FUNCTION myfuncsql_double COMMENT "This was altered.";
125
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
126
db name type param_list body comment
127
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00 This was altered.
128
test myfuncsql_int FUNCTION i INT RETURN i This was altered.
130
"Running on the slave"
131
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
132
db name type param_list body comment
133
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00 This was altered.
134
test myfuncsql_int FUNCTION i INT RETURN i This was altered.
136
SELECT myfuncsql_int(25);
140
SELECT myfuncsql_double(75.00);
141
myfuncsql_double(75.00)
144
"Running on the master"
145
DROP FUNCTION myfuncsql_double;
147
DROP FUNCTION myfuncsql_int;
149
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
150
db name type param_list body comment
152
"Running on the slave"
153
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
154
db name type param_list body comment
156
"Running on the master"
159
set binlog_format=statement;
160
drop table if exists t1;
161
"*** Test 1) Test UDFs via loadable libraries ***
162
"Running on the master"
163
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
165
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
167
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
168
ERROR HY000: Can't find symbol 'myfunc_nonexist' in library
169
SELECT * FROM mysql.func ORDER BY name;
171
myfunc_double 1 UDF_LIB function
172
myfunc_int 2 UDF_LIB function
174
"Running on the slave"
175
SELECT * FROM mysql.func ORDER BY name;
177
myfunc_double 1 UDF_LIB function
178
myfunc_int 2 UDF_LIB function
180
"Running on the master"
181
CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM;
183
INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00));
185
Warning 1592 Statement is not safe to log in statement format.
187
INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00));
189
Warning 1592 Statement is not safe to log in statement format.
191
INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00));
193
Warning 1592 Statement is not safe to log in statement format.
195
INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00));
197
Warning 1592 Statement is not safe to log in statement format.
199
SELECT * FROM t1 ORDER BY sum;
206
"Running on the slave"
207
SELECT * FROM t1 ORDER BY sum;
214
SELECT myfunc_int(25);
218
SELECT myfunc_double(75.00);
222
"Running on the master"
223
DROP FUNCTION myfunc_double;
225
DROP FUNCTION myfunc_int;
227
SELECT * FROM mysql.func ORDER BY name;
230
"Running on the slave"
231
SELECT * FROM mysql.func ORDER BY name;
234
"Running on the master"
237
"*** Test 2) Test UDFs with SQL body ***
238
"Running on the master"
239
CREATE FUNCTION myfuncsql_int(i INT) RETURNS INTEGER DETERMINISTIC RETURN i;
241
CREATE FUNCTION myfuncsql_double(d DOUBLE) RETURNS INTEGER DETERMINISTIC RETURN d * 2.00;
243
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
244
db name type param_list body comment
245
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00
246
test myfuncsql_int FUNCTION i INT RETURN i
248
"Running on the slave"
249
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
250
db name type param_list body comment
251
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00
252
test myfuncsql_int FUNCTION i INT RETURN i
254
"Running on the master"
255
CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM;
257
INSERT INTO t1 VALUES(myfuncsql_int(100), myfuncsql_double(50.00));
259
INSERT INTO t1 VALUES(myfuncsql_int(10), myfuncsql_double(5.00));
261
INSERT INTO t1 VALUES(myfuncsql_int(200), myfuncsql_double(25.00));
263
INSERT INTO t1 VALUES(myfuncsql_int(1), myfuncsql_double(500.00));
265
SELECT * FROM t1 ORDER BY sum;
272
"Running on the slave"
273
SELECT * FROM t1 ORDER BY sum;
280
"Running on the master"
281
ALTER FUNCTION myfuncsql_int COMMENT "This was altered.";
283
ALTER FUNCTION myfuncsql_double COMMENT "This was altered.";
285
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
286
db name type param_list body comment
287
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00 This was altered.
288
test myfuncsql_int FUNCTION i INT RETURN i This was altered.
290
"Running on the slave"
291
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
292
db name type param_list body comment
293
test myfuncsql_double FUNCTION d DOUBLE RETURN d * 2.00 This was altered.
294
test myfuncsql_int FUNCTION i INT RETURN i This was altered.
296
SELECT myfuncsql_int(25);
300
SELECT myfuncsql_double(75.00);
301
myfuncsql_double(75.00)
304
"Running on the master"
305
DROP FUNCTION myfuncsql_double;
307
DROP FUNCTION myfuncsql_int;
309
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
310
db name type param_list body comment
312
"Running on the slave"
313
SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%' ORDER BY name;
314
db name type param_list body comment
316
"Running on the master"