Bug #48659 CREATE TABLE LIKE <view> gives wrong error message
Submitted: 10 Nov 2009 10:07 Modified: 10 Nov 2009 18:47
Reporter: Sven Sandberg Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Errors Severity:S4 (Feature request)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[10 Nov 2009 10:07] Sven Sandberg
Description:
If v is a view, the statement

  CREATE [TEMPORARY] TABLE [IF NOT EXISTS] t LIKE v

Gives the error message:

  v is not BASE TABLE

However, CREATE ... LIKE v is valid if v is a temporary table. So 'base table' is too narrow. A better error message would be

  v is not a table

How to repeat:
CREATE TEMPORARY TABLE tt (a INT);
CREATE TABLE t1 LIKE tt;

CREATE VIEW v AS SELECT 1;
CREATE TABLE t2 LIKE v;
[10 Nov 2009 18:47] Valeriy Kravchuk
Verified just as described:

77-52-7-73:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.42-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE TEMPORARY TABLE tt (a INT);
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1 LIKE tt;
Query OK, 0 rows affected (0.42 sec)

mysql> CREATE VIEW v AS SELECT 1;
Query OK, 0 rows affected (0.04 sec)

mysql> CREATE TABLE t2 LIKE v;
ERROR 1347 (HY000): 'test.v' is not BASE TABLE