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

DDL bypass plan #8013

Merged
merged 1 commit into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions go/vt/vtgate/planbuilder/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (fk *fkContraint) FkWalk(node sqlparser.SQLNode) (kontinue bool, err error)
// This is why we return a compound primitive (DDL) which contains fully populated primitives (Send & OnlineDDL),
// and which chooses which of the two to invoke at runtime.
func buildGeneralDDLPlan(sql string, ddlStatement sqlparser.DDLStatement, reservedVars *sqlparser.ReservedVars, vschema ContextVSchema) (engine.Primitive, error) {
if vschema.Destination() != nil {
return buildByPassDDLPlan(sql, vschema)
}
normalDDLPlan, onlineDDLPlan, err := buildDDLPlans(sql, ddlStatement, reservedVars, vschema)
if err != nil {
return nil, err
Expand All @@ -76,6 +79,18 @@ func buildGeneralDDLPlan(sql string, ddlStatement sqlparser.DDLStatement, reserv
}, nil
}

func buildByPassDDLPlan(sql string, vschema ContextVSchema) (engine.Primitive, error) {
keyspace, err := vschema.DefaultKeyspace()
if err != nil {
return nil, err
}
return &engine.Send{
Keyspace: keyspace,
TargetDestination: vschema.Destination(),
Query: sql,
}, nil
}

func buildDDLPlans(sql string, ddlStatement sqlparser.DDLStatement, reservedVars *sqlparser.ReservedVars, vschema ContextVSchema) (*engine.Send, *engine.OnlineDDL, error) {
var destination key.Destination
var keyspace *vindexes.Keyspace
Expand Down
17 changes: 17 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,20 @@ Gen4 plan same as above
}
}
Gen4 plan same as above

# create table
"create /* test */ table t1(id bigint, primary key(id)) /* comments */"
{
"QueryType": "DDL",
"Original": "create /* test */ table t1(id bigint, primary key(id)) /* comments */",
"Instructions": {
"OperatorType": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"TargetDestination": "Shard(-80)",
"Query": "create /* test */ table t1(id bigint, primary key(id)) /* comments */"
}
}
Gen4 plan same as above