5

MySQL Server version: 5.1.73 Source distribution.

I can't create a function, it is still exists after I drop it.

Drop the function first:

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)

But It still alive when I create it again.

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

Try to use:

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

Try to find it from function list:

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

Try to drop it, but it does not exist:

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)

Is it bug of MySQL? How to remove this function correctly?

informatik01
  • 16,038
  • 10
  • 74
  • 104
J.H
  • 63
  • 1
  • 1
  • 6

1 Answers1

4

Make sure you have a selected db from 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 is used only in some client tools. Not phpmyadmin.

avec backticks, no problem 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:

enter image description here

Drew
  • 24,851
  • 10
  • 43
  • 78