[MDEV-11878] Shift/reduce conflict in window_spec clause: OVER (rows ...) Created: 2017-01-23  Updated: 2017-02-02  Resolved: 2017-02-02

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.2
Fix Version/s: 10.2.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: 10.2-ga

Issue Links:
Relates
relates to MDEV-9979 Keywords UNBOUNDED, PRECEDING, FOLLOW... Closed

 Description   

The window_spec clause in sql_yacc.yy has a shift/reduce conflict.

In a query like this:

SELECT .. COUNT(*) OVER (rows ...);

It's not clear what rows stands for. It can be ident in opt_window_ref:

SELECT ... COUNT(*) OVER (rows ORDER BY ...);

or the ROWS keyword in window_frame_units:

SELECT ... COUNT(*) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING);

The conflict happens because ROWS is a non-reserved keyword in MariaDB.

Possible solutions:

  • Make ROWS a reserved keyword, as in the SQL standard
  • Or change the ident part in opt_window_ref to a new rule ident_window_ref which will not include ROWS.


 Comments   
Comment by Igor Babaev [ 2017-01-31 ]

Alexander,
Could you, please, tell me why ROWS is considered as a non-reserved keyword in our parser (as opposed to PRECEDING)?
To my mind window_ref can be ident, and ident can be keyword. So we still have a conflict

Comment by Alexander Barkov [ 2017-01-31 ]

Igor,

I don't know why ROWS is not reserved. It has been non-reserved in MySQL/MariaDB for years. Perhaps it did not cause any conflicts earlier.

PRECEDING must be a non-reserved keyword. See MDEV-9979, which is now in review.

ROWS is a reserved keyword in the SQL standard. I don't mind to make it reserved in MariaDB. But usually we try not to introduce new reserved keywords, unless it's absolutely necessary.

Comment by Igor Babaev [ 2017-01-31 ]

This conflict causes the problems of MDEV-9976.
So I'd rather get rid of it.

Comment by Igor Babaev [ 2017-02-02 ]

This problem was resolved by the patch for the bug mdev-9976.

Generated at Thu Feb 08 07:53:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.