Bug #4611 Views: Crash caused by any statement run after Bug#4610
Submitted: 19 Jul 2004 0:44 Modified: 21 Jul 2004 3:10
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

[19 Jul 2004 0:44] Trudy Pelzer
Description:
This bug is related to Bug #4610.

If one creates a view (e.g. v1) based on an aggregate function of one column of a single underlying table (e.g. t), then creates another view (e.g. v2) based on the first view but with a new column name, then a DESCRIBE of the second view returns this error:
You have an error in your SQL syntax; ...

Any subsequent statement causes a crash:
Packets out of order (Found: 2, expected 1)
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
create table t (col1 int,col2 char(2),col3 text,col4 dec);
create view v1 as select count(*) from t where col4 = 2;
create view v2 as select `count(*)` as xx from v1;
describe v2;
describe v1;
Packets out of order (Found: 2, expected 1)
ERROR 2013 (HY000): Lost connection to MySQL server during query
[19 Jul 2004 19:27] Aleksey Kishkin
mysql> create table t (col1 int,col2 char(2),col3 text,col4 dec);
Query OK, 0 rows affected (0.01 sec)

mysql> create view v1 as select count(*) from t where col4 = 2;
Query OK, 0 rows affected (0.00 sec)

mysql> create view v2 as select `count(*)` as xx from v1;
Query OK, 0 rows affected (0.00 sec)

mysql> describe v2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS `xx` from test.v1' at line 1
mysql> describe v1;
+----------+------------+------+-----+---------+-------+
| Field    | Type       | Null | Key | Default | Extra |
+----------+------------+------+-----+---------+-------+
| count(*) | bigint(20) |      |     | 0       |       |
+----------+------------+------+-----+---------+-------+
1 row in set (0.00 sec)
[21 Jul 2004 2:53] Trudy Pelzer
This bug can be closed. Your fix for related Bug#4612 corrected this one too.
[21 Jul 2004 3:10] Oleksandr Byelkin
Thank you for information I changed bug status, now it is duplicate of Bug#4612