| 1 |
# This test serves as rough measurement of performance of old UDF creation to ne registration |
| 2 |
# of UDFs. The other test, being functional equivalent to this is "udf_reg_3 funcs". |
| 3 |
# Run both tests with "mtr --repeat=9 --suite=service_udf_registration udf udf_reg_3_func". |
| 4 |
# Then compare the run time. Register/unregister must not be slower in average than old style. |
| 5 |
# Functional equivalence: |
| 6 |
# - Create/register 3 UDFS |
| 7 |
# - Use them in exactly same way in both tests |
| 8 |
# - DROP/unregister 3 UDFs. |
| 9 |
# - Verify, that they are not more available. |
| 10 |
# - Create/register them again. |
| 11 |
# - Use myfunc_int and myfunc_double. |
| 12 |
# - Drop/unregister myfunc_int. |
| 13 |
# - Use myfunc_int and myfunc_double (int must fail). |
| 14 |
# - Drop/unregister UDFs. |
| 15 |
|
| 16 |
--source include/have_udf.inc |
| 17 |
|
| 18 |
--disable_warnings |
| 19 |
drop table if exists t1; |
| 20 |
--enable_warnings |
| 21 |
|
| 22 |
# Create 3 UDFS |
| 23 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 24 |
eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; |
| 25 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 26 |
eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; |
| 27 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 28 |
eval CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; |
| 29 |
|
| 30 |
# Use UDFs in exactly same way in both tests |
| 31 |
--error ER_CANT_INITIALIZE_UDF |
| 32 |
SELECT myfunc_double(); |
| 33 |
SELECT myfunc_double(1); |
| 34 |
SELECT myfunc_double(78654); |
| 35 |
SELECT myfunc_int(); |
| 36 |
SELECT myfunc_int(5); |
| 37 |
SELECT myfunc_int('MySQL V8.0'); |
| 38 |
|
| 39 |
CREATE TABLE t1(a INT, b INT); |
| 40 |
INSERT INTO t1 values (1,1),(2,2); |
| 41 |
SELECT myfunc_int(a AS attr_name) FROM t1; |
| 42 |
DROP TABLE t1; |
| 43 |
|
| 44 |
CREATE TABLE t1(sum int, price float(24)); |
| 45 |
INSERT INTO t1 VALUES(100, 50.00), (100, 100.00); |
| 46 |
SELECT avgcost(sum, price) from t1; |
| 47 |
DELETE from t1; |
| 48 |
INSERT INTO t1 VALUES(100, 54.33), (200, 199.99); |
| 49 |
SELECT avgcost(sum, price) from t1; |
| 50 |
DROP TABLE t1; |
| 51 |
|
| 52 |
# DROP 3 UDFs. |
| 53 |
DROP FUNCTION myfunc_double; |
| 54 |
DROP FUNCTION myfunc_int; |
| 55 |
DROP FUNCTION avgcost; |
| 56 |
|
| 57 |
# Verify, that they are not more available. |
| 58 |
--error ER_SP_DOES_NOT_EXIST |
| 59 |
SELECT myfunc_double(1); |
| 60 |
--error ER_SP_DOES_NOT_EXIST |
| 61 |
SELECT myfunc_int(1); |
| 62 |
|
| 63 |
# Create them again. |
| 64 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 65 |
eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; |
| 66 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 67 |
eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; |
| 68 |
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB |
| 69 |
eval CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; |
| 70 |
|
| 71 |
# Use myfunc_int and myfunc_double. |
| 72 |
SELECT myfunc_double(78654); |
| 73 |
SELECT myfunc_int(5); |
| 74 |
|
| 75 |
# Drop myfunc_int. |
| 76 |
DROP FUNCTION myfunc_int; |
| 77 |
|
| 78 |
# Use myfunc_int and myfunc_double (int must fail). |
| 79 |
SELECT myfunc_double(78654); |
| 80 |
--error ER_SP_DOES_NOT_EXIST |
| 81 |
SELECT myfunc_int(5); |
| 82 |
|
| 83 |
# Drop UDFs. |
| 84 |
DROP FUNCTION myfunc_double; |
| 85 |
DROP FUNCTION avgcost; |