| 1 |
SET @old_general_log= @@global.general_log; |
| 2 |
SET @old_log_output= @@global.log_output; |
| 3 |
SET @old_general_log_file= @@global.general_log_file; |
| 4 |
SET global general_log= ON; |
| 5 |
SET global log_output='table'; |
| 6 |
TRUNCATE TABLE mysql.general_log; |
| 7 |
# Simple load test |
| 8 |
INSTALL COMPONENT "file://component_udf_reg_3_func"; |
| 9 |
SELECT myfunc_double(); |
| 10 |
ERROR HY000: Can't initialize function 'myfunc_double'; myfunc_double must have at least one argument |
| 11 |
SELECT myfunc_double(1); |
| 12 |
myfunc_double(1) |
| 13 |
49.00 |
| 14 |
SELECT myfunc_double(78654); |
| 15 |
myfunc_double(78654) |
| 16 |
54.00 |
| 17 |
SELECT myfunc_int(); |
| 18 |
myfunc_int() |
| 19 |
0 |
| 20 |
SELECT myfunc_int(5); |
| 21 |
myfunc_int(5) |
| 22 |
5 |
| 23 |
SELECT myfunc_int('MySQL V8.0'); |
| 24 |
myfunc_int('MySQL V8.0') |
| 25 |
10 |
| 26 |
CREATE TABLE t1(a INT, b INT); |
| 27 |
INSERT INTO t1 values (1,1),(2,2); |
| 28 |
SELECT myfunc_int(a AS attr_name) FROM t1; |
| 29 |
myfunc_int(a AS attr_name) |
| 30 |
1 |
| 31 |
2 |
| 32 |
DROP TABLE t1; |
| 33 |
CREATE TABLE t1(sum int, price float(24)); |
| 34 |
INSERT INTO t1 VALUES(100, 50.00), (100, 100.00); |
| 35 |
SELECT avgcost(sum, price) from t1; |
| 36 |
avgcost(sum, price) |
| 37 |
75.0000 |
| 38 |
DELETE from t1; |
| 39 |
INSERT INTO t1 VALUES(100, 54.33), (200, 199.99); |
| 40 |
SELECT avgcost(sum, price) from t1; |
| 41 |
avgcost(sum, price) |
| 42 |
151.4367 |
| 43 |
DROP TABLE t1; |
| 44 |
# remove the plugin |
| 45 |
UNINSTALL COMPONENT "file://component_udf_reg_3_func"; |
| 46 |
SELECT myfunc_double(1); |
| 47 |
ERROR 42000: FUNCTION test.myfunc_double does not exist |
| 48 |
SELECT myfunc_double(1); |
| 49 |
ERROR 42000: FUNCTION test.myfunc_double does not exist |
| 50 |
INSTALL COMPONENT "file://component_udf_reg_3_func"; |
| 51 |
SELECT myfunc_double(78654); |
| 52 |
myfunc_double(78654) |
| 53 |
54.00 |
| 54 |
SELECT myfunc_int(5); |
| 55 |
myfunc_int(5) |
| 56 |
5 |
| 57 |
INSTALL COMPONENT "file://component_udf_unreg_int_func"; |
| 58 |
UNINSTALL COMPONENT "file://component_udf_unreg_int_func"; |
| 59 |
SELECT myfunc_double(78654); |
| 60 |
myfunc_double(78654) |
| 61 |
54.00 |
| 62 |
SELECT myfunc_int(5); |
| 63 |
ERROR 42000: FUNCTION test.myfunc_int does not exist |
| 64 |
UNINSTALL COMPONENT "file://component_udf_reg_3_func"; |
| 65 |
SET GLOBAL general_log = @old_general_log; |
| 66 |
SET GLOBAL log_output = @old_log_output; |
| 67 |
SET GLOBAL general_log_file = @old_general_log_file; |
| 68 |
select command_type,argument from mysql.general_log WHERE argument LIKE '%myfunc%'; |
| 69 |
command_type argument |
| 70 |
Query SELECT myfunc_double() |
| 71 |
Query SELECT myfunc_double(1) |
| 72 |
Query SELECT myfunc_double(78654) |
| 73 |
Query SELECT myfunc_int() |
| 74 |
Query SELECT myfunc_int(5) |
| 75 |
Query SELECT myfunc_int('MySQL V8.0') |
| 76 |
Query SELECT myfunc_int(a AS attr_name) FROM t1 |
| 77 |
Query SELECT myfunc_double(1) |
| 78 |
Query SELECT myfunc_double(1) |
| 79 |
Query SELECT myfunc_double(78654) |
| 80 |
Query SELECT myfunc_int(5) |
| 81 |
Query SELECT myfunc_double(78654) |
| 82 |
Query SELECT myfunc_int(5) |
| 83 |
TRUNCATE TABLE mysql.general_log; |