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

ALTER USER parser definition has wrong parameter order

    XMLWordPrintable

Details

    Description

      toddstoffel escalated a customer concern that ALTER USER IF EXISTS does not appear to function correctly, and inquired if this was a code defect or a documentation defect.

      Local test confirmed that the documented ALTER USER IF EXISTS syntax generated an error.

      Examination of the related KB content showed that the IF EXISTS content was present in the oldest version of the KB page.

      Examination of sql_yacc.yy showed that the token order does not appear to align to the documented and expected behavior. Adjustment of the test query to the token order in sql_yacc.yy confirmed that the ALTER did not generate an error, confirming that this is a problem with the parser grammar. As implemented ALTER USER IF EXISTS is only accepted as ALTER IF EXISTS USER.

      From 10.4.12:

                /* ALTER USER foo is allowed for MySQL compatibility. */
              | ALTER opt_if_exists USER_SYM clear_privileges grant_list
      

      https://github.com/MariaDB/server/blob/mariadb-10.4.12/sql/sql_yacc.yy#L7972

      This is inconsistent with how IF EXISTS is used by other commands. For example, it is DROP USER IF EXISTS, rather than DROP IF EXISTS USER:

              | DROP USER_SYM opt_if_exists clear_privileges user_list
      

      https://github.com/MariaDB/server/blob/mariadb-10.4.12/sql/sql_yacc.yy#L13338

      The expected token order would be:

      ALTER USER_SYM opt_if_exists ...
      

      This defect appears present in 10.2, 10.3, 10.4.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jacob.moorman Jacob Moorman (Inactive)
              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.