Bug #32480 "Adding a New Native Function" documentation no longer valid in 5.1 manual
Submitted: 18 Nov 2007 16:00 Modified: 11 Jan 2008 4:17
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[18 Nov 2007 16:00] Hartmut Holzgraefe
The "Adding a New Native Function" documentation is at least partially no longer valid for MySQL 5.1 and needs to be rewritten


How to repeat:

  2) If the function prototype is simple (just takes zero, one, two or three 
     arguments), you should in lex.h specify SYM(FUNC_ARGN) (where N is the
     number of arguments) as the second argument in the sql_functions[] array
     and add a function that creates a function object in item_create.cc. 
     Take a look at "ABS" and create_funcs_abs() for an example of this. 

This is true for 5.0, here sql_functions[] looks like

  static SYMBOL sql_functions[] = {
  { "ABS",              F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_abs)},

In 5.1 the array looks like this though:

  static SYMBOL sql_functions[] = {
  { "ADDDATE",          SYM(ADDDATE_SYM)},

so the SYMBOL type definition has changed, there is nothing like FUNC_ARGn any more for example, and ABS is not even part of the sql_functions[] list anymore.

I stopped reading/checking after this point but there are probably even more changes in this area ...

Suggested fix:
Rewrite this part of the documentation
[18 Nov 2007 16:06] Mark Leith
Verifying, documentation does not match reality - though I'm not sure *how* it is changed specifically now, I can see that the documentation differs from the source.
[8 Jan 2008 16:01] Paul DuBois
The changes occurred due to work done by Marc Alff in 5.1.13 to reduce the number of function names that are treated as reserved words:


The changes result in a different procedure for adding new native functions. I have the information from Marc now and will begin updating the manual.
[11 Jan 2008 4:17] 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.

Updated documentation is at:


The first two steps are different from the previous instructions.