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

confusing error message for SET ROLE INVALID

Details

    Description

      execute immediate set role via script

      MariaDB [(none)]> select version();
      +-----------------+
      | version()       |
      +-----------------+
      | 10.2.34-MariaDB |
      +-----------------+
      1 row in set (0.00 sec)
       
      MariaDB [(none)]> drop role mariadb_dump_import_role;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [(none)]> Bye
      [dan@linux build-mariadb-server-10.2]$ mc -u superbob -p < /dev/shm/var_auto_Ptio/tmp/dump1.sql
      Enter password: 
      ERROR 1193 (HY000) at line 5: Unknown system variable 'ROLE'
       
      [dan@linux build-mariadb-server-10.2]$ cat /dev/shm/var_auto_Ptio/tmp/dump1.sql
      SELECT COALESCE(QUOTE(CURRENT_ROLE()),'NONE') into @current_role;
      CREATE ROLE mariadb_dump_import_role;
      SET ROLE mariadb_dump_import_role;
      SET ROLE NONE;
      EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role);
      

      on tty ok

      [dan@linux build-mariadb-server-10.2]$ mc -u superbob
      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Your MariaDB connection id is 19
      Server version: 10.2.34-MariaDB Source distribution
       
      Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
       
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
       
      MariaDB [(none)]> 
      MariaDB [(none)]> set @current_role='mariadb_dump_import_role';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [(none)]> EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role);
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [(none)]> select current_role();
      +--------------------------+
      | current_role()           |
      +--------------------------+
      | mariadb_dump_import_role |
      +--------------------------+
      1 row in set (0.00 sec)
      
      

      Attachments

        Activity

          serg Sergei Golubchik added a comment - - edited

          danblack, check the content of @current_role variable in your dump. Your SELECT doesn't do what you think it should.

          serg Sergei Golubchik added a comment - - edited danblack , check the content of @current_role variable in your dump. Your SELECT doesn't do what you think it should.
          danblack Daniel Black added a comment -

          Doh. Thanks.

          danblack Daniel Black added a comment - Doh. Thanks.
          danblack Daniel Black added a comment -

          Attached is a patch that results in a SYNTAX ERROR rather than a unknown system variable. It feels like I'm doing something ugly in the parser however.

          danblack Daniel Black added a comment - Attached is a patch that results in a SYNTAX ERROR rather than a unknown system variable. It feels like I'm doing something ugly in the parser however.

          No, please don't. Unknown role is not a syntax error.

          serg Sergei Golubchik added a comment - No, please don't. Unknown role is not a syntax error.
          danblack Daniel Black added a comment -

          well it was 'SET ROLE' is a syntax error without a role specified. Same with the other partial syntaxes. The `EXECUTE IMMEDIATE 'SET ROLE '` was ending down the variable path in the parser without it.

          danblack Daniel Black added a comment - well it was 'SET ROLE' is a syntax error without a role specified. Same with the other partial syntaxes. The `EXECUTE IMMEDIATE 'SET ROLE '` was ending down the variable path in the parser without it.

          People

            sanja Oleksandr Byelkin
            danblack Daniel Black
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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