Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11878

Shift/reduce conflict in window_spec clause: OVER (rows ...)

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL)
    • 10.2.4
    • Parser

    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.

      Attachments

        Issue Links

          Activity

            igor Igor Babaev added a comment -

            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

            igor Igor Babaev added a comment - 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
            bar Alexander Barkov added a comment - - edited

            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.

            bar Alexander Barkov added a comment - - edited 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.
            igor Igor Babaev added a comment -

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

            igor Igor Babaev added a comment - This conflict causes the problems of MDEV-9976 . So I'd rather get rid of it.
            igor Igor Babaev added a comment -

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

            igor Igor Babaev added a comment - This problem was resolved by the patch for the bug mdev-9976.

            People

              igor Igor Babaev
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.