Bug #11551 | Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE | ||
---|---|---|---|
Submitted: | 24 Jun 2005 18:17 | Modified: | 2 Aug 2006 19:13 |
Reporter: | Matthias Leich | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Views | Severity: | S3 (Non-critical) |
Version: | 5.0 | OS: | |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
[24 Jun 2005 18:17]
Matthias Leich
[6 Jul 2006 19:32]
Trudy Pelzer
Re-verified using 5.1.12-beta-debug. This is a bug because -- since views are just a form of table -- their behaviour should be no different from the behaviour exhibited by tables. Sometimes dropping multiple views does work, though. Consider the following. mysql> select @@version; +-------------------+ | @@version | +-------------------+ | 5.1.12-beta-debug | +-------------------+ mysql> drop table if exists t1,t2; mysql> create table t1 (col1 int); mysql> drop table t1,t2; ERROR 1051 (42S02): Unknown table 't2' mysql> show tables; Empty set (0.00 sec) mysql> create table t1 (col1 int); mysql> drop table t2,t1; ERROR 1051 (42S02): Unknown table 't2' mysql> show tables; Empty set (0.01 sec) Note the difference between the two examples: In the first case, the existing table (t1) comes first in the list of tables to drop. In the second case, the non-existent table (t2) comes first in the list. But, in both cases, table t1 is dropped and MySQL returns an error indicating that table t2 couldn't be dropped because it doesn't exist. This is the correct behaviour. Here's what happens with views: mysql> drop table if exists t1,t2; mysql> drop view if exists vt1,vt2; mysql> create table t1 (col1 int); mysql> create view vt1 as select * from t1; mysql> drop view vt1,vt2; ERROR 1051 (42S02): Unknown table 'tp.vt2' mysql> show tables; +--------------+ | Tables_in_tp | +--------------+ | t1 | +--------------+ 1 row in set (0.00 sec) -- This is the correct behaviour; matching what is done for tables. Although view vt2 doesn't exist, the DROP correctly drops vt1 and returns an error indicating that view vt2 can't be dropped because it doesn't exist. However, when I turn the DROP arguments around: mysql> create view vt1 as select * from t1; mysql> drop view vt2,vt1; ERROR 1051 (42S02): Unknown table 'tp.vt2' mysql> show tables; +--------------+ | Tables_in_tp | +--------------+ | t1 | | vt1 | +--------------+ 2 rows in set (0.00 sec) -- This shows the incorrect behaviour; it doesn't match the equivalent example for tables. That is, when the first argument to DROP VIEW is the view that doesn't exist, MySQL does correctly return an error indicating that view vt2 can't be dropped because it doesn't exist -- but does not drop view vt1, as it should. Suggested fix: Make DROP VIEW behave the same as DROP TABLE. When DROP contains multiple arguments, one or more of which do not exist, DROP the views that do exist and return ERROR 1051 (42S02): Unknown table ... for the non-existent views.
[28 Jul 2006 12:15]
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/9704
[31 Jul 2006 17:56]
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/9844 ChangeSet@1.2222, 2006-07-31 20:56:06+03:00, gkodinov@macbook.gmz +3 -0 Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE made DROP VIEW to continue on error and report an aggregated error at its end. This makes it similar to DROP TABLE.
[2 Aug 2006 18:46]
Evgeny Potemkin
Fixed in 5.0.25, 5.1.12
[2 Aug 2006 19:13]
Paul DuBois
Noted in 5.0.25, 5.1.12 changelogs.