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

Unable to parse table name #335

Open
williamdes opened this issue Apr 19, 2021 · 6 comments
Open

Unable to parse table name #335

williamdes opened this issue Apr 19, 2021 · 6 comments
Labels

Comments

@williamdes
Copy link
Member

See: phpmyadmin/phpmyadmin#16837

create table event(
eventID varchar(10) not null,
b char(30),
c varchar(20),
d TIME,
e Date,
f int,
g char(70),
h char(90),
primary key(eventID)
)

is the table is named event2 that will work

@williamdes williamdes added the bug label Apr 19, 2021
@williamdes williamdes added this to the 4.7.3 milestone Apr 19, 2021
@iifawzi
Copy link
Contributor

iifawzi commented Sep 16, 2021

I'm afraid of that this issue couldn't be easily fixed, because the event keyword is a reserved keyword, the bug will also occur whenever we're creating a table, index or anything with a name identical to any of the options with number 6.

'DATABASE' => 6,
'EVENT' => 6,
'FUNCTION' => 6,
'INDEX' => 6,
'UNIQUE INDEX' => 6,
'FULLTEXT INDEX' => 6,
'SPATIAL INDEX' => 6,
'PROCEDURE' => 6,
'SERVER' => 6,
'TABLE' => 6,
'TABLESPACE' => 6,
'TRIGGER' => 6,
'USER' => 6,
'VIEW' => 6,
'SCHEMA' => 6,

and it would be hard to fixed because of

if (isset($ret->options[$lastOptionId])) {
$parser->error(
sprintf(
Translator::gettext('This option conflicts with "%1$s".'),
is_array($ret->options[$lastOptionId])
? $ret->options[$lastOptionId]['name']
: $ret->options[$lastOptionId]
),
$token
);
$lastOptionId = $lastAssignedId++;
}
}

that's why it will always throw a conflict error, these are my findings, I couldn't think of a not-breaking fix for this.

@williamdes
Copy link
Member Author

Thank you for the debug, maybe we can keep this one open for now

@williamdes williamdes modified the milestones: 4.7.3, 4.7.4 Dec 11, 2021
@williamdes williamdes modified the milestones: 4.7.4, 5.7.0 Nov 21, 2022
@williamdes williamdes modified the milestones: 5.7.0, 5.8.0 Jan 25, 2023
@niconoe-
Copy link
Contributor

@williamdes / @iifawzi

I made some tests and some of the options are allowed while some others are not, and I can't really find any clear rule about how to distinguish them.

CREATE TABLE DATABASE(ID INT(11)); -- Refused by MySQL
CREATE TABLE EVENT(ID INT(11)); -- OK by MySQL
CREATE TABLE FUNCTION(ID INT(11)); -- OK by MySQL
CREATE TABLE INDEX(ID INT(11)); -- Refused by MySQL
CREATE TABLE UNIQUE INDEX(ID INT(11)); -- Refused by MySQL
CREATE TABLE FULLTEXT INDEX(ID INT(11)); -- Refused by MySQL
CREATE TABLE SPATIAL INDEX(ID INT(11)); -- Refused by MySQL
CREATE TABLE PROCEDURE(ID INT(11)); -- Refused by MySQL
CREATE TABLE SERVER(ID INT(11)); -- OK by MySQL
CREATE TABLE TABLE(ID INT(11)); -- Refused by MySQL
CREATE TABLE TABLESPACE(ID INT(11)); -- OK by MySQL
CREATE TABLE TRIGGER(ID INT(11)); -- Refused by MySQL
CREATE TABLE USER(ID INT(11)); -- OK by MySQL
CREATE TABLE VIEW(ID INT(11)); -- OK by MySQL
CREATE TABLE SCHEMA(ID INT(11)); -- Refused by MySQL

Would it be ok to create a whitelist of the allowed options and to not trigger an error if such whitelist exists + the option is part of it?

@williamdes
Copy link
Member Author

I am not really sure we should do that in this project, but maybe if it integrates well with the existing code base?

@niconoe-
Copy link
Contributor

niconoe- commented Mar 1, 2023

I don't know if I would be available to give it a try on a PR soon. I was just trying to find a workaround as even @iifawzi seemed to have no solution about it. If this solution is too hacky, then we need to find another one.

@iifawzi
Copy link
Contributor

iifawzi commented Mar 25, 2023

It's been two years, the project has evolved a lot, my knowledge in the project evolved too. So, my conclusion above might be totally outdated.

@williamdes williamdes modified the milestones: 5.8.0, 5.9.0 Jun 5, 2023
@MauricioFauth MauricioFauth removed this from the 5.8.1 milestone Sep 16, 2023
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

4 participants