go-mysql-server
go-mysql-server copied to clipboard
Incorrect Group by syntax passes validation and executes
Hi,
it appears that GMS doesn't correctly validate incorrect GROUP BY queries. For example the SQL below is executed by GMS but its incorrect SQL syntax (i.e. its missing the group by clause).
select C_MKTSEGMENT, count(*) from customer;
explain plain gives -
+--------------------------------------------------------+
| GroupBy |
| ├─ SelectedExprs(customer.C_MKTSEGMENT, COUNT(*))
| ├─ Grouping() |
| └─ Projected table access on [C_MKTSEGMENT]
| └─ Table(customer) |
+--------------------------------------------------------+
FYI the underlying table implements both sql.ProjectedTable and sql.FilteredTable. That probably doesn't matter because the syntax checker should catch the incorrect syntax before it hits the table.
Cheers.