mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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. 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 the lengths of constants are correctly passed.
This commit is contained in:
@ -334,4 +334,28 @@ Qcache_queries_in_cache 0
|
||||
drop table t1;
|
||||
drop function metaphon;
|
||||
set GLOBAL query_cache_size=default;
|
||||
CREATE TABLE const_len_bug (
|
||||
str_const varchar(4000),
|
||||
result1 varchar(4000),
|
||||
result2 varchar(4000)
|
||||
);
|
||||
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 |
|
||||
CREATE FUNCTION check_const_len RETURNS string SONAME "UDF_EXAMPLE_LIB";
|
||||
CALL check_const_len_sp("foo");
|
||||
SELECT * from const_len_bug;
|
||||
str_const result1 result2
|
||||
bar Correct length Correct length
|
||||
DROP FUNCTION check_const_len;
|
||||
DROP PROCEDURE check_const_len_sp;
|
||||
DROP TRIGGER check_const_len_trigger;
|
||||
DROP TABLE const_len_bug;
|
||||
End of 5.0 tests.
|
||||
|
Reference in New Issue
Block a user