Bug #28776 Aliasing a function in a select statement doesn't require white space.
Submitted: 30 May 2007 13:57 Modified: 30 May 2007 18:26
Reporter: Rolf Martin-Hoster Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[30 May 2007 13:57] Rolf Martin-Hoster
Description:
I accidently mistyped a query and it aliased the function as "l", I would have expected a space to be requird to follow the functon. 

How to repeat:
mysql> select asset_get_root(55093)l;
+-------+
| l     |
+-------+
| 55090 |
+-------+
1 row in set (0.00 sec)

Suggested fix:
Require some type of white space?
[30 May 2007 18:26] Valeriy Kravchuk
I can confirm the behaviour you had described:

mysql> delimiter //
mysql> create function asset_get_root(i int) returns int return i;
    -> //
Query OK, 0 rows affected (0.01 sec)

mysql> select asset_get_root(55093)l//
+-------+
| l     |
+-------+
| 55093 |
+-------+
1 row in set (0.01 sec)

mysql> select asset_get_root(55093) as l//
+-------+
| l     |
+-------+
| 55093 |
+-------+
1 row in set (0.00 sec)

mysql> select now()l//
+---------------------+
| l                   |
+---------------------+
| 2007-05-21 15:33:40 |
+---------------------+
1 row in set (0.01 sec)

But I do not think it is a bug. ')' is enough to understand that function call is finished, and any next word is an alias. Same behaviour is repeatable in Oracle, for example.