-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Parser does not fail on invalid query #8057
Comments
On vitess: mysql> set @@ddl_strategy='direct';
Query OK, 0 rows affected (0.00 sec)
mysql> alter table corder zzzz zzzz zzzz;
Query OK, 0 rows affected (0.01 sec) On MySQL: mysql> alter table demo zzzz zzzz zzzz;
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 'zzzz zzzz zzzz' at line 1 |
I traced the problem down to this path: Lines 1869 to 1871 in 9cc166f
|
alter table corder zzzz zzzz zzzz remove partitioning; in this path: Lines 2052 to 2058 in 9cc166f
|
I also notice this line gets executed on such invalid SQL: vitess/go/vt/sqlparser/parser.go Line 84 in 9cc166f
Other samples of wrongly accepted syntax: alter table corder engine=innodb zzzz zzzz;
alter table corder drop column c zzzz zzzz; |
Similarily, in the input Lines 2052 to 2058 in 9cc166f
PartitionSpec field would not be null, but it is.
The reason that this behavior happens is that when the parser sees the Since only the initial tokens are used in parsing, the query becomes valid and therefore |
I think the error lies in the lines vitess/go/vt/sqlparser/parser.go Lines 81 to 83 in 9cc166f
lastError field of the tokenizer indead shows that there is a syntax error at position 24 near zzzz . These lines do not catch this error and the errors are ignored in the subsequent lines. As to why tokenizer.Scan() returns 0 in these lines is still left to investigate
|
I think "only the initial tokens are used in parsing" necessarily implies that |
Yes, I agree with you, in this place where we are catching the errors, we should be setting the FullyParsed value to false. vitess/go/vt/sqlparser/parser.go Lines 81 to 85 in 9cc166f
|
Yes, that makes sense to me! |
It's funny though that |
Yes, it isn't but we set the PartialDDLs only for DDLs, so it should be okay. I'll get the PR ready ASAP |
Fixed by #8094 |
Based on #8055
The following query:
should fail parsing. However, it parses without error, and on top of that, claims
isFullyParsed() == true
.The text was updated successfully, but these errors were encountered: