[MDEV-26174] A few Reserved Words are allowed to use as Column/Table name Created: 2021-07-19  Updated: 2021-07-29  Resolved: 2021-07-29

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.5.11
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: suresh ramagiri Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

One of our customer noted that from the list of Reserved words - https://mariadb.com/kb/en/reserved-words/ a few of them, they can able to use it as a table name/column name.

Following Reserved words - can be specified as a table/column name
GENERAL
IGNORE_SERVER_IDS
MASTER_HEARTBEAT_PERIOD
OFFSET
OPTION
POSITION
SLOW
WINDOW

I found an existing bug - MDEV-10312, noted about this and marked as "not a bug", mentioning only keywords that are required by the grammar to be reserved are reserved.

But, the customer pointed one case, that with the Reserved word - POSITION

  • without space in the CREATE TABLE statement getting syntax error -expected behavior
  • with space able to create the table with name POSITION

## without space:
MariaDB [test]> create table POSITION(i int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'POSITION(i int)' at line 1
## with space:
MariaDB [test]> create table POSITION (i int);
Query OK, 0 rows affected (0.005 sec) 
MariaDB [test]> select @@version;
+-----------------+
| @@version       |
+-----------------+
| 10.5.11-MariaDB |
+-----------------+
1 row in set (0.000 sec)

If I checked with other reserved word, for both cases getting syntax error, expected behavior:

MariaDB [test]> create table FALSE (i int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FALSE (i int)' at line 1
MariaDB [test]> create table FALSE(i int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FALSE(i int)' at line 1
MariaDB [test]>

Can this be fixed.



 Comments   
Comment by Sergei Golubchik [ 2021-07-29 ]

a non-reserved word can be freely used as an identifier anywhere.

A word is called reserved if it is reserved at least in some context. It doesn't mean it is reserved in every possible context. Where a parser can unambiguously recognize it as an identifier, it can be used without quoting.

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