go-mysql-server icon indicating copy to clipboard operation
go-mysql-server copied to clipboard

Incorrect Group by syntax passes validation and executes

Open osawyerr opened this issue 3 years ago • 6 comments

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.

osawyerr avatar Jun 12 '22 03:06 osawyerr