Bug #16303 erroneus stored procedures and functions should be droppable
Submitted: 9 Jan 2006 16:06 Modified: 7 Feb 2006 0:57
Reporter: Domas Mituzas
Status: Closed
Category:Server: SP Severity:S3 (Non-critical)
Version:5.0.18 OS:Linux (Linux)
Assigned to: Bugs System Target Version:

[9 Jan 2006 16:06] Domas Mituzas
Description:
If a procedure was valid in previous versions, new versions should allow to drop it,
rather than complaining about contents and doing nothing.

How to repeat:
5.0.16:
mysql> show create function test.f1 \G
*************************** 1. row ***************************
       Function: f1
       sql_mode: 
Create Function: CREATE FUNCTION `f1`(a decimal(5,1)) RETURNS decimal(5,1)
begin
DECLARE tc     DECIMAL(3, 9);
return tc;
end
1 row in set (0.00 sec)

5.0.18: 
mysql> show create function f1;
ERROR 1427 (42000): For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column
'').
mysql> drop function f1;
ERROR 1427 (42000): For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column
'').

Suggested fix:
do not do syntax checks on DROP
[25 Jan 2006 15:41] Konstantin Osipov
Bug#14977 has been marked as a duplicate of this bug.
[26 Jan 2006 11:22] Per-Erik Martin
I think this is more serious than P4, as it might prevent upgrading from older versions.

A workaround (until this is fixed):

  delete from mysql.proc where db='mydb' and name='myproc' and type='type';

where 'type' is 'FUNCTION' or 'PROCEDURE'.

Note: Using the system table mysql.proc directly like this is normally not supported,
it's a workaround only. It (of course) requires root privileges.
[26 Jan 2006 13:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/1673
[2 Feb 2006 13:38] Miguel Solorzano
Bug http://bugs.mysql.com/bug.php?id=17012 was marked as duplicate
of this bug.
[2 Feb 2006 14:23] Andrey Hristov
Check if this is ok also for ALTER PROCEDURE/FUNCTION ?
[2 Feb 2006 14:25] Andrey Hristov
+    if ((ret= db_find_routine_aux(thd, type, name, table)) == SP_OK)
+      ret= SP_OK;
+    else
+      ret= SP_KEY_NOT_FOUND;

could be
+    if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK)
+      ret= SP_KEY_NOT_FOUND;
[2 Feb 2006 15:29] Per-Erik Martin
>Check if this is ok also for ALTER PROCEDURE/FUNCTION ?

No, not altering a routine that can't be parsed is meaningless, it can never be used.
(Since the body can't be altered.)
[2 Feb 2006 15:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/2074
[3 Feb 2006 19:57] Konstantin Osipov
Approved by email.
[6 Feb 2006 18:08] Per-Erik Martin
Pushed to bk 5.0.19
[7 Feb 2006 0:57] Mike Hillyer
Documented in 5.0.19 changelog:

      <listitem>
        <para>
          An invalid stored routine could not be dropped. (Bug #16303)
        </para>
      </listitem>