Skip to content

Commit 6e3f6b0

Browse files
author
malff/marcsql@weblab.(none)
committed
Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.1-new-maint
into weblab.(none):/home/marcsql/TREE/mysql-5.1-maint-24736
2 parents 32dedbe + 88ba767 commit 6e3f6b0

File tree

9 files changed

+459
-101
lines changed

9 files changed

+459
-101
lines changed

mysql-test/r/parser.result

+101
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,104 @@ select yearweek();
386386
ERROR 42000: Incorrect parameter count in the call to native function 'yearweek'
387387
select yearweek(1, 2, 3);
388388
ERROR 42000: Incorrect parameter count in the call to native function 'yearweek'
389+
select abs(3);
390+
abs(3)
391+
3
392+
select abs(3 AS three);
393+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
394+
select abs(3 three);
395+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
396+
select abs(3 AS "three");
397+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
398+
select abs(3 "three");
399+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
400+
set @bar="bar";
401+
set @foobar="foobar";
402+
select instr("foobar", "bar");
403+
instr("foobar", "bar")
404+
4
405+
select instr("foobar" AS p1, "bar");
406+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
407+
select instr("foobar" p1, "bar");
408+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
409+
select instr("foobar" AS "p1", "bar");
410+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
411+
select instr("foobar" "p1", "bar");
412+
instr("foobar" "p1", "bar")
413+
4
414+
select instr(@foobar "p1", "bar");
415+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
416+
select instr("foobar", "bar" AS p2);
417+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
418+
select instr("foobar", "bar" p2);
419+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
420+
select instr("foobar", "bar" AS "p2");
421+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
422+
select instr("foobar", "bar" "p2");
423+
instr("foobar", "bar" "p2")
424+
0
425+
select instr("foobar", @bar "p2");
426+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
427+
select instr("foobar" AS p1, "bar" AS p2);
428+
ERROR 42000: Incorrect parameters in the call to native function 'instr'
429+
select conv(255, 10, 16);
430+
conv(255, 10, 16)
431+
FF
432+
select conv(255 AS p1, 10, 16);
433+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
434+
select conv(255 p1, 10, 16);
435+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
436+
select conv(255 AS "p1", 10, 16);
437+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
438+
select conv(255 "p1", 10, 16);
439+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
440+
select conv(255, 10 AS p2, 16);
441+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
442+
select conv(255, 10 p2, 16);
443+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
444+
select conv(255, 10 AS "p2", 16);
445+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
446+
select conv(255, 10 "p2", 16);
447+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
448+
select conv(255, 10, 16 AS p3);
449+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
450+
select conv(255, 10, 16 p3);
451+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
452+
select conv(255, 10, 16 AS "p3");
453+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
454+
select conv(255, 10, 16 "p3");
455+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
456+
select conv(255 AS p1, 10 AS p2, 16 AS p3);
457+
ERROR 42000: Incorrect parameters in the call to native function 'conv'
458+
select atan(10);
459+
atan(10)
460+
1.4711276743037
461+
select atan(10 AS p1);
462+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
463+
select atan(10 p1);
464+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
465+
select atan(10 AS "p1");
466+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
467+
select atan(10 "p1");
468+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
469+
select atan(10, 20);
470+
atan(10, 20)
471+
0.46364760900081
472+
select atan(10 AS p1, 20);
473+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
474+
select atan(10 p1, 20);
475+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
476+
select atan(10 AS "p1", 20);
477+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
478+
select atan(10 "p1", 20);
479+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
480+
select atan(10, 20 AS p2);
481+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
482+
select atan(10, 20 p2);
483+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
484+
select atan(10, 20 AS "p2");
485+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
486+
select atan(10, 20 "p2");
487+
ERROR 42000: Incorrect parameters in the call to native function 'atan'
488+
select atan(10 AS p1, 20 AS p2);
489+
ERROR 42000: Incorrect parameters in the call to native function 'atan'

mysql-test/r/udf.result

+24-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ a c
132132
1 1
133133
2 2
134134
SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a;
135-
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
135+
ERROR 42000: Incorrect parameters in the call to stored function 'fn'
136136
SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
137-
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
137+
ERROR 42000: Incorrect parameters in the call to stored function 'fn'
138138
SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
139139
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
140140
SELECT myfunc_int(fn(MIN(b)) xx) as c FROM t1 GROUP BY a;
@@ -185,6 +185,28 @@ DROP VIEW v1;
185185
DROP TABLE t1;
186186
DROP FUNCTION fn;
187187
End of 5.0 tests.
188+
select myfunc_double(3);
189+
myfunc_double(3)
190+
51.00
191+
select myfunc_double(3 AS three);
192+
myfunc_double(3 AS three)
193+
51.00
194+
select myfunc_double(abs(3));
195+
myfunc_double(abs(3))
196+
51.00
197+
select myfunc_double(abs(3) AS named_param);
198+
myfunc_double(abs(3) AS named_param)
199+
51.00
200+
select abs(myfunc_double(3));
201+
abs(myfunc_double(3))
202+
51.00
203+
select abs(myfunc_double(3 AS three));
204+
abs(myfunc_double(3 AS three))
205+
51.00
206+
select myfunc_double(abs(3 AS wrong));
207+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
208+
select abs(myfunc_double(3) AS wrong);
209+
ERROR 42000: Incorrect parameters in the call to native function 'abs'
188210
DROP FUNCTION metaphon;
189211
DROP FUNCTION myfunc_double;
190212
DROP FUNCTION myfunc_nonexist;

