Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping does not work with reserved keywords #1827

Open
Nick-S-2018 opened this issue Feb 12, 2024 · 2 comments
Open

Escaping does not work with reserved keywords #1827

Nick-S-2018 opened this issue Feb 12, 2024 · 2 comments
Assignees
Labels

Comments

@Nick-S-2018
Copy link
Collaborator

Describe the bug
Escaping does not work with reserved keywords in the query.

To Reproduce
Steps to reproduce the behavior:

  1. mysql> create table t(`year` int);
  2. mysql> create table t(`facet` int);
  3. mysql> create table t(`order` int);

Expected behavior
The table is created

Actual behavior

ERROR 1064 (42000): table 't': CREATE TABLE failed: attribute name 'order' is a reserved keyword

Describe the environment:

  • Manticore 6.2.13 7e1e4f312@24021217 dev
@sanikolaev
Copy link
Collaborator

Escaping helps in some cases, e.g. for table:

mysql> drop table if exists t; create table t(table int);
Query OK, 0 rows affected (0.01 sec)

ERROR 1064 (42000): P03: syntax error, unexpected TABLE, expecting identifier or tablename or MODIFY or TYPE near 'table int)'
mysql> drop table if exists t; create table t(`table` int);
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

but not for some others, e.g. order:

mysql> drop table if exists t; create table t(`order` int);
Query OK, 0 rows affected (0.00 sec)

ERROR 1064 (42000): table 't': CREATE TABLE failed: attribute name 'order' is a reserved keyword

@sanikolaev
Copy link
Collaborator

Interesting that it works fine with table when it's escaped:

mysql> drop table if exists t; create table t(table text);; create table t(`table` text);
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.01 sec)

--------------
create table t(table text)
--------------

ERROR 1064 (42000): P03: syntax error, unexpected TABLE, expecting identifier or tablename or MODIFY or TYPE near 'table text)'
ERROR:
No query specified

--------------
create table t(`table` text)
--------------

Query OK, 0 rows affected (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants