Bug #28937 SELECT statement does not produce SQL syntax error with trailing junk characters
Submitted: 7 Jun 2007 3:40 Modified: 7 Jun 2007 7:38
Reporter: KB Intl Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.44-BK, 5.0.22, 4.0.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: error, limit, SELECT, SQL Syntax

[7 Jun 2007 3:40] KB Intl
Description:
The following SQL query does not produce a SQL syntax error as expected.

SELECT * FROM TABLE LIMIT5;

The result from the above query is the same as SELECT * FROM TABLE, which has the annoying consequences of returning all rows from the table when making a typo.

Any junk/random collection of characters afterwards produce the same results, eg:

SELECT * FROM TABLE kfjdskfjhsdkfhdskjhfjfhfdjgha;

How to repeat:
1) Connect to mysql server via command line client
2) Execute command
  SELECT * FROM mysql.user LIMIT5;

Suggested fix:
Upon entering invalid SQL syntax mysql should produce ERROR 1064.
[7 Jun 2007 7:38] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Please read carefully about SELECT syntax at http://dev.mysql.com/doc/refman/5.0/en/select.html Especcially pay attention to syntax of table_references at http://dev.mysql.com/doc/refman/5.0/en/join.html