summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <dkatz@damien-katzs-computer.local>2007-08-05 21:37:55 -0400
committerunknown <dkatz@damien-katzs-computer.local>2007-08-05 21:37:55 -0400
commitccb32a59465eb502d6e292e5f074dcade1ec7fa8 (patch)
tree9172987b105bf8879768d7b8a20358ca9da23be1 /sql/item_func.cc
parent8ab9412a3203cd746f126d4a559d1d172d720516 (diff)
downloadmariadb-git-ccb32a59465eb502d6e292e5f074dcade1ec7fa8.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. 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.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 9a26169ad30..4492b7519aa 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2916,7 +2916,8 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
String *res= arguments[i]->val_str(&buffers[i]);
if (arguments[i]->null_value)
continue;
- f_args.args[i]= (char*) res->ptr();
+ f_args.args[i]= (char*) res->c_ptr();
+ f_args.lengths[i]= res->length();
break;
}
case INT_RESULT: