Bug #71079 Typo in user manual for UDFs
Submitted: 4 Dec 2013 13:24 Modified: 9 Dec 2013 16:12
Reporter: Sveta Smirnova Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.6.15 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[4 Dec 2013 13:24] Sveta Smirnova
Description:
At http://dev.mysql.com/doc/refman/5.6/en/udf-arguments.html there is a text:

----<q>----
To make sure that arguments are of a given type and return an error if they are not, check the arg_type array in the initialization function. For example:

if (args->arg_type[0] != STRING_RESULT ||
    args->arg_type[1] != INT_RESULT)
{
    strcpy(message,"XXX() requires a string and an integer");
    return 1;
}
----</q>----

But expression args->arg_type[0] != STRING_RESULT || args->arg_type[1] != INT_RESULT is true only if args->arg_type[0] is of both STRING_RESULT and INT_RESULT which never happens.

How to repeat:
See description

Suggested fix:
if (args->arg_type[0] != STRING_RESULT &&
    args->arg_type[1] != INT_RESULT)
{
    strcpy(message,"XXX() requires a string and an integer");
    return 1;
}
[8 Dec 2013 14:17] Paul DuBois
What you say would be true if the expression tested arg 0 twice, but it doesn't. It tests arg 0 against the required type for arg 0 and arg 1 against the required type for arg 1.
[9 Dec 2013 16:12] Paul DuBois
The suggested fix in the bug report fails only if both arguments are the wrong type. We really want failure if either argument is the wrong type.