Bug #24898 No suitable error code for 'resource in use' in DROP/ALTER/RENAME
Submitted: 8 Dec 2006 7:51 Modified: 3 Apr 2009 11:35
Reporter: Jan Lindström Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Errors Severity:S4 (Feature request)
Version:5.0&5.1 OS:Any (Any)
Assigned to: CPU Architecture:Any

[8 Dec 2006 7:51] Jan Lindström
Description:
There is no suitable error code which storage engine could return if a table is currently used while second client issues a DROP/ALTER/RENAME to the same table.

How to repeat:
On first client say:

create table sou1(a int not null, primary key(a)) engine=soliddb comment='MODE=PESSIMISTIC';
insert into sou1 values (1),(2),(3),(4);
commit;
set autocommit = 0;
start transaction;
select * from sou1 for update;

On the second client say:
drop table sou1; // Here 'resouce in use or similar error message should be returned

Suggested fix:
Add a new error message available also for handler interface.
[20 Dec 2006 14:07] Sergei Golubchik
Another - also perfectly logical - behaviour for DROP in the second client, would be to wait on a lock, saying that IX lock on a table is not compatible with "drop lock" (even if there's no physical "drop lock"). Eventually it'll time out and return an error "lock timed out".

You prefer to return an error at once - ok, it could be considered a "nowait" lock, or a lock attempt with zero timeout. Still "lock timed out" error here is appropriate.