Bug #38159 Function parsing problem generates misleading error message
Submitted: 16 Jul 2008 2:27 Modified: 29 Jun 2009 1:28
Reporter: C. D. Tavares Email Updates:
Status: Closed
Category:Server: Parser Severity:S3 (Non-critical)
Version:5.0.51b, 5.1, 6.0 OS:Any
Assigned to: Georgi Kodinov Target Version:5.1+
Triage: Triaged: D4 (Minor) / E5 (Major)

[16 Jul 2008 2:27] C. D. Tavares
Description:
The following statement

   SELECT MAX (DATE) FROM HISTORY WHERE SERIALNO = "999999";

results in the error message:

   FUNCTION database.max does not exist

As a newbie, this caused me about an hour of puzzlement and analysis time.  I have since
found the explanation for this behavior at
http://dev.mysql.com/doc/refman/5.0/en/function-resolution.html and I understand the
design choice you have made.  As I understand the explanation at that web page, syntactic
ambiguities of SQL make it impossible to determine whether a token is an element name or a
function without resorting to reserved words, and I used the syntax reserved for variable
names.  

HOWEVER, it would have been a lot easier to analyze this failure if the error message had
been more appropriate. The error message indicates that the token was indeed interpreted
as a function (despite your syntax rule), and the function was simply not found.  To
someone unaware of the syntax rule peculiar to your implementation, this is a major act
of misdirection.  Had the error message indicated that the parser could not resolve the
ELEMENT NAME max, it would have been much less frustrating to pinpoint the actual
problem.  Thank you.

How to repeat:
Contained in the problem description
[16 Jul 2008 3:50] Valeriy Kravchuk
Thank you for a problem report. Error message should not be misleading.
[23 Jul 2008 16:48] Marc Alff
Analysis

The issue is related to only a few remaining keywords affected by
SQL_MODE=IGNORE_SPACE

For 5.0, it is impossible to fix IGNORE_SPACE without causing
incompatible changes.

For 5.1, IGNORE_SPACE has been fixed for *most* functions,
but the sum functions (MIN, MAX, etc) are still affected.

the syntax "MAX(...)" and "MAX<space>(...)" cause the confusion.

