Bug #21963 Views doesn't store formatting (line breaks, extra spaces)
Submitted: 1 Sep 2006 11:09 Modified: 2 Sep 2006 9:01
Reporter: Markku Parviainen Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0.22 OS:Solaris (solaris 8 sparc)
Assigned to: CPU Architecture:Any
Tags: formatting, line breaks, procedures, Views

[1 Sep 2006 11:09] Markku Parviainen
Description:
Hi, would it be possible not to remove line breaks and extra spaces on view definition, as it makes any later editing of those views impossible?

My current views are around 30 lines long, and after retrieving them back from mysql, they are all on a single line. Also I find it funny how the output becomes a complete gibberish from all those automatic quote marks and _latin1 or _utf8 additions.

Now I have kept another copy on harddrive for editing, but this "feature" makes it much harder to reverse engineer any existing databases. Mysql query browser is a great tool for editing existing procedures, but again, "views" can't be viewed at all. You can call that ironic.

How to repeat:
mysql> create table a (a int);
Query OK, 0 rows affected (0.04 sec)

mysql> create view b as select *
    -> from a
    -> where a = 0;
Query OK, 0 rows affected (0.01 sec)

mysql> create view b as select a, '0' from a where a = 0;
Query OK, 0 rows affected (0.01 sec)

mysql> show create view b;
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| View | Create View                                                                                                                                                 |
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| b    | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `b` AS select `a`.`a` AS `a`,_latin1'0' AS `0` from `a` where (`a`.`a` = 0) |
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+

Suggested fix:
Don't trim white spaces and line breaks from views.
Mimic functionality from stored procedures.
[1 Sep 2006 11:13] Markku Parviainen
Oh my, copied wrong lines on example part. Supposed to be like this.

mysql> create view b as select a, '0'
    -> from a
    -> where
    ->    a = 0;
Query OK, 0 rows affected (0.03 sec)

mysql> show create view b;
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| View | Create View                                                                                                                                                 |
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| b    | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `b` AS select `a`.`a` AS `a`,_latin1'0' AS `0` from `a` where (`a`.`a` = 0) |
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[2 Sep 2006 9:01] Valeriy Kravchuk
Thank you for a feature reuqst. It is a duplicate of bug #14369, bug #5159, bug #13109, ... One of the "most wanted" features, it seems.