4

MySQL 服务器版本:5.1.73 源代码分发。

我无法创建函数,删除后它仍然存在。

先删除函数:

mysql> drop function if exists `xapps_f20160817`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+-----------------------------------------+
| Level | Code | Message                                 |
+-------+------+-----------------------------------------+
| Note  | 1305 | FUNCTION xapps_f20160817 does not exist |
+-------+------+-----------------------------------------+
1 row in set (0.00 sec)

但是当我再次创建它时它仍然存在。

mysql> create function `xapps_f20160817`(
    -> `_time` varchar(30),
    -> `_rpid` varchar(10),
    -> `_mvsz` varchar(10),
    -> `_rvsz` varchar(10),
    -> `_ncpu` varchar(10),
    -> `_rcpu` varchar(10),
    -> `_appn` varchar(64)
    -> )  RETURNS BIGINT READS SQL DATA
    -> BEGIN
    -> insert into `20160817`(time, rpid, mvsz, rvsz, ncpu, rcpu, appn)
    -> values(_time, _rpid, _mvsz, _rvsz, _ncpu, _rcpu, _appn);
    -> RETURN LAST_INSERT_ID();
    -> END
ERROR 1304 (42000): FUNCTION xapps_f20160817 already exists

尝试使用:

mysql> select xapps_f20160817('100','100','100','100','100','100','100');$$
ERROR 1305 (42000): FUNCTION xapps_db.xapps_f20160817 does not exist

尝试从函数列表中找到它:

mysql> show function status where name='xapps_f20160817';$$
Empty set (0.00 sec)

尝试删除它,但它不存在:

mysql> drop function if exists `xapps_f20160817`;$$
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;$$
+-------+------+-----------------------------------------+
| Level | Code | Message                                 |
+-------+------+-----------------------------------------+
| Note  | 1305 | FUNCTION xapps_f20160817 does not exist |
+-------+------+-----------------------------------------+
1 row in set (0.01 sec)

它是MySQL的错误吗?如何正确删除此功能?

4

1 回答 1

4

确保您有一个选定的数据库use mydbname;

DROP FUNCTION IF EXISTS myfunc789a;
DELIMITER $$
create function myfunc789a
(   theI INT
)
RETURNS INT
BEGIN
    RETURN theI*7;
END$$
DELIMITER ;

select myfunc789a(8);

DELIMITER 仅在某些客户端工具中使用。不是phpmyadmin。

avec 反引号,没问题 5.6 5.7:

DROP FUNCTION IF EXISTS `myfunc789a`;
DELIMITER $$
create function `myfunc789a`
(   theI INT
)
RETURNS INT
BEGIN
    RETURN theI*7;
END$$
DELIMITER ;

select `myfunc789a`(8);

Bug # 16303

在此处输入图像描述

于 2016-08-17T01:33:07.883 回答