Bug #4607 Views: Descriptive information is lost for view definition
Submitted: 18 Jul 2004 23:11 Modified: 14 Jun 2013 0:10
Reporter: Trudy Pelzer Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Assigned Account CPU Architecture:Any

[18 Jul 2004 23:11] Trudy Pelzer
Description:
If one creates a view (e.g. vt1) based exactly on a single underlying table (e.g. t1), the DESCRIBE information should be the same for both. Currently, the "Key" and "Default" information is lost for the view definition. For example:

mysql> describe t1;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| col1  | int(11) |      | PRI | 0       |       |
| col2  | char(5) | YES  |     | hello   |       |
| col3  | int(11) |      | UNI | 0       |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> describe vt1;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| col1  | int(11) |      |     | 0       |       |
| col2  | char(5) | YES  |     | NULL    |       |
| col3  | int(11) |      |     | 0       |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)

How to repeat:
create table t1 (col1 int not null primary key, 
                         col2 char(5) default 'hello', 
                         col3 int not null unique);
create view vt1 as select * from t1;
describe t1;
describe vt1;
[19 Jul 2004 19:11] Aleksey Kishkin
tested on slackware 9
[7 Oct 2004 7:00] Oleksandr Byelkin
Thank you for bugreport. Presence of indexes in VIEW depends on algorithm used for 
VIEW resolving, so it is not so accurate information.
[1 Nov 2005 21:15] Evgeny Potemkin
'Extra' field is also lost. See bug#14493.

If the underlying table is altered, or the index is dropped,
then the view column must also change.

The 'auto_increment' applies for updatable views only.

INFORMATION_SCHEMA.VIEWS needs fixing at the same time.
[1 Nov 2005 21:28] MySQL-Front Team
I can't beleave that a bug which tells invalid results is marked as "Feature request".

Additional I can't beleave MySQL is not interessed to fix a bug with wrong results.

... very poor!!!
[17 May 2006 13:25] Marcello Romani
Oleksandr Byelkin wrote:

> Thank you for bugreport.
> Presence of indexes in VIEW depends on algorithm
> used for VIEW resolving, so it is not so accurate information.

The algorithm that the user can specify when creating a view has no influence on the bug, i.e. the bug shows with all of the values UNDEFINED, MERGE, TEMPTABLE for the ALGORITHM option.
[17 May 2006 14:04] Oleksandr Byelkin
From the other hand view does not have indeces at all, only underlying table has them...