Bug #6859 Bogus error message on attempt to CREATE TABLE t LIKE view
Submitted: 28 Nov 2004 7:01 Modified: 8 Aug 2005 16:12
Reporter: Sergey Petrunya Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:
Assigned to: Georg Richter CPU Architecture:Any

[28 Nov 2004 7:01] Sergey Petrunya
Description:
Attempt to run CREATE TABLE t LIKE someview fails (I'm not sure if it should?) 
with this error message on the client:

ERROR 4 (HY000): Error on close of 'UNOPENED' (Errcode: 9)

And this error message in the server log:
[ERROR] ./mysqld: Incorrect information in file: './testview/t.frm'

Which probably could cause some problems (not sure again, didn't check) and in any 
case the error message is not good.

How to repeat:
create table t1 (a int not null);
drop view v1;  
create view v1 as select * from t1;
create table t2 like v1;

Suggested fix:
Figure out 
 * If CREATE TABLE t LIKE someview should work
 * If not, make the error message explanatory
[27 Jul 2005 15:22] 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/27646
[1 Aug 2005 9:55] 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/27766
[3 Aug 2005 5:31] 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/27837
[7 Aug 2005 2:00] Mike Hillyer
There is no three-part version number present for this fix. Reverting to Patch Approved. Please add an appropriate three-part version number and set back to Documenting status.
[8 Aug 2005 16:12] Mike Hillyer
Documented in 5.0.11 changelog:

<listitem><para>Added error message for users who attempt <literal>CREATE TABLE ... LIKE</literal> and specify a non-table in the <literal>LIKE</literal> clause. (Bug #6859)</para></listitem>
[19 Aug 2008 5:08] Dmitry Lenev
Bug #10355 "Incorrect error displayed if view is used in like clause when creating a table" was marked as duplicate of this bug.