summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2006-11-14 19:34:16 -0700
committerunknown <malff/marcsql@weblab.(none)>2006-11-14 19:34:16 -0700
commit418fd54843a4917a2bd1d00086269d2fd66b65a5 (patch)
tree13d2f576ce27d448e6100afd7ff5df8582d6b753 /mysql-test/r
parent0af0c4432913bedeeaf274d2712c88876ab9c58b (diff)
downloadmariadb-git-418fd54843a4917a2bd1d00086269d2fd66b65a5.tar.gz
Bug#18239 (Possible to overload internal functions with stored functions)
Bug#21025 (misleading error message when creating functions named 'x', or 'y') Bug#22619 (Spaces considered harmful) This change contains a fix to report warnings or errors, and multiple tests cases. Before this fix, name collisions between: - Native functions - User Defined Functions - Stored Functions were not systematically reported, leading to confusing behavior. I) Native / User Defined Function Before this fix, is was possible to create a UDF named "foo", with the same name as a native function "foo", but it was impossible to invoke the UDF, since the syntax "foo()" always refer to the native function. After this fix, creating a UDF fails with an error if there is a name collision with a native function. II) Native / Stored Function Before this fix, is was possible to create a SF named "db.foo", with the same name as a native function "foo", but this was confusing since the syntax "foo()" would refer to the native function. To refer to the Stored Function, the user had to use the "db.foo()" syntax. After this fix, creating a Stored Function reports a warning if there is a name collision with a native function. III) User Defined Function / Stored Function Before this fix, creating a User Defined Function "foo" and a Stored Function "db.foo" are mutually exclusive operations. Whenever the second function is created, an error is reported. However, the test suite did not cover this behavior. After this fix, the behavior is unchanged, and is now covered by test cases. Note that the code change in this patch depends on the fix for Bug 21114. mysql-test/r/sp.result: New test cases. mysql-test/r/udf.result: New test cases. mysql-test/t/sp.test: New test cases. mysql-test/t/udf.test: New test cases. sql/sql_lex.cc: Name collisions with native functions. sql/sql_lex.h: Name collisions with native functions. sql/sql_yacc.yy: Name collisions with native functions. sql/share/errmsg.txt: Name collisions with native functions. mysql-test/r/sp_gis.result: New test cases. mysql-test/t/sp_gis.test: New test cases.
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/sp.result116
-rw-r--r--mysql-test/r/sp_gis.result33
-rw-r--r--mysql-test/r/udf.result16
3 files changed, 165 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index aeccfd9c951..c53656c2546 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -2178,6 +2178,7 @@ set @stamped_time=in_time;
set x=2;
end if;
end|
+set time_zone='+03:00';
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
@@ -5627,4 +5628,119 @@ Called B
drop procedure proc_21462_a|
drop procedure proc_21462_b|
End of 5.0 tests
+Begin of 5.1 tests
+drop function if exists pi;
+create function pi() returns varchar(50)
+return "pie, my favorite desert.";
+Warnings:
+Note 1578 This function 'pi' has the same name as a native function.
+SET @save_sql_mode=@@sql_mode;
+SET SQL_MODE='IGNORE_SPACE';
+select pi(), pi ();
+pi() pi ()
+3.141593 3.141593
+select test.pi(), test.pi ();
+test.pi() test.pi ()
+pie, my favorite desert. pie, my favorite desert.
+Warnings:
+Note 1578 This function 'pi' has the same name as a native function.
+SET SQL_MODE='';
+select pi(), pi ();
+pi() pi ()
+3.141593 3.141593
+select test.pi(), test.pi ();
+test.pi() test.pi ()
+pie, my favorite desert. pie, my favorite desert.
+SET @@sql_mode=@save_sql_mode;
+drop function pi;
+drop function if exists test.database;
+drop function if exists test.current_user;
+drop function if exists test.md5;
+create database nowhere;
+use nowhere;
+drop database nowhere;
+SET @save_sql_mode=@@sql_mode;
+SET SQL_MODE='IGNORE_SPACE';
+select database(), database ();
+database() database ()
+NULL NULL
+select current_user(), current_user ();
+current_user() current_user ()
+root@localhost root@localhost
+select md5("aaa"), md5 ("aaa");
+md5("aaa") md5 ("aaa")
+47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
+SET SQL_MODE='';
+select database(), database ();
+database() database ()
+NULL NULL
+select current_user(), current_user ();
+current_user() current_user ()
+root@localhost root@localhost
+select md5("aaa"), md5 ("aaa");
+md5("aaa") md5 ("aaa")
+47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
+use test;
+create function `database`() returns varchar(50)
+return "Stored function database";
+Warnings:
+Note 1578 This function 'database' has the same name as a native function.
+create function `current_user`() returns varchar(50)
+return "Stored function current_user";
+Warnings:
+Note 1578 This function 'current_user' has the same name as a native function.
+create function md5(x varchar(50)) returns varchar(50)
+return "Stored function md5";
+Warnings:
+Note 1578 This function 'md5' has the same name as a native function.
+SET SQL_MODE='IGNORE_SPACE';
+select database(), database ();
+database() database ()
+test test
+select current_user(), current_user ();
+current_user() current_user ()
+root@localhost root@localhost
+select md5("aaa"), md5 ("aaa");
+md5("aaa") md5 ("aaa")
+47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
+select test.database(), test.database ();
+test.database() test.database ()
+Stored function database Stored function database
+Warnings:
+Note 1578 This function 'database' has the same name as a native function.
+select test.current_user(), test.current_user ();
+test.current_user() test.current_user ()
+Stored function current_user Stored function current_user
+Warnings:
+Note 1578 This function 'current_user' has the same name as a native function.
+select test.md5("aaa"), test.md5 ("aaa");
+test.md5("aaa") test.md5 ("aaa")
+Stored function md5 Stored function md5
+Warnings:
+Note 1578 This function 'md5' has the same name as a native function.
+SET SQL_MODE='';
+select database(), database ();
+database() database ()
+test test
+select current_user(), current_user ();
+current_user() current_user ()
+root@localhost root@localhost
+select md5("aaa"), md5 ("aaa");
+md5("aaa") md5 ("aaa")
+47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
+select test.database(), test.database ();
+test.database() test.database ()
+Stored function database Stored function database
+select test.current_user(), test.current_user ();
+test.current_user() test.current_user ()
+Stored function current_user Stored function current_user
+select test.md5("aaa"), test.md5 ("aaa");
+test.md5("aaa") test.md5 ("aaa")
+Stored function md5 Stored function md5
+SET @@sql_mode=@save_sql_mode;
+drop function test.database;
+drop function test.current_user;
+drop function md5;
+use test;
+End of 5.1 tests
drop table t1,t2;
diff --git a/mysql-test/r/sp_gis.result b/mysql-test/r/sp_gis.result
new file mode 100644
index 00000000000..2d538b52279
--- /dev/null
+++ b/mysql-test/r/sp_gis.result
@@ -0,0 +1,33 @@
+use test;
+drop function if exists a;
+drop function if exists x;
+drop function if exists y;
+create function a() returns int
+return 1;
+create function x() returns int
+return 2;
+Warnings:
+Note 1578 This function 'x' has the same name as a native function.
+create function y() returns int
+return 3;
+Warnings:
+Note 1578 This function 'y' has the same name as a native function.
+select a();
+a()
+1
+select x();
+ERROR 42000: Incorrect parameter count in the call to native function 'x'
+select y();
+ERROR 42000: Incorrect parameter count in the call to native function 'y'
+select x(PointFromText("POINT(10 20)")), y(PointFromText("POINT(10 20)"));
+x(PointFromText("POINT(10 20)")) y(PointFromText("POINT(10 20)"))
+10 20
+select test.a(), test.x(), test.y();
+test.a() test.x() test.y()
+1 2 3
+Warnings:
+Note 1578 This function 'x' has the same name as a native function.
+Note 1578 This function 'y' has the same name as a native function.
+drop function a;
+drop function x;
+drop function y;
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
index a552282fece..851818e7a79 100644
--- a/mysql-test/r/udf.result
+++ b/mysql-test/r/udf.result
@@ -106,6 +106,22 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
drop table t1;
End of 5.0 tests.
+drop function if exists pi;
+CREATE FUNCTION pi RETURNS STRING SONAME "should_not_parse.so";
+ERROR HY000: This function 'pi' has the same name as a native function.
+DROP FUNCTION IF EXISTS metaphon;
+CREATE FUNCTION metaphon(a int) RETURNS int
+return 0;
+CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
+ERROR HY000: Function 'metaphon' already exists
+DROP FUNCTION metaphon;
+CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
+CREATE FUNCTION metaphon(a int) RETURNS int
+return 0;
+ERROR HY000: Function 'metaphon' already exists
+CREATE FUNCTION test.metaphon(a int) RETURNS int
+return 0;
+ERROR HY000: Function 'metaphon' already exists
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
DROP FUNCTION myfunc_nonexist;