Bug #75271 sql parser chokes on extra spaces between (at least some) words
Submitted: 19 Dec 2014 4:25 Modified: 19 Dec 2014 21:36
Reporter: Don Cohen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5.35-log OS:Linux
Assigned to: CPU Architecture:Any

[19 Dec 2014 4:25] Don Cohen
Description:
I assume this is the server though I'm entering sql from the client.

select cg2.timestamp,
 bg2.birth_date,  datediff(cg2.timestamp,bg2.birth_date)/365.24 
from censusgroup cg2,biograph2 bg2 limit 2; 
ERROR 1305 (42000): FUNCTION capuchin. datediff does not exist

I have to reformat the line above to show it, but there were two spaces between 
the comma and the datediff.
The same thing happens with

select count(*) from censusgroup cg2,biograph2 bg2 
   where  datediff(cg2.timestamp,bg2.birth_date)/365.24>5  limit 2; 
=> You have an error in your SQL syntax;
where there are two spaces between where and datediff.
Removing the "extra" space solves the problem.
I'd have thought that an sql parser would allow multiple spaces between words.
And of course, it usually does.

How to repeat:
enter the examples more than once
[19 Dec 2014 15:30] MySQL Verification Team
Please provide the complete test case sql script (create table, insert data and so on). Thanks.
[19 Dec 2014 17:04] Don Cohen
How's this:
MySQL [capuchin]> select 123,  datediff('2001-01-01','2001-01-01'); 
ERROR 1305 (42000): FUNCTION capuchin. datediff does not exist
[19 Dec 2014 18:43] Sveta Smirnova
Thank you for the report.

I cannot repeat described behavior:

mysql> select 123,  datediff('2001-01-01','2001-01-01'); 
+-----+-------------------------------------+
| 123 | datediff('2001-01-01','2001-01-01') |
+-----+-------------------------------------+
| 123 |                                   0 |
+-----+-------------------------------------+
1 row in set (0.00 sec)

Most likely you have hidden character which is not white-space and which caused syntax error. Try to re-type whole statement.
[19 Dec 2014 21:36] Don Cohen
yes, that was it - A0 instead of space
Thank you