Commit 7043524c authored by unknown's avatar unknown

Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.1-new-maint

into  weblab.(none):/home/marcsql/TREE/mysql-5.1-maint-24736

parents e0a4801a b92081cd
......@@ -386,3 +386,104 @@ select yearweek();
ERROR 42000: Incorrect parameter count in the call to native function 'yearweek'
select yearweek(1, 2, 3);
ERROR 42000: Incorrect parameter count in the call to native function 'yearweek'
select abs(3);
abs(3)
3
select abs(3 AS three);
ERROR 42000: Incorrect parameters in the call to native function 'abs'
select abs(3 three);
ERROR 42000: Incorrect parameters in the call to native function 'abs'
select abs(3 AS "three");
ERROR 42000: Incorrect parameters in the call to native function 'abs'
select abs(3 "three");
ERROR 42000: Incorrect parameters in the call to native function 'abs'
set @bar="bar";
set @foobar="foobar";
select instr("foobar", "bar");
instr("foobar", "bar")
4
select instr("foobar" AS p1, "bar");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar" p1, "bar");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar" AS "p1", "bar");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar" "p1", "bar");
instr("foobar" "p1", "bar")
4
select instr(@foobar "p1", "bar");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar", "bar" AS p2);
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar", "bar" p2);
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar", "bar" AS "p2");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar", "bar" "p2");
instr("foobar", "bar" "p2")
0
select instr("foobar", @bar "p2");
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select instr("foobar" AS p1, "bar" AS p2);
ERROR 42000: Incorrect parameters in the call to native function 'instr'
select conv(255, 10, 16);
conv(255, 10, 16)
FF
select conv(255 AS p1, 10, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255 p1, 10, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255 AS "p1", 10, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255 "p1", 10, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10 AS p2, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10 p2, 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10 AS "p2", 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10 "p2", 16);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10, 16 AS p3);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10, 16 p3);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10, 16 AS "p3");
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255, 10, 16 "p3");
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select conv(255 AS p1, 10 AS p2, 16 AS p3);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select atan(10);
atan(10)
1.4711276743037
select atan(10 AS p1);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 AS "p1");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 "p1");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20);
atan(10, 20)
0.46364760900081
select atan(10 AS p1, 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1, 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 AS "p1", 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 "p1", 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20 AS p2);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20 p2);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20 AS "p2");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20 "p2");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 AS p1, 20 AS p2);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
......@@ -132,9 +132,9 @@ a c
1 1
2 2
SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a;
ERROR 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 'xx) as c FROM t1 GROUP BY a' at line 1
ERROR 42000: Incorrect parameters in the call to stored function 'fn'
SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
ERROR 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 'xx)) as c FROM t1 GROUP BY a' at line 1
ERROR 42000: Incorrect parameters in the call to stored function 'fn'
SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
ERROR 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 'xx)) as c FROM t1 GROUP BY a' at line 1
SELECT myfunc_int(fn(MIN(b)) xx) as c FROM t1 GROUP BY a;
......@@ -185,6 +185,28 @@ DROP VIEW v1;
DROP TABLE t1;
DROP FUNCTION fn;
End of 5.0 tests.
select myfunc_double(3);
myfunc_double(3)
51.00
select myfunc_double(3 AS three);
myfunc_double(3 AS three)
51.00
select myfunc_double(abs(3));
myfunc_double(abs(3))
51.00
select myfunc_double(abs(3) AS named_param);
myfunc_double(abs(3) AS named_param)
51.00
select abs(myfunc_double(3));
abs(myfunc_double(3))
51.00
select abs(myfunc_double(3 AS three));
abs(myfunc_double(3 AS three))
51.00
select myfunc_double(abs(3 AS wrong));
ERROR 42000: Incorrect parameters in the call to native function 'abs'
select abs(myfunc_double(3) AS wrong);
ERROR 42000: Incorrect parameters in the call to native function 'abs'
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
DROP FUNCTION myfunc_nonexist;
......
......@@ -508,3 +508,113 @@ select yearweek();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select yearweek(1, 2, 3);
#
# Bug#24736: UDF functions parsed as Stored Functions
#
# Verify that the syntax for calling UDF : foo(expr AS param, ...)
# can not be used when calling native functions
# Native function with 1 argument
select abs(3);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select abs(3 AS three);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select abs(3 three);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select abs(3 AS "three");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select abs(3 "three");
# Native function with 2 arguments
set @bar="bar";
set @foobar="foobar";
select instr("foobar", "bar");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar" AS p1, "bar");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar" p1, "bar");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar" AS "p1", "bar");
## String concatenation, valid syntax
select instr("foobar" "p1", "bar");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr(@foobar "p1", "bar");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar", "bar" AS p2);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar", "bar" p2);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar", "bar" AS "p2");
## String concatenation, valid syntax
select instr("foobar", "bar" "p2");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar", @bar "p2");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select instr("foobar" AS p1, "bar" AS p2);
# Native function with 3 arguments
select conv(255, 10, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255 AS p1, 10, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255 p1, 10, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255 AS "p1", 10, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255 "p1", 10, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10 AS p2, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10 p2, 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10 AS "p2", 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10 "p2", 16);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10, 16 AS p3);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10, 16 p3);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10, 16 AS "p3");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255, 10, 16 "p3");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select conv(255 AS p1, 10 AS p2, 16 AS p3);
# Native function with a variable number of arguments
select atan(10);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 p1);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS "p1");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 "p1");
select atan(10, 20);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1, 20);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 p1, 20);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS "p1", 20);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 "p1", 20);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10, 20 AS p2);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10, 20 p2);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10, 20 AS "p2");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10, 20 "p2");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1, 20 AS p2);
......@@ -149,9 +149,9 @@ EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1;
EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1;
SELECT a,c FROM v1;
--error ER_PARSE_ERROR
--error ER_WRONG_PARAMETERS_TO_STORED_FCT
SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a;
--error ER_PARSE_ERROR
--error ER_WRONG_PARAMETERS_TO_STORED_FCT
SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
--error ER_PARSE_ERROR
SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
......@@ -173,6 +173,22 @@ DROP FUNCTION fn;
--echo End of 5.0 tests.
#
# Bug#24736: UDF functions parsed as Stored Functions
#
select myfunc_double(3);
select myfunc_double(3 AS three);
select myfunc_double(abs(3));
select myfunc_double(abs(3) AS named_param);
select abs(myfunc_double(3));
select abs(myfunc_double(3 AS three));
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select myfunc_double(abs(3 AS wrong));
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select abs(myfunc_double(3) AS wrong);
#
# Drop the example functions from udf_example
#
......
This diff is collapsed.
......@@ -6010,4 +6010,6 @@ ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000
eng "Incorrect parameter count in the call to native function '%-.64s'"
ER_WRONG_PARAMETERS_TO_NATIVE_FCT 42000
eng "Incorrect parameters in the call to native function '%-.64s'"
ER_WRONG_PARAMETERS_TO_STORED_FCT 42000
eng "Incorrect parameters in the call to stored function '%-.64s'"
......@@ -164,7 +164,6 @@ void lex_start(THD *thd, const uchar *buf, uint length)
lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
lex->select_lex.group_list.empty();
lex->select_lex.order_list.empty();
lex->select_lex.udf_list.empty();
lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE);
lex->sql_command= SQLCOM_END;
lex->duplicates= DUP_ERROR;
......@@ -1176,7 +1175,6 @@ void st_select_lex::init_select()
braces= 0;
when_list.empty();
expr_list.empty();
udf_list.empty();
interval_list.empty();
use_index.empty();
ftfunc_list_alloc.empty();
......
......@@ -609,8 +609,6 @@ class st_select_lex: public st_select_lex_node
/* exclude this select from check of unique_table() */
bool exclude_from_table_unique_test;
List<udf_func> udf_list; /* udf function calls stack */
void init_query();
void init_select();
st_select_lex_unit* master_unit();
......
......@@ -6375,7 +6375,7 @@ function_call_generic:
}
}
/* Temporary placing the result of find_udf in $3 */
lex->current_select->udf_list.push_front(udf);
$<udf>$= udf;
#endif
}
udf_expr_list ')'
......@@ -6403,10 +6403,10 @@ function_call_generic:
{
#ifdef HAVE_DLOPEN
/* Retrieving the result of find_udf */
udf_func *udf;
udf_func *udf= $<udf>3;
LEX *lex= Lex;
if (NULL != (udf= lex->current_select->udf_list.pop()))
if (udf)
{
if (udf->type == UDFTYPE_AGGREGATE)
{
......@@ -6502,7 +6502,6 @@ udf_expr_list3:
udf_expr:
remember_name expr remember_end select_alias
{
udf_func *udf= Select->udf_list.head();
/*
Use Item::name as a storage for the attribute value of user
defined function argument. It is safe to use Item::name
......@@ -6511,20 +6510,10 @@ udf_expr:
*/
if ($4.str)
{
if (!udf)
{
/*
Disallow using AS to specify explicit names for the arguments
of stored routine calls
*/
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
$2->is_autogenerated_name= FALSE;
$2->set_name($4.str, $4.length, system_charset_info);
}
else if (udf)
else
$2->set_name($1, (uint) ($3 - $1), YYTHD->charset());
$$= $2;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment