Bug #12329 Bogus error msg when executing PS with stored procedure after SP was re-created
Submitted: 3 Aug 2005 0:12 Modified: 20 Nov 2005 3:19
Reporter: Sergey Petrunya Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:
Assigned to: Dmitry Lenev CPU Architecture:Any

[3 Aug 2005 0:12] Sergey Petrunya
Description:
If one does the following:
prepare a prepared statement that uses an SP
execute the prepared statement
drop/create SP 
execute the preprared statement again
Then on second PS execution one will get  "Table X doesn't exist" error message where X will be various garbage.

How to repeat:
Run the following
create table t1 as select 1 a;
create table t2 as select 1 a;
create procedure sp1() select a from t1;
prepare s from 'call sp1()';
execute s;
drop procedure sp1;
create procedure sp1() select a+100 from t2;
call sp1();
-- (1)
execute s;
And get:
ERROR 1146 (42S02): Table '.' doesn't exist
or 
ERROR 1146 (42S02): Table '.(' doesn't exist
or something like that.

One may or may not observe different "table names" if one runs different queries at point -- (1) in the above test. Perhaps this means that mysqld reads garbage for table name and so potentially could crash.

Suggested fix:
According to our discussion with Dmitri, a prepared statement should be invalidated if 
SP it uses is deleted. And we need an appopriate error message about this.
[28 Oct 2005 15:23] 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/internals/31625
[28 Oct 2005 15:25] Dmitry Lenev
See also similar bug for triggers - bug #13399.
[17 Nov 2005 0:50] 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/internals/32343
[17 Nov 2005 12:55] Dmitry Lenev
Fixed in version 5.0.17 (by the same patch as bug #13399).
[20 Nov 2005 3:19] Paul Dubois
Noted in 5.0.17 changelog.