Bug #82954 CURRENT_ROLE doesn't behave like CURRENT_USER
Submitted: 12 Sep 2016 19:00 Modified: 16 Sep 2016 5:19
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Security: Roles Severity:S3 (Non-critical)
Version:8.0.0 OS:Any
Assigned to: CPU Architecture:Any

[12 Sep 2016 19:00] Daniël van Eeden
Description:
CURRENT_USER() can be called w/o the (), but CURRENT_ROLE doesn't allow this

How to repeat:
mysql> SELECT CURRENT_ROLE(), CURRENT_USER(), CURRENT_TIMESTAMP();
+----------------+--------------------+---------------------+
| CURRENT_ROLE() | CURRENT_USER()     | CURRENT_TIMESTAMP() |
+----------------+--------------------+---------------------+
| NONE           | msandbox@localhost | 2016-09-08 11:32:22 |
+----------------+--------------------+---------------------+
1 row in set (0.00 sec)

mysql> SELECT CURRENT_ROLE(), CURRENT_USER(), CURRENT_TIMESTAMP;
+----------------+--------------------+---------------------+
| CURRENT_ROLE() | CURRENT_USER()     | CURRENT_TIMESTAMP   |
+----------------+--------------------+---------------------+
| NONE           | msandbox@localhost | 2016-09-08 11:32:26 |
+----------------+--------------------+---------------------+
1 row in set (0.00 sec)

mysql> SELECT CURRENT_ROLE(), CURRENT_USER, CURRENT_TIMESTAMP;
+----------------+--------------------+---------------------+
| CURRENT_ROLE() | CURRENT_USER       | CURRENT_TIMESTAMP   |
+----------------+--------------------+---------------------+
| NONE           | msandbox@localhost | 2016-09-08 11:32:29 |
+----------------+--------------------+---------------------+
1 row in set (0.00 sec)

mysql> SELECT CURRENT_ROLE, CURRENT_USER, CURRENT_TIMESTAMP;
ERROR 1054 (42S22): Unknown column 'CURRENT_ROLE' in 'field list'

Suggested fix:
Make 'SELECT CURRENT_ROLE' valid syntax.
[13 Sep 2016 13:09] MySQL Verification Team
Hello Daniël, 

Thank you for the report. 

Thanks, 
Umesh
[14 Sep 2016 10:19] Georgi Kodinov
As discussed in bug #82955 this shouldn't have been a function to begin with. 
Just curious: why is it important that we support the no-parenthesis syntax ? 
I understand the others: backward compatibility, no reason to remove etc. But why the new one too ?
[14 Sep 2016 12:01] Daniël van Eeden
> why is it important that we support the no-parenthesis syntax ?
Just for consistency.
[14 Sep 2016 12:56] Georgi Kodinov
I'd much rather hope to reverse this trend since it's causing extra parser productions for each such statement. So if it's not such a big deal let's stick with the current syntax.
[14 Sep 2016 13:23] Daniël van Eeden
Ok. that's a good explanation. Please close as won't fix.