From 80730df7d634e1a620c864d6665d6e66ccad447a Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 27 May 2009 16:05:29 +0300 Subject: 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 --- mysql-test/r/ps.result | 4 ++-- mysql-test/r/sp-error.result | 10 ++++++++++ mysql-test/t/ps.test | 4 ++-- mysql-test/t/sp-error.test | 13 +++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 43c50998e20..e8e75c82b93 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -502,7 +502,7 @@ deallocate prepare stmt; create table t1 (a varchar(20)); insert into t1 values ('foo'); prepare stmt FROM 'SELECT char_length (a) FROM t1'; -ERROR 42000: FUNCTION test.char_length does not exist +ERROR 42000: FUNCTION test.char_length does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual drop table t1; prepare stmt from "SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0"; execute stmt; @@ -1147,7 +1147,7 @@ End of 4.1 tests. create table t1 (a varchar(20)); insert into t1 values ('foo'); prepare stmt FROM 'SELECT char_length (a) FROM t1'; -ERROR 42000: FUNCTION test.char_length does not exist +ERROR 42000: FUNCTION test.char_length does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual drop table t1; create table t1 (a char(3) not null, b char(3) not null, c char(3) not null, primary key (a, b, c)); diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index e83e8c2c71d..bf25f93cceb 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1520,3 +1520,13 @@ CALL p1((SELECT * FROM t1))| ERROR 21000: Subquery returns more than 1 row DROP PROCEDURE IF EXISTS p1| DROP TABLE t1| +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +SELECT MAX (a) FROM t1 WHERE b = 999999; +ERROR 42000: FUNCTION test.MAX does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT AVG (a) FROM t1 WHERE b = 999999; +AVG (a) +NULL +SELECT non_existent (a) FROM t1 WHERE b = 999999; +ERROR 42000: FUNCTION test.non_existent does not exist +DROP TABLE t1; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index d9e593fd76f..99bc198259e 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -530,7 +530,7 @@ deallocate prepare stmt; # create table t1 (a varchar(20)); insert into t1 values ('foo'); ---error 1305 +--error ER_FUNC_INEXISTENT_NAME_COLLISION prepare stmt FROM 'SELECT char_length (a) FROM t1'; drop table t1; @@ -1239,7 +1239,7 @@ drop table t1; # create table t1 (a varchar(20)); insert into t1 values ('foo'); ---error 1305 +--error ER_FUNC_INEXISTENT_NAME_COLLISION prepare stmt FROM 'SELECT char_length (a) FROM t1'; drop table t1; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index c839b1e4374..8143fd56c6d 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2190,3 +2190,16 @@ delimiter ;| #drop procedure if exists bugNNNN| #--enable_warnings #create procedure bugNNNN... + +# +# Bug #38159: Function parsing problem generates misleading error message +# + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +--error ER_FUNC_INEXISTENT_NAME_COLLISION +SELECT MAX (a) FROM t1 WHERE b = 999999; +SELECT AVG (a) FROM t1 WHERE b = 999999; +--error ER_SP_DOES_NOT_EXIST +SELECT non_existent (a) FROM t1 WHERE b = 999999; +DROP TABLE t1; -- cgit v1.2.1