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

Shift/reduce conflicts because of SOUNDS_SYM, ESCAPE_SYM, USER_SYM not given precedence

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
    • 10.3.11
    • Parser
    • None

    Description

      bison -v sql_yacc.yy reports some conflicts caused by the fact that SOUNDS_SYM, ESCAPE_SYM, USER_SYM are not given any precedence.

      Summary:

      • SOUNDS_SYM should have the same precedence with LIKE and REGEXP (i.e. should be in the same %left directive with LIKE). It seems it was just forgotten.
      • ESCAPE_SYM should have its own %left directive with a very low precedence, and the empty branch in the opt_escape rule should have even lower precedence than ESCAPE_SYM. The current parser default behavior is to hungry scan all possible expressions between LIKE and the optional ESCAPE clause. Adding precedence as described for empty and non-empty ESCAPE clauses will preserve this behavior and remove conflicts.
      • The "| USER_SYM" line in keyword_sp_var_and_label should have its %prec directive, to treat "USER" as a identifier only if it's not followed by a TEXT_STRING. Similar conflicts were earlier addressed for TRANSACTION_SYM, TIMESTAMP, PERIOD_SYM, SYSTEM (they can also be identifiers, or can have a special meaning).

      The relevant bison -v output pieces:

      State 1019
        ...
        1482          | bit_expr . SOUNDS_SYM LIKE bit_expr
        ...
          SOUNDS_SYM         shift, and go to state 1548
          SOUNDS_SYM  [reduce using rule 1487 (predicate)]
      

      State 1963
       
        1612 function_call_keyword: USER_SYM . '(' ')'
        2366 kill_expr: USER_SYM . user
        2952 keyword_sp_var_and_label: USER_SYM .
       
          USER_SYM                     shift, and go to state 557
          SOUNDS_SYM  [reduce using rule 2952 (keyword_sp_var_and_label)]
      

      State 2183
       
        1483 predicate: bit_expr LIKE mysql_concatenation_expr . opt_escape
        1591 mysql_concatenation_expr: mysql_concatenation_expr . MYSQL_CONCAT_SYM simple_expr
       
          MYSQL_CONCAT_SYM  shift, and go to state 1560
          ESCAPE_SYM        shift, and go to state 2827
       
          MYSQL_CONCAT_SYM  [reduce using rule 1923 (opt_escape)]
          ESCAPE_SYM        [reduce using rule 1923 (opt_escape)]
          $default          reduce using rule 1923 (opt_escape)
       
          opt_escape  go to state 2828
      

      State 2834
       
        1484 predicate: bit_expr not LIKE mysql_concatenation_expr . opt_escape
        1591 mysql_concatenation_expr: mysql_concatenation_expr . MYSQL_CONCAT_SYM simple_expr
       
          MYSQL_CONCAT_SYM  shift, and go to state 1560
          ESCAPE_SYM        shift, and go to state 2827
       
          MYSQL_CONCAT_SYM  [reduce using rule 1923 (opt_escape)]
          ESCAPE_SYM        [reduce using rule 1923 (opt_escape)]
          $default          reduce using rule 1923 (opt_escape)
       
          opt_escape  go to state 3407
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.