mysql-test/t/parser.test

+110
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,113 @@ select yearweek();
508508
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
509509
select yearweek(1, 2, 3);
510510

511+
#
512+
# Bug#24736: UDF functions parsed as Stored Functions
513+
#
514+
515+
# Verify that the syntax for calling UDF : foo(expr AS param, ...)
516+
# can not be used when calling native functions
517+
518+
# Native function with 1 argument
519+
520+
select abs(3);
521+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
522+
select abs(3 AS three);
523+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
524+
select abs(3 three);
525+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
526+
select abs(3 AS "three");
527+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
528+
select abs(3 "three");
529+
530+
# Native function with 2 arguments
531+
532+
set @bar="bar";
533+
set @foobar="foobar";
534+
535+
select instr("foobar", "bar");
536+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
537+
select instr("foobar" AS p1, "bar");
538+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
539+
select instr("foobar" p1, "bar");
540+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
541+
select instr("foobar" AS "p1", "bar");
542+
## String concatenation, valid syntax
543+
select instr("foobar" "p1", "bar");
544+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
545+
select instr(@foobar "p1", "bar");
546+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
547+
select instr("foobar", "bar" AS p2);
548+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
549+
select instr("foobar", "bar" p2);
550+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
551+
select instr("foobar", "bar" AS "p2");
552+
## String concatenation, valid syntax
553+
select instr("foobar", "bar" "p2");
554+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
555+
select instr("foobar", @bar "p2");
556+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
557+
select instr("foobar" AS p1, "bar" AS p2);
558+
559+
# Native function with 3 arguments
560+
561+
select conv(255, 10, 16);
562+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
563+
select conv(255 AS p1, 10, 16);
564+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
565+
select conv(255 p1, 10, 16);
566+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
567+
select conv(255 AS "p1", 10, 16);
568+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
569+
select conv(255 "p1", 10, 16);
570+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
571+
select conv(255, 10 AS p2, 16);
572+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
573+
select conv(255, 10 p2, 16);
574+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
575+
select conv(255, 10 AS "p2", 16);
576+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
577+
select conv(255, 10 "p2", 16);
578+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
579+
select conv(255, 10, 16 AS p3);
580+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
581+
select conv(255, 10, 16 p3);
582+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
583+
select conv(255, 10, 16 AS "p3");
584+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
585+
select conv(255, 10, 16 "p3");
586+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
587+
select conv(255 AS p1, 10 AS p2, 16 AS p3);
588+
589+
# Native function with a variable number of arguments
590+
591+
select atan(10);
592+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
593+
select atan(10 AS p1);
594+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
595+
select atan(10 p1);
596+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
597+
select atan(10 AS "p1");
598+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
599+
select atan(10 "p1");
600+
601+
select atan(10, 20);
602+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
603+
select atan(10 AS p1, 20);
604+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
605+
select atan(10 p1, 20);
606+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
607+
select atan(10 AS "p1", 20);
608+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
609+
select atan(10 "p1", 20);
610+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
611+
select atan(10, 20 AS p2);
612+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
613+
select atan(10, 20 p2);
614+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
615+
select atan(10, 20 AS "p2");
616+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
617+
select atan(10, 20 "p2");
618+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
619+
select atan(10 AS p1, 20 AS p2);
620+

mysql-test/t/udf.test

+18-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1;
149149
EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1;
150150
SELECT a,c FROM v1;
151151

152-
--error ER_PARSE_ERROR
152+
--error ER_WRONG_PARAMETERS_TO_STORED_FCT
153153
SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a;
154-
--error ER_PARSE_ERROR
154+
--error ER_WRONG_PARAMETERS_TO_STORED_FCT
155155
SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
156156
--error ER_PARSE_ERROR
157157
SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
@@ -173,6 +173,22 @@ DROP FUNCTION fn;
173173

174174
--echo End of 5.0 tests.
175175

176+
#
177+
# Bug#24736: UDF functions parsed as Stored Functions
178+
#
179+
180+
select myfunc_double(3);
181+
select myfunc_double(3 AS three);
182+
select myfunc_double(abs(3));
183+
select myfunc_double(abs(3) AS named_param);
184+
select abs(myfunc_double(3));
185+
select abs(myfunc_double(3 AS three));
186+
187+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
188+
select myfunc_double(abs(3 AS wrong));
189+
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
190+
select abs(myfunc_double(3) AS wrong);
191+
176192
#
177193
# Drop the example functions from udf_example
178194
#

0 commit comments

Comments
 (0)