| Bug #100796 | 'member' cannot be used as column alias | ||
|---|---|---|---|
| Submitted: | 10 Sep 2020 11:22 | Modified: | 14 Sep 2020 10:36 |
| Reporter: | Baolin Huang | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
| Version: | 8.0.21 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[10 Sep 2020 11:34]
MySQL Verification Team
Hello Baolin Huang, Thank you for the report and feedback. regards, Umesh
[14 Sep 2020 10:36]
Gleb Shchepa
Thank you for taking the time to write to us, but this is not a bug.
The keyword "MEMBER" is a reserved word in the SQL standard, i.e. "MEMBER" can't be used as unquoted identifier (e.g. column name alias) by the standard.
In the MySQL 8.0 syntax, the use of the keyword "MEMBER" as unquoted identifier is limited.
Workarounds: to use "MEMBER" as a column name alias
1. please quote the identifier "MEMBER":
SELECT ... `member`
2. or, use the the explicit keyword "AS":
SELECT ... AS member

Description: The fix for 'member' key word seems not complete. How to repeat: ``` mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.21 | +-----------+ 1 row in set (0.00 sec) mysql> mysql> delimiter ;; mysql> mysql> CREATE EVENT `f` ON SCHEDULE EVERY 5 MINUTE STARTS '2019-11-30 01:00:19' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO BEGIN -> create table ttt(id int); -> select if(id <3,1,0) member from ttt; -> END -> ;; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from ttt; END' at line 3 mysql> mysql> mysql> CREATE EVENT `f` ON SCHEDULE EVERY 5 MINUTE STARTS '2019-11-30 01:00:19' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO BEGIN -> create table ttt(id int); -> select if(id <3,1,0) `member` from ttt; -> END -> ;; Query OK, 0 rows affected (0.00 sec) ``` Suggested fix: none