parser: support index name in FOREIGN KEY clause; Online DDL to reject FK clauses#8058
Merged
shlomi-noach merged 6 commits intovitessio:masterfrom May 10, 2021
Merged
Conversation
OnlineDDL: explicit error when foreign key clause found Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Contributor
Author
GuptaManan100
approved these changes
May 10, 2021
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
systay
reviewed
May 10, 2021
go/vt/schema/online_ddl.go
Outdated
| } | ||
|
|
||
| fk := &fkContraint{} | ||
| _ = sqlparser.Walk(fk.FkWalk, ddlStmt) |
Collaborator
There was a problem hiding this comment.
nit: You can return the error from fk.FkWalk directly, which would also abort the traversal of the AST.
systay
reviewed
May 10, 2021
go/vt/schema/online_ddl.go
Outdated
| *sqlparser.TableSpec, *sqlparser.AddConstraintDefinition, *sqlparser.ConstraintDefinition: | ||
| return true, nil | ||
| case *sqlparser.ForeignKeyDefinition: | ||
| fk.found = true |
Collaborator
There was a problem hiding this comment.
nit: here you could return an error
Contributor
Author
There was a problem hiding this comment.
Oh I like this! Updated code.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
systay
reviewed
May 10, 2021
| case sqlparser.DDLStatement: | ||
| if !stmt.IsFullyParsed() { | ||
| return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "NewOnlineDDL: cannot fully parse statement %v", sqlparser.String(stmt)) | ||
| return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "NewOnlineDDL: cannot parse statement: %v", sqlparser.String(stmt)) |
Collaborator
There was a problem hiding this comment.
nit: To get a nice looking error message:
return nil, vterrors.NewErrorf(vtrpcpb.Code_INVALID_ARGUMENT, vterrors.SyntaxError, "NewOnlineDDL: cannot parse statement: %s", sqlparser.String(stmt))
systay
approved these changes
May 10, 2021
This was referenced May 11, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the specific comment #8055 (comment)
The parser now supports queries of the form:
index_namepart of the clause (my_fk) in the above.Online DDL now outright rejects any query that has to do with foreign keys.
Related Issue(s)
Checklist
Deployment Notes