diff --git a/udfs/test/minacum.sql b/udfs/test/minacum.sql index f283fd5..73bb61e 100644 --- a/udfs/test/minacum.sql +++ b/udfs/test/minacum.sql @@ -1,32 +1,34 @@ DROP TEMPORARY TABLE IF EXISTS tData; CREATE TEMPORARY TABLE tData + ENGINE = MEMORY SELECT 1 `group`, 1 `ival`, 10 `num` - UNION SELECT 1, 3, -2 - UNION SELECT 1, 2, 1 - UNION SELECT 1, 3, -1 - UNION SELECT 1, 2, -5 - UNION SELECT 2, '1', 20 - UNION SELECT 2, '3', -5 - UNION SELECT 2, '2', 1 - UNION SELECT 2, '3', 10 - UNION SELECT 2, '2', -6 - UNION SELECT 3, 2, 8 - UNION SELECT 3, 3, 10 - UNION SELECT 4, 2, 10 - UNION SELECT 4, 3, -24 - UNION SELECT 5, NULL, 0 - UNION SELECT 5, NULL, -4 - UNION SELECT 6, 2, NULL - UNION SELECT 6, 3, -8; + UNION SELECT 1, 3, -2 + UNION SELECT 1, 2, 1 + UNION SELECT 1, 3, -1 + UNION SELECT 1, 2, -5 + UNION SELECT 2, '1', 20 + UNION SELECT 2, '3', -5 + UNION SELECT 2, '2', 1 + UNION SELECT 2, '3', 10 + UNION SELECT 2, '2', -6 + UNION SELECT 3, 2, 8 + UNION SELECT 3, 3, 10 + UNION SELECT 4, 2, 10 + UNION SELECT 4, 3, -24 + UNION SELECT 5, NULL, 0 + UNION SELECT 5, NULL, -4 + UNION SELECT 6, 2, NULL + UNION SELECT 6, 3, -8; DROP TEMPORARY TABLE IF EXISTS tExpect; CREATE TEMPORARY TABLE tExpect + ENGINE = MEMORY SELECT 1 `group`, 3 expect - UNION SELECT 2, 15 - UNION SELECT 3, 0 - UNION SELECT 4, -14 - UNION SELECT 5, -4 - UNION SELECT 6, -8; + UNION SELECT 2, 15 + UNION SELECT 3, 0 + UNION SELECT 4, -14 + UNION SELECT 5, -4 + UNION SELECT 6, -8; SELECT e.`group`, r.result, e.expect, r.result <=> e.expect isRight FROM tExpect e diff --git a/udfs/test/multimax.sql b/udfs/test/multimax.sql index d2a1c36..65c63bc 100644 --- a/udfs/test/multimax.sql +++ b/udfs/test/multimax.sql @@ -1,29 +1,31 @@ DROP TEMPORARY TABLE IF EXISTS tData; CREATE TEMPORARY TABLE tData + ENGINE = MEMORY SELECT 1 `group`, 1 `max`, 10 `value` - UNION SELECT 1, 3, 30 - UNION SELECT 1, 2, 20 - UNION SELECT 1, 3, 31 - UNION SELECT 1, 2, 21 - UNION SELECT 2, '4', 40 - UNION SELECT 2, '6', 60 - UNION SELECT 2, '5', 50 - UNION SELECT 2, '6', 61 - UNION SELECT 2, '5', 51 - UNION SELECT 3, 7, 70 - UNION SELECT 3, 9, 90 - UNION SELECT 3, 8, 80 - UNION SELECT 3, 9, NULL - UNION SELECT 3, 8, 81 - UNION SELECT 4, NULL, 101 - UNION SELECT 4, NULL, 102; + UNION SELECT 1, 3, 30 + UNION SELECT 1, 2, 20 + UNION SELECT 1, 3, 31 + UNION SELECT 1, 2, 21 + UNION SELECT 2, '4', 40 + UNION SELECT 2, '6', 60 + UNION SELECT 2, '5', 50 + UNION SELECT 2, '6', 61 + UNION SELECT 2, '5', 51 + UNION SELECT 3, 7, 70 + UNION SELECT 3, 9, 90 + UNION SELECT 3, 8, 80 + UNION SELECT 3, 9, NULL + UNION SELECT 3, 8, 81 + UNION SELECT 4, NULL, 101 + UNION SELECT 4, NULL, 102; DROP TEMPORARY TABLE IF EXISTS tExpect; CREATE TEMPORARY TABLE tExpect + ENGINE = MEMORY SELECT 1 `group`, 31 expect - UNION SELECT 2, 61 - UNION SELECT 3, NULL - UNION SELECT 4, 102; + UNION SELECT 2, 61 + UNION SELECT 3, NULL + UNION SELECT 4, 102; SELECT e.`group`, r.result, e.expect, r.result <=> e.expect isRight FROM tExpect e diff --git a/udfs/test/sql_printf.sql b/udfs/test/sql_printf.sql index ed997a2..12c33d6 100644 --- a/udfs/test/sql_printf.sql +++ b/udfs/test/sql_printf.sql @@ -1,17 +1,18 @@ DROP TEMPORARY TABLE IF EXISTS tData; CREATE TEMPORARY TABLE tData + ENGINE = MEMORY SELECT sql_printf('SELECT %v FROM %t', 1, 'tbl') result, 'SELECT 1 FROM `tbl`' expect - UNION SELECT sql_printf('%v', TRUE), 1 - UNION SELECT sql_printf('%v', 1), 1 - UNION SELECT sql_printf('%v', 'string'), '\'string\'' - UNION SELECT sql_printf('%v', DATE('2020-01-01')), '\'2020-01-01\'' - UNION SELECT sql_printf('%v', NULL), 'NULL' - UNION SELECT sql_printf('%t', 'myTable'), '`myTable`' - UNION SELECT sql_printf('%s', 'expr = TRUE'), 'expr = TRUE' - UNION SELECT sql_printf('%%'), '%' - UNION SELECT sql_printf(NULL), NULL - UNION SELECT sql_printf('SELECT %'), NULL - UNION SELECT sql_printf('SELECT %v'), NULL; + UNION SELECT sql_printf('%v', TRUE), 1 + UNION SELECT sql_printf('%v', 1), 1 + UNION SELECT sql_printf('%v', 'string'), '\'string\'' + UNION SELECT sql_printf('%v', DATE('2020-01-01')), '\'2020-01-01\'' + UNION SELECT sql_printf('%v', NULL), 'NULL' + UNION SELECT sql_printf('%t', 'myTable'), '`myTable`' + UNION SELECT sql_printf('%s', 'expr = TRUE'), 'expr = TRUE' + UNION SELECT sql_printf('%%'), '%' + UNION SELECT sql_printf(NULL), NULL + UNION SELECT sql_printf('SELECT %'), NULL + UNION SELECT sql_printf('SELECT %v'), NULL; SELECT result, expect, result <=> expect isRight FROM tData; diff --git a/udfs/test/udf.sql b/udfs/test/udf.sql index a72c564..ebff509 100644 --- a/udfs/test/udf.sql +++ b/udfs/test/udf.sql @@ -11,11 +11,13 @@ BEGIN WHILE vI < vLoops DO SELECT minacum(2, -10, 1) INTO vRes; + SELECT multimax(10, 20) INTO vRes; + SELECT sql_printf('SELECT %v FROM %t', TRUE, 'myTable') INTO vRes; SET vI = vI + 1; END WHILE; END$$ DELIMITER ; -CALL udf_test(POW(10, 6)); +CALL udf_test(POW(10, 7)); DROP PROCEDURE udf_test;