diff options
author | unknown <dkatz@damien-katzs-computer.local> | 2007-10-17 17:54:11 -0400 |
---|---|---|
committer | unknown <dkatz@damien-katzs-computer.local> | 2007-10-17 17:54:11 -0400 |
commit | 367fc73e3cf8825bdf46ac4c277afe7097652e39 (patch) | |
tree | 081efbee271b95604a78e556a92985046d186533 /mysql-test/t/udf.test | |
parent | 42b6424327763192c7fb4701f0ae93b7a52af89d (diff) | |
download | mariadb-git-367fc73e3cf8825bdf46ac4c277afe7097652e39.tar.gz |
Bug #29804 UDF parameters don't contain correct string length
Previously, UDF *_init functions were passed constant strings with erroneous lengths. The length came from the containing variable's size, not the length of the value itself.
Now the *_init functions get the constant as a null terminated string with the correct length supplied too.
mysql-test/r/udf.result:
Test case to check constants passed UDFs.
mysql-test/t/udf.test:
Test case to check constants passed UDFs.
sql/item_func.cc:
UDF _init functions are now passed the length of the constants, rather than the max length of the var containing the constant.
sql/udf_example.c:
Added check_const_len functions. The check_const_len_init functions checks that lengths of constants are correctly passed.
sql/udf_example.def:
Add new example functions to windows dll export list.
Diffstat (limited to 'mysql-test/t/udf.test')
-rw-r--r-- | mysql-test/t/udf.test | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 14aef3361e4..22b8ed10a49 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -326,4 +326,40 @@ eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; DROP FUNCTION metaphon; USE test; +# +# Bug #29804 UDF parameters don't contain correct string length +# + +CREATE TABLE const_len_bug ( + str_const varchar(4000), + result1 varchar(4000), + result2 varchar(4000) +); + +DELIMITER |; +CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN + set NEW.str_const = 'bar'; + set NEW.result2 = check_const_len(NEW.str_const); +END | + +CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000)) +BEGIN +DECLARE result VARCHAR(4000); +SET result = check_const_len(str_const); +insert into const_len_bug values(str_const, result, ""); +END | +DELIMITER ;| + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION check_const_len RETURNS string SONAME "$UDF_EXAMPLE_LIB"; + +CALL check_const_len_sp("foo"); + +SELECT * from const_len_bug; + +DROP FUNCTION check_const_len; +DROP PROCEDURE check_const_len_sp; +DROP TRIGGER check_const_len_trigger; +DROP TABLE const_len_bug; + --echo End of 5.0 tests. |