Bug #28511 UDF API does not check whether a function exceeds max_length
Submitted: 18 May 2007 8:35
Reporter: Hartmut Holzgraefe Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S4 (Feature request)
Version:5.1.17, probably all OS:Any
Assigned to: CPU Architecture:Any

[18 May 2007 8:35] Hartmut Holzgraefe
Description:
When a UDF returning a string is called it may set the *length output parameter to a value higher than the initid->max_length defined in the UDFs init function without warning. 

This can lead to strange results in some situations where query results may change depending on sort order

How to repeat:
test project will be uploaded to this bugs file section

Suggested fix:
on each call to a UDF check whether the returned length exceeds the previously declared max_length or not, throw at least a warning if it is exceeded

this should have a very small performance impact only
[18 May 2007 13:20] Hartmut Holzgraefe
The same applies to maybe_null being set to zero but the UDF returning NULL values nonetheless