Bug #28731 UDF Features incomplete
Submitted: 28 May 2007 20:38 Modified: 26 Jul 2007 3:46
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1, 5.0 OS:Other
Assigned to: Paul DuBois CPU Architecture:Any

[28 May 2007 20:38] Roland Bouman
Description:
Hi, 

http://dev.mysql.com/doc/refman/5.1/en/udf-features.html

"Functions can return string, integer, or real values."

is incomplete 
- decimal type ignored
- same is true for arguments

How to repeat:
na

Suggested fix:
change to 

"Functions can accept and return string, integer, real or decimal values."
[28 May 2007 20:55] MySQL Verification Team
Thank you for the bug report.
[1 Jun 2007 17:42] Paul DuBois
UDFs cannot return DECIMAL values, unless something has changed.

http://dev.mysql.com/doc/refman/5.0/en/create-function.html:

"As of MySQL 5.0.3, DECIMAL is a legal value after RETURNS, but currently DECIMAL functions return string values and should be written like STRING functions."

Similarly for arguments. http://dev.mysql.com/doc/refman/5.0/en/udf-arguments.html:

"Arguments of type DECIMAL_RESULT are passed as strings, so you should handle them like STRING_RESULT values."
[1 Jun 2007 21:14] Roland Bouman
Hi Paul,

well, for the return value, you have a point. However, I found that when passing a decimal type value to a UDF, the arg->arg_types[x] entry does contain a value equal to DECIMAL_RESULT.
[26 Jul 2007 3:46] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

The manual says:

"Functions can return string, integer, or real values."

I will change this to:

"Functions can return string, integer, or real values, and can accept
arguments of those same types."

It remains true that DECIMAL_RESULT arguments should be passed as strings.
You *could* pass a value that's encoded like the DECIMAL data type, but
all that means is that its bits won't be changed when it gets transmitted
to the UDF.  The UDF itself is still expected to treat it like a string.
At least, I can find no indication otherwise, either in the manual or
in discussion with Serg.

The type value of DECIMAL_RESULT doesn't get changed to STRING_RESULT,
true. But the manual does say that DECIMAL_RESULT is an allowable argument
type.

I will also change this:

"Arguments of type DECIMAL_RESULT are passed as strings, so you should handle them like STRING_RESULT values."

To:

"Arguments of type DECIMAL_RESULT should be passed as strings, and you should handle them the same way as STRING_RESULT values."

Which (I hope) makes it a little clearer that DECIMAL_RESULT is equivalent to STRING_RESULT.