Bug #33520 Description for UDF aggregate function XXX_add not correct
Submitted: 27 Dec 2007 0:29 Modified: 31 Jul 2008 17:19
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.22 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[27 Dec 2007 0:29] Roland Bouman
Description:
http://dev.mysql.com/doc/refman/5.1/en/udf-aggr-calling.html

reads

"his function is called for all rows that belong to the same group, except for the first row."

I don't think the statement about the first row us true. 

I have this data:

mysql> select * from t;
+------+
| c    |
+------+
|    1 |
|    1 |
|    2 |
|    2 |
|    3 |
+------+
5 rows in set (0.00 sec)

and this function call: 

mysql> select uda_calling_sequence('\0') from t group by c;
+----------------------------+
| uda_calling_sequence('\0') |
+----------------------------+
|                          1 |
|                          1 |
|                          1 |
+----------------------------+
3 rows in set (0.00 sec)

and I see this calling sequence:

How to repeat:
init
1

clear
1
add
1

add
1

row-level
1

clear
1
add
1

add
1

row-level
1

clear
1
add
1

row-level
1

deinit
1

Suggested fix:
Pleas remove the remark concerning the first row. add is called afer clear for each row in the group, whereas the text now suggests it does it for all but the first rows in the group.
[27 Dec 2007 4:20] Valeriy Kravchuk
Thank you for a documentation bug report.
[31 Jul 2008 17:13] Paul DuBois
Confirmed: As of MySQL 4.1.1, you call xxx_clear() rather than xxx_reset(), and then xxx_add() is called for all rows in the group, including the first row.
[31 Jul 2008 17:19] 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.