Bug #36813 Some native functions return syntax error instead of incorrect parameter count
Submitted: 20 May 2008 2:35 Modified: 24 Jul 2008 18:07
Reporter: Eric Bergen (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.1,6.0 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[20 May 2008 2:35] Eric Bergen
Description:
Functions that are listed as function_call_keyword functions in sql_yacc.yy return a parse error instead of incorrect parameter count when called with the incorrect number of arguments. 

How to repeat:
Normal function:
mysql> select locate();
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'locate'

Function in function_call_keyword:
mysql> select left();
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[20 May 2008 3:11] Valeriy Kravchuk
Thank you for a problem report. Verified just as described with 5.1.24. It is a (minor) bug at least because of inconsistency...
[24 Jul 2008 18:07] Marc ALFF
In both cases, for "keyword" and "non keyword" functions,
the server is correct to return an error when the number of parameters
does not match the function.

In both cases, the SQLSTATE or the error is 42000

Both errors are technically accurate:
- "Incorrect parameter count"
- "Syntax error"
both point at the root cause, while the former is more accurate than the
later.

If I understand the bug report correctly, the expectation is that the errors
should be identical.

To have an identical error, the server would have to either:

a) return a "Syntax error" for non keyword functions instead of the more
informative "Invalid parameter count" error.
Doing this is clearly not a good change, and should not be implemented.

b) return a more explicit "Incorrect parameter count" for keyword functions.
This can not be implemented, for the very reason that the function names
used in these cases are ... KEYWORDS of the sql language, which by
definition impacts parsing (causing "syntax errors" when the syntax of the
query does not match the language grammar).

It is correct to observe that the error message is different,
but that by itself does not constitute a bug: in both cases, the error
message returned is the expected one, by design choice.

Closing as "Not a bug".

Thanks for the bug report.