The effort to fix for 5.1 or 6.0 is Major, setting triage to E5.
The user impact is negligible, setting triage to I5.
setting target version to 6.0+.
[18 May 2009 14:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/74390

2748 Georgi Kodinov	2009-05-18
      Bug #38159: Function parsing problem generates misleading error message
      
      Added a more detailed error message on calling a missing function.
     @ mysql-test/r/ps.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/sp-error.result
        Bug #38159: 
         - fixed existing tests
         - test case
     @ mysql-test/r/trigger.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/udf.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/view.result
        Bug #38159: fixed existing tests
     @ mysql-test/suite/funcs_1/r/innodb_storedproc_10.result
        Bug #38159: fixed existing tests
     @ mysql-test/suite/funcs_1/r/memory_storedproc_10.result
        Bug #38159: fixed existing tests
     @ mysql-test/suite/funcs_1/r/myisam_storedproc_10.result
        Bug #38159: fixed existing tests
     @ mysql-test/suite/funcs_1/storedproc/storedproc_10.inc
        Bug #38159: fixed existing tests
     @ mysql-test/t/ps.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/sp-error.test
        Bug #38159: 
         - fixed existing tests
         - test case
     @ mysql-test/t/trigger.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/udf.test
        Bug #38159: fixed existing tests
     @ sql/item_func.cc
        Bug #38159: generate more detailed error message
     @ sql/share/errmsg.txt
        Bug #38159: add a more detailed error message
     @ sql/sql_derived.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
     @ sql/sql_yacc.yy
        Bug #38159: generate more detailed error message
     @ sql/table.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
[26 May 2009 15:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/74967

2748 Georgi Kodinov	2009-05-26
      Bug #38159: Function parsing problem generates misleading error message
            
      Added a more detailed error message on calling an ambiguous missing function.
     @ mysql-test/r/ps.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/sp-error.result
        Bug #38159: test case
     @ mysql-test/t/ps.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/sp-error.test
        Bug #38159: test case
     @ sql/item_func.cc
        Bug #38159: generate more detailed error message
     @ sql/mysql_priv.h
        Bug #38159: detect if the token is ambiguous and print the appropriate error.
     @ sql/share/errmsg.txt
        Bug #38159: add a more detailed error message
     @ sql/sql_derived.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
     @ sql/sql_lex.cc
        Bug #38159: detect if the token is ambiguous and print the appropriate error.
     @ sql/sql_yacc.yy
        Bug #38159: generate more detailed error message
     @ sql/table.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
[27 May 2009 10:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75040

2748 Georgi Kodinov	2009-05-27
      Bug #38159: Function parsing problem generates misleading error message
      
      Added a more detailed error message on calling an ambiguous missing function.
     @ mysql-test/r/ps.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/sp-error.result
        Bug #38159: test case
     @ mysql-test/t/ps.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/sp-error.test
        Bug #38159: test case
     @ sql/item_func.cc
        Bug #38159: generate more detailed error message
     @ sql/mysql_priv.h
        Bug #38159: detect if the token is ambiguous and print the appropriate error.
     @ sql/share/errmsg.txt
        Bug #38159: add a more detailed error message
     @ sql/sql_derived.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
     @ sql/sql_lex.cc
        Bug #38159: 
        - detect if the token is ambiguous and print the appropriate error.
        - backport is_lex_native_function() from 5.1
     @ sql/sql_yacc.yy
        Bug #38159: generate more detailed error message
     @ sql/table.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
[27 May 2009 13:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75050

2748 Georgi Kodinov	2009-05-27
      Bug #38159: Function parsing problem generates misleading error message
            
      Added a more detailed error message on calling an ambiguous missing function.
     @ mysql-test/r/ps.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/sp-error.result
        Bug #38159: test case
     @ mysql-test/t/ps.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/sp-error.test
        Bug #38159: test case
     @ sql/item_func.cc
        Bug #38159: generate more detailed error message
     @ sql/share/errmsg.txt
        Bug #38159: add a more detailed error message
     @ sql/sql_derived.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
     @ sql/sql_lex.cc
        Bug #38159: 
          - detect if the token is ambiguous and print the appropriate error.
          - backport is_lex_native_function() from 5.1
     @ sql/sql_lex.h
        Bug #38159: detect if the token is ambiguous and print the appropriate error.
     @ sql/sql_yacc.yy
        Bug #38159: generate more detailed error message
     @ sql/table.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
[27 May 2009 13:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75051

2756 Georgi Kodinov	2009-05-27
      Bug #38159: Function parsing problem generates misleading error message
            
      Added a more detailed error message on calling an ambiguous missing function.
     @ mysql-test/r/ps.result
        Bug #38159: fixed existing tests
     @ mysql-test/r/sp-error.result
        Bug #38159: test case
     @ mysql-test/t/ps.test
        Bug #38159: fixed existing tests
     @ mysql-test/t/sp-error.test
        Bug #38159: test case
     @ sql/item_func.cc
        Bug #38159: generate more detailed error message
     @ sql/share/errmsg.txt
        Bug #38159: add a more detailed error message
     @ sql/sql_derived.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
     @ sql/sql_lex.cc
        Bug #38159: 
          - detect if the token is ambiguous and print the appropriate error.
          - backport is_lex_native_function() from 5.1
     @ sql/sql_lex.h
        Bug #38159: detect if the token is ambiguous and print the appropriate error.
     @ sql/sql_yacc.yy
        Bug #38159: generate more detailed error message
     @ sql/table.cc
        Bug #38159: treat the detailed error message the same way as the
        generic one
[16 Jun 2009 11:03] Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090616102155-3zhezogudt4uxdyn) (version source
revid:azundris@mysql.com-20090529164935-xe3dceff53d7pywb) (merge vers: 5.1.36) (pib:6)
[17 Jun 2009 19:25] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version
source revid:azundris@mysql.com-20090529170733-wxq9j0idmss9rllz) (merge vers:
6.0.12-alpha) (pib:11)
[29 Jun 2009 1:28] Paul DuBois
Cosmetic change. No changelog entry needed.
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l)
(version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers:
5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc)
(version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers:
5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4)
(version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers:
5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:33] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr)
(version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers:
5.1.37-ndb-7.0.8) (pib:11)