Bug #39055 SHOW CREATE TABLE works for views
Submitted: 26 Aug 2008 20:48 Modified: 16 Oct 2012 5:24
Reporter: Alexander Nozdrin Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0/5.1/6.0-TRUNK OS:Any
Assigned to: CPU Architecture:Any

[26 Aug 2008 20:48] Alexander Nozdrin
Description:
"SHOW CREATE TABLE <view name>" actually invokes "SHOW CREATE VIEW <view name>".

How to repeat:
> CREATE VIEW v1 AS SELECT 1;

> show create TABLE v1;
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                             | character_set_client | collation_connection |
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` | latin1               | latin1_swedish_ci    |
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
1 row in set (0.00 sec)

> show create VIEW v1;
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                             | character_set_client | collation_connection |
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` | latin1               | latin1_swedish_ci    |
+------+---------------------------------------------------------------------------------------------------------+----------------------+----------------------+
1 row in set (0.00 sec)

Suggested fix:
Throw an error if SHOW CREATE TABLE is called for a view.
[26 Aug 2008 21:34] MySQL Verification Team
Thank you for the bug reports. Older version presents the same behavior as well.