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

Shift/reduce grammar conflict: GRANT .. ON FUNCTION

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.6, 10.11, 11.1(EOL), 11.2, 10.7(EOL), 10.8(EOL), 10.9(EOL), 11.0(EOL), 11.3(EOL)
    • 11.3.0
    • Parser
    • None

    Description

      The grammar in sql_yacc.yy is conflicting in the grant_privileges rule.

      • The keyword FUNCTION is not reserved in MariaDB, it's a valid a table name.
      • The keywotd TABLE is optional in the ON TABLE syntax

      So the sequence "ON FUNCTION" is ambiguous:

      grant_privileges ON FUNCTION f1 TO foo@localhost;
      grant_privileges ON [TABLE] function TO foo@localhost;
      

      It can either be a ON FUNCTION or "ON TABLE function" with

      Here's the bison -rall output:

        222 sp_handler: . FUNCTION_SYM
        223           | . PROCEDURE_SYM
        224           | . PACKAGE_ORACLE_SYM
        225           | . PACKAGE_ORACLE_SYM BODY_ORACLE_SYM
        3405 grant_command: grant_privileges ON . opt_table grant_ident TO_SYM grant_l
        3406              | grant_privileges ON . sp_handler grant_ident TO_SYM grant_
        3419 opt_table: . %empty  [IDENT, IDENT_QUOTED, EMPTY_SYM, JSON_TABLE_SYM, IGN
        3420          | . TABLE_SYM
       
          PACKAGE_ORACLE_SYM  shift, and go to state 2152
          PROCEDURE_SYM       shift, and go to state 2153
          TABLE_SYM           shift, and go to state 2154
          FUNCTION_SYM        shift, and go to state 2155
       
          FUNCTION_SYM  [reduce using rule 3419 (opt_table)]
          $default      reduce using rule 3419 (opt_table)
      

      The same problem is also reported in the REVOKE grammar.

      The opt_table rule should be resolve using %prec. It's empty branch should parse only if the following lookahead token is not FUNCTION_SYM.

      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.