udf.result

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· RESULT 代码 · 共 300 行

RESULT
300
字号
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 function 'myfunc_nonexist' in libraryCREATE 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_lookupRETURNS STRING SONAME "UDF_EXAMPLE_LIB";CREATE AGGREGATE FUNCTION avgcostRETURNS REAL SONAME "UDF_EXAMPLE_LIB";select myfunc_double();ERROR HY000: myfunc_double must have at least one argumentselect myfunc_double(1);myfunc_double(1)49.00select myfunc_double(78654);myfunc_double(78654)54.00select myfunc_nonexist();ERROR 42000: FUNCTION test.myfunc_nonexist does not existselect myfunc_int();myfunc_int()0select lookup();ERROR HY000: Wrong arguments to lookup;  Use the sourceselect lookup("127.0.0.1");lookup("127.0.0.1")127.0.0.1select lookup(127,0,0,1);ERROR HY000: Wrong arguments to lookup;  Use the sourceselect lookup("localhost");lookup("localhost")127.0.0.1select reverse_lookup();ERROR HY000: Wrong number of arguments to reverse_lookup;  Use the sourceselect reverse_lookup("127.0.0.1");select reverse_lookup(127,0,0,1);select reverse_lookup("localhost");reverse_lookup("localhost")NULLselect avgcost();ERROR HY000: wrong number of arguments: AVGCOST() requires two argumentsselect avgcost(100,23.76);ERROR HY000: wrong argument type: AVGCOST() requires an INT and a REALcreate 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.0000delete from t1;insert into t1 values(100, 54.33), (200, 199.99);select avgcost(sum, price) from t1;avgcost(sum, price)151.4367drop table t1;select metaphon('hello');metaphon('hello')HLCREATE PROCEDURE `XXX1`(in testval varchar(10))beginselect metaphon(testval);end//call XXX1('hello');metaphon(testval)HLdrop procedure xxx1;CREATE PROCEDURE `XXX2`()begindeclare testval varchar(10);set testval = 'hello';select metaphon(testval);end//call XXX2();metaphon(testval)HLdrop 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;f49.0050.00NULL51.0052.00SELECT metaphon(v) AS f FROM bug19904;fONTWNULL0RFRDROP TABLE bug19904;CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parseRETURNS STRING SONAME "should_not_parse.so";ERROR HY000: Incorrect usage of SONAME and DEFINERCREATE DEFINER=someone@somewhere FUNCTION should_not_parseRETURNS STRING SONAME "should_not_parse.so";ERROR HY000: Incorrect usage of SONAME and DEFINERcreate 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	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesortdrop table t1;CREATE TABLE t1(a INT, b INT);INSERT INTO t1 values (1,1),(2,2);CREATE FUNCTION fn(a int) RETURNS int DETERMINISTICBEGINRETURN a;END||CREATE VIEW v1 AS SELECT a, fn(MIN(b)) as c FROM t1 GROUP BY a;SELECT myfunc_int(a AS attr_name) FROM t1;myfunc_int(a AS attr_name)12EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Warnings:Note	1003	select myfunc_int(`test`.`t1`.`a` AS `attr_name`) AS `myfunc_int(a AS attr_name)` from `test`.`t1`EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Warnings:Note	1003	select myfunc_int(`test`.`t1`.`a` AS `a`) AS `myfunc_int(a)` from `test`.`t1`SELECT a,c FROM v1;a	c1	12	2SELECT 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 1SELECT 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 1SELECT 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 1SELECT myfunc_int(fn(MIN(b)) xx) as c FROM t1 GROUP BY a;c12SELECT myfunc_int(test.fn(MIN(b)) xx) as c FROM t1 GROUP BY a;c12EXPLAIN EXTENDED SELECT myfunc_int(MIN(b) xx) as c FROM t1 GROUP BY a;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesortWarnings:Note	1003	select myfunc_int(min(`test`.`t1`.`b`) AS `xx`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`EXPLAIN EXTENDED SELECT test.fn(MIN(b)) as c FROM t1 GROUP BY a;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesortWarnings:Note	1003	select `test`.`fn`(min(`test`.`t1`.`b`)) AS `c` from `test`.`t1` group by `test`.`t1`.`a`EXPLAIN EXTENDED SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesortWarnings:Note	1003	select myfunc_int(`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`EXPLAIN EXTENDED SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesortWarnings:Note	1003	select myfunc_int(`test`.`fn`(min(`test`.`t1`.`b`)) AS `test.fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`SELECT myfunc_int(MIN(b) xx) as c FROM t1 GROUP BY a;c12SELECT test.fn(MIN(b)) as c FROM t1 GROUP BY a;c12SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a;c12SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a;c12DROP VIEW v1;DROP TABLE t1;DROP FUNCTION fn;End of 5.0 tests.DROP FUNCTION metaphon;DROP FUNCTION myfunc_double;DROP FUNCTION myfunc_nonexist;ERROR 42000: FUNCTION test.myfunc_nonexist does not existDROP FUNCTION myfunc_int;DROP FUNCTION sequence;DROP FUNCTION lookup;DROP FUNCTION reverse_lookup;DROP FUNCTION avgcost;select * from mysql.func;name	ret	dl	typeCREATE FUNCTION is_const RETURNS STRING SONAME "UDF_EXAMPLE_LIB";select IS_const(3);IS_const(3)constdrop function IS_const;select * from mysql.func;name	ret	dl	typeselect is_const(3);ERROR 42000: FUNCTION test.is_const does not existCREATE FUNCTION is_const RETURNS STRING SONAME "UDF_EXAMPLE_LIB";selectis_const(3) as const,is_const(3.14) as const,is_const('fnord') as const,is_const(2+3) as const,is_const(rand()) as 'nc rand()',is_const(sin(3.14)) as const,is_const(upper('test')) as const;const	const	const	const	nc rand()	const	constconst	const	const	const	not const	const	constcreate table bug18761 (n int);insert into bug18761 values (null),(2);selectis_const(3) as const,is_const(3.14) as const,is_const('fnord') as const,is_const(2+3) as const,is_const(2+n) as 'nc  2+n  ',is_const(sin(n)) as 'nc sin(n)',is_const(sin(3.14)) as const,is_const(upper('test')) as const,is_const(rand()) as 'nc rand()',is_const(n) as 'nc   n   ',is_const(is_const(n)) as 'nc ic?(n)',is_const(is_const('c')) as constfrombug18761;const	const	const	const	nc  2+n  	nc sin(n)	const	const	nc rand()	nc   n   	nc ic?(n)	constconst	const	const	const	not const	not const	const	const	not const	not const	not const	constconst	const	const	const	not const	not const	const	const	not const	not const	not const	constdrop table bug18761;select is_const((1,2,3));ERROR 21000: Operand should contain 1 column(s)drop function if exists is_const;CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";create function f1(p1 varchar(255))returns varchar(255)beginreturn metaphon(p1);end//create function f2(p1 varchar(255))returns doublebeginreturn myfunc_double(p1);end//create function f3(p1 varchar(255))returns doublebeginreturn myfunc_int(p1);end//select f3(NULL);f3(NULL)0select f2(NULL);f2(NULL)NULLselect f1(NULL);f1(NULL)NULLdrop function f1;drop function f2;drop function f3;drop function metaphon;drop function myfunc_double;drop function myfunc_int;CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";create table t1 (a char);set GLOBAL query_cache_size=1355776;reset query cache;select metaphon('MySQL') from t1;metaphon('MySQL')show status like "Qcache_hits";Variable_name	ValueQcache_hits	0show status like "Qcache_queries_in_cache";Variable_name	ValueQcache_queries_in_cache	0select metaphon('MySQL') from t1;metaphon('MySQL')show status like "Qcache_hits";Variable_name	ValueQcache_hits	0show status like "Qcache_queries_in_cache";Variable_name	ValueQcache_queries_in_cache	0drop table t1;drop function metaphon;set GLOBAL query_cache_size=default;End of 5.0 tests.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?