mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
ddb91478e8
into sunlight.local:/local_work/tmp_merge-5.1-opt-mysql client/mysql.cc: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_str.result: Auto merged mysql-test/r/group_min_max.result: Auto merged BitKeeper/deleted/.del-make_win_src_distribution.sh~f80d8fca44e4e5f1: Auto merged BitKeeper/deleted/.del-mysqld.dsp~ffdbf2d234e23e56: Auto merged BitKeeper/deleted/.del-mysqld_ia64.dsp~7f8cf84d81ee04e2: Auto merged BitKeeper/deleted/.del-mysqldump.dsp~a8bd23547d3fc27e: Auto merged BitKeeper/deleted/.del-mysqldump_ia64.dsp~a2aabe898be35b31: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/innodb_mysql.result: Auto merged mysql-test/r/ps_7ndb.result: Auto merged mysql-test/r/type_ranges.result: Auto merged mysql-test/r/udf.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/date_formats.test: Auto merged mysql-test/t/func_gconcat.test: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/group_min_max.test: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/innodb_mysql.test: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/select.test: Auto merged mysql-test/t/sp.test: Auto merged mysql-test/t/view.test: Auto merged sql/field.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_subselect.cc: Auto merged sql/item_subselect.h: Auto merged sql/opt_range.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/time.cc: Auto merged storage/ndb/test/ndbapi/Makefile.am: Auto merged strings/decimal.c: Auto merged mysql-test/r/analyse.result: Manual merge mysql-test/r/bigint.result: Manual merge mysql-test/r/create.result: Manual merge mysql-test/r/information_schema.result: Manual merge mysql-test/r/ps_2myisam.result: Manual merge mysql-test/r/ps_3innodb.result: Manual merge mysql-test/r/ps_4heap.result: Manual merge mysql-test/r/ps_5merge.result: Manual merge mysql-test/r/ps_6bdb.result: Manual merge mysql-test/r/rpl_insert_id.result: Manual merge mysql-test/r/select.result: Manual merge mysql-test/r/sp.result: Manual merge mysql-test/r/subselect.result: Manual merge mysql-test/t/information_schema.test: Manual merge mysql-test/t/rpl_insert_id.test: Manual merge sql/field.h: Manual merge sql/item.cc: Manual merge sql/item.h: Manual merge sql/item_strfunc.h: Manual merge sql/item_sum.cc: Manual merge sql/mysql_priv.h: Manual merge sql/share/errmsg.txt: Manual merge sql/sql_class.h: Manual merge sql/sql_select.cc: Manual merge
111 lines
3.1 KiB
Text
111 lines
3.1 KiB
Text
drop table if exists t1;
|
|
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
|
|
ERROR HY000: Can't find symbol 'myfunc_nonexist' in library
|
|
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE FUNCTION sequence RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE FUNCTION lookup RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE FUNCTION reverse_lookup
|
|
RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
|
|
CREATE AGGREGATE FUNCTION avgcost
|
|
RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
|
|
select myfunc_double();
|
|
ERROR HY000: myfunc_double must have at least one argument
|
|
select myfunc_double(1);
|
|
myfunc_double(1)
|
|
49.00
|
|
select myfunc_double(78654);
|
|
myfunc_double(78654)
|
|
54.00
|
|
select myfunc_nonexist();
|
|
ERROR 42000: FUNCTION test.myfunc_nonexist does not exist
|
|
select myfunc_int();
|
|
myfunc_int()
|
|
0
|
|
select lookup();
|
|
ERROR HY000: Wrong arguments to lookup; Use the source
|
|
select lookup("127.0.0.1");
|
|
lookup("127.0.0.1")
|
|
127.0.0.1
|
|
select lookup(127,0,0,1);
|
|
ERROR HY000: Wrong arguments to lookup; Use the source
|
|
select lookup("localhost");
|
|
lookup("localhost")
|
|
127.0.0.1
|
|
select reverse_lookup();
|
|
ERROR HY000: Wrong number of arguments to reverse_lookup; Use the source
|
|
select reverse_lookup("127.0.0.1");
|
|
select reverse_lookup(127,0,0,1);
|
|
select reverse_lookup("localhost");
|
|
reverse_lookup("localhost")
|
|
NULL
|
|
select avgcost();
|
|
ERROR HY000: wrong number of arguments: AVGCOST() requires two arguments
|
|
select avgcost(100,23.76);
|
|
ERROR HY000: wrong argument type: AVGCOST() requires an INT and a REAL
|
|
create table t1(sum int, price float(24));
|
|
insert into t1 values(100, 50.00), (100, 100.00);
|
|
select avgcost(sum, price) from t1;
|
|
avgcost(sum, price)
|
|
75.0000
|
|
delete from t1;
|
|
insert into t1 values(100, 54.33), (200, 199.99);
|
|
select avgcost(sum, price) from t1;
|
|
avgcost(sum, price)
|
|
151.4367
|
|
drop table t1;
|
|
select metaphon('hello');
|
|
metaphon('hello')
|
|
HL
|
|
CREATE PROCEDURE `XXX1`(in testval varchar(10))
|
|
begin
|
|
select metaphon(testval);
|
|
end//
|
|
call XXX1('hello');
|
|
metaphon(testval)
|
|
HL
|
|
drop procedure xxx1;
|
|
CREATE PROCEDURE `XXX2`()
|
|
begin
|
|
declare testval varchar(10);
|
|
set testval = 'hello';
|
|
select metaphon(testval);
|
|
end//
|
|
call XXX2();
|
|
metaphon(testval)
|
|
HL
|
|
drop procedure xxx2;
|
|
CREATE TABLE bug19904(n INT, v varchar(10));
|
|
INSERT INTO bug19904 VALUES (1,'one'),(2,'two'),(NULL,NULL),(3,'three'),(4,'four');
|
|
SELECT myfunc_double(n) AS f FROM bug19904;
|
|
f
|
|
49.00
|
|
50.00
|
|
NULL
|
|
51.00
|
|
52.00
|
|
SELECT metaphon(v) AS f FROM bug19904;
|
|
f
|
|
ON
|
|
TW
|
|
NULL
|
|
0R
|
|
FR
|
|
DROP TABLE bug19904;
|
|
create table t1(f1 int);
|
|
insert into t1 values(1),(2);
|
|
explain select myfunc_int(f1) from t1 order by 1;
|
|
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 metaphon;
|
|
DROP FUNCTION myfunc_double;
|
|
DROP FUNCTION myfunc_nonexist;
|
|
ERROR 42000: FUNCTION test.myfunc_nonexist does not exist
|
|
DROP FUNCTION myfunc_int;
|
|
DROP FUNCTION sequence;
|
|
DROP FUNCTION lookup;
|
|
DROP FUNCTION reverse_lookup;
|
|
DROP FUNCTION avgcost;
|