Bug #4600 Views: Drpping and recreating underlying table can cause view column conflict
Submitted: 18 Jul 2004 21:38 Modified: 21 Jul 2004 9:02
Reporter: Trudy Pelzer Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Assigned Account CPU Architecture:Any

[18 Jul 2004 21:38] Trudy Pelzer
Description:
See Bug #4599:
After the crash, I restart the server and select from the view (vt1) which I tried to INSERT into, and MySQL returns this error:
ERROR 1054 (42S22): Unknown column 'db77.t1.col2' in 'field list'

Recall that the crash was caused by creating a table (t1), creating a view based on that table (vt1), dropping the table, recreating the table with a different column name (newcol instead of col2), then trying to INSERT into the view. The error caused by the SELECT shows that the view column list was not updated when the table was recreated.

A better method of handing views would be to drop the view definition completely when the underlying table(s) are dropped -- that way, on table recreation, there can be no conflict with a view definition left over from the obsolete tables.

How to repeat:
mysql> insert into vt1 values('a','aa');
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> use db77;
No connection. Trying to reconnect...
Connection id:    1
Current database: *** NONE ***

Database changed
mysql> select * from vt1;
ERROR 1054 (42S22): Unknown column 'db77.t1.col2' in 'field list'
[21 Jul 2004 9:02] Oleksandr Byelkin
Thank you for bugreport! 
This bug was fixed with Bug#4599.