Bug #28907 UDF_ARGS->attributes and UDF_ARGS->attribute_lengths not documented
Submitted: 5 Jun 2007 20:31 Modified: 26 Jul 2007 17:18
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:4.1 and beyond OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: udf, UDF_ARGS, UDF_ARGS->attribute_lengths, UDF_ARGS->attributes

[5 Jun 2007 20:31] Roland Bouman
Description:
The description of UDF argument processing at

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

does not describe the attributes and attribute_lenghts members of the UDF_ARGS structure passed to UDFs. 

UDF_ARGS->attributes[n] contains the "name" of the n+1th argument passed to the UDF (n=0 for first argument, n=1 for second and so on and so forth)

UDF_ARGS->attribute_lengths[n] contains the string length of UDF_ARGS->attributes[n]

How to repeat:
select my_udf(expr1, expr2 AS alias1, expr3 alias2)

UDF_ARGS->attributes[0] = "expr1"
UDF_ARGS->attribute_lengths[0] = 5

UDF_ARGS->attributes[1] = "alias1"
UDF_ARGS->attribute_lengths[1] = 6

UDF_ARGS->attributes[2] = "alias2"
UDF_ARGS->attribute_lengths[2] = 6

so, the "name" of an UDF argument is 
- the expression text when no alias is specified
- the alias if an alias is specified.

Aliases may be specified as usual, so the keyword "AS" is optional.
(I believe that passing aliases for function arguments is not part of any standard)

Suggested fix:
Please document this behaviour. It is very convenient in a number of cases, for example when mapping data from the database to another format:

select udf_xml_attributes(column1, column2, ...) 

->

'column1="value of column1" column2="value of column2"'
[5 Jun 2007 20:38] Valeriy Kravchuk
Thank you for a reasonable documentation request.
[26 Jul 2007 17:18] 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.