Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table #115

Open
kennytm opened this issue Dec 23, 2018 · 3 comments · Fixed by #587
Open

Failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table #115

kennytm opened this issue Dec 23, 2018 · 3 comments · Fixed by #587
Labels
help wanted Extra attention is needed type/new-feature

Comments

@kennytm
Copy link
Contributor

kennytm commented Dec 23, 2018

These SQLs:

select 1 where true;
select 1 group by 1;
select 1 having true;

All return one row with the value 1 on MySQL 8.0 (also tested on PostgreSQL 9.6 and SQLite 3.24 with the same behavior), but failed to parse on TiDB 2.1.1 and master:

mysql> select 1 where true;
ERROR 1105 (HY000): line 1 column 14 near " true" (total length 19)
mysql> select 1 group by 1;
ERROR 1105 (HY000): line 1 column 14 near " by 1" (total length 19)
mysql> select 1 having true;
ERROR 1105 (HY000): line 1 column 15 near " true" (total length 20)

Table-less queries which are correctly accepted by TiDB:

select 1 order by 1;
select 1 limit 1;
@kennytm kennytm added the type/bug Something isn't working label Dec 23, 2018
@zz-jason zz-jason added help wanted Extra attention is needed type/new-feature and removed type/bug Something isn't working labels Oct 21, 2019
@zhenghaoz
Copy link
Contributor

Let me fix it please 😄

@wangggong
Copy link
Contributor

wangggong commented Jul 11, 2020

Hey, I wanna fix this issue. I read the discussion, and wondering:

  1. What is the conclusion of these SQL shown in pr Fixed: failed to parse WHERE / GROUP BY clauses in a SELECT statement without a FROM table #587 :
SELECT @@autocommit limit 1; -- @@autocommit:1 or `@@autocommit limit 1`:1?
select 1 where true group by 1 having 1>0; -- Throw an error? Or just return 1:1?
  1. If the case is going to be fixed, is it ok to just fix the SQL shown in this pr? Or maybe the overwrite of SELECT statement is needed?

If there is a clear conclusion, I'll be happy to fix it if I can. Otherwise maybe I can go out and see other cases ^_^.

PS: I also read doc in mysql (https://dev.mysql.com/doc/refman/8.0/en/select.html), no clear conclusion found.

@kennytm
Copy link
Contributor Author

kennytm commented Jul 11, 2020

Follow MySQL's behavior on doubt.

mysql> SELECT @@autocommit limit 1;
+--------------+
| @@autocommit |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

mysql> select 1 where true group by 1 having 1>0;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.01 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type/new-feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants