[MDEV-23829] confusing error message for SET ROLE INVALID Created: 2020-09-28  Updated: 2020-12-02

Status: Open
Project: MariaDB Server
Component/s: Authentication and Privilege System
Affects Version/s: 10.2.34
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Daniel Black Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File MDEV-23829.patch    

 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)



 Comments   
Comment by Sergei Golubchik [ 2020-09-28 ]

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

Comment by Daniel Black [ 2020-09-28 ]

Doh. Thanks.

Comment by Daniel Black [ 2020-12-01 ]

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.

Comment by Sergei Golubchik [ 2020-12-01 ]

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

Comment by Daniel Black [ 2020-12-02 ]

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.

Generated at Thu Feb 08 09:25:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.