Debian Codegraph @

mysql-test/suite/service_udf_registration/t/udf_log_reg_3_func.test

raw
1 # Test of general log of 3 UDFs with registration.
2
3 --source include/no_ps_protocol.inc
4
5 # Save values of log variables.
6 SET @old_general_log= @@global.general_log;
7 SET @old_log_output= @@global.log_output;
8 SET @old_general_log_file= @@global.general_log_file;
9 SET global general_log= ON;
10 SET global log_output='table';
11
12 # Empty general log.
13 TRUNCATE TABLE mysql.general_log;
14
15 # Register 3 UDFs.
16 --echo # Simple load test
17 INSTALL COMPONENT "file://component_udf_reg_3_func";
18
19 # Usage of UDFs.
20 --error ER_CANT_INITIALIZE_UDF
21 SELECT myfunc_double();
22 SELECT myfunc_double(1);
23 SELECT myfunc_double(78654);
24 SELECT myfunc_int();
25 SELECT myfunc_int(5);
26 SELECT myfunc_int('MySQL V8.0');
27
28 CREATE TABLE t1(a INT, b INT);
29 INSERT INTO t1 values (1,1),(2,2);
30 SELECT myfunc_int(a AS attr_name) FROM t1;
31 DROP TABLE t1;
32
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 DELETE from t1;
37 INSERT INTO t1 VALUES(100, 54.33), (200, 199.99);
38 SELECT avgcost(sum, price) from t1;
39 DROP TABLE t1;
40
41 # Unregister UDFs.
42 --echo # remove the plugin
43 UNINSTALL COMPONENT "file://component_udf_reg_3_func";
44
45 # UDFs must nor mor be available.
46 --error ER_SP_DOES_NOT_EXIST
47 SELECT myfunc_double(1);
48 --error ER_SP_DOES_NOT_EXIST
49 SELECT myfunc_double(1);
50
51 # Register uDFs again.
52 INSTALL COMPONENT "file://component_udf_reg_3_func";
53
54 # UDFs again available.
55 SELECT myfunc_double(78654);
56 SELECT myfunc_int(5);
57
58 # Unregister myfunc_int (called in init of component).
59 INSTALL COMPONENT "file://component_udf_unreg_int_func";
60
61 # Unload component.
62 UNINSTALL COMPONENT "file://component_udf_unreg_int_func";
63
64 # myfunc_int nit more available, other UDFs are.
65 SELECT myfunc_double(78654);
66 --error ER_SP_DOES_NOT_EXIST
67 SELECT myfunc_int(5);
68
69 # Unregister all UDFs.
70 UNINSTALL COMPONENT "file://component_udf_reg_3_func";
71
72 # Restore values of log variables.
73 SET GLOBAL general_log = @old_general_log;
74 SET GLOBAL log_output = @old_log_output;
75 SET GLOBAL general_log_file = @old_general_log_file;
76
77 # Show general log for UDFs.
78 select command_type,argument from mysql.general_log WHERE argument LIKE '%myfunc%';
79
80 # Clear general log
81 TRUNCATE TABLE mysql.general_log;