From 29afd1dc28b674d5629106b197b7e0c161a57a92 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jan 2022 12:26:34 +0530 Subject: [PATCH 01/12] refactor: move dba query routing to common routing logic Signed-off-by: Manan Gupta --- go/vt/vtgate/engine/delete.go | 2 +- go/vt/vtgate/engine/dml.go | 29 +---- go/vt/vtgate/engine/route.go | 162 +++++------------------- go/vt/vtgate/engine/routing.go | 211 ++++++++++++++++++++++++++++++++ go/vt/vtgate/engine/update.go | 2 +- go/vt/vtgate/planbuilder/dml.go | 14 +-- 6 files changed, 253 insertions(+), 167 deletions(-) create mode 100644 go/vt/vtgate/engine/routing.go diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 48be6ce4eb7..1ba52c37b8b 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -44,7 +44,7 @@ type Delete struct { noInputs } -var delName = map[DMLOpcode]string{ +var delName = map[Opcode]string{ Unsharded: "DeleteUnsharded", Equal: "DeleteEqual", In: "DeleteIn", diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index 0d3eb60f93f..5a58bc80447 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -34,7 +34,7 @@ import ( // DML contains the common elements between Update and Delete plans type DML struct { // Opcode is the execution opcode. - Opcode DMLOpcode + Opcode Opcode // Keyspace specifies the keyspace to send the query to. Keyspace *vindexes.Keyspace @@ -74,30 +74,7 @@ type DML struct { txNeeded } -// DMLOpcode is a number representing the opcode -// for the Update or Delete primitve. -type DMLOpcode int - -// This is the list of UpdateOpcode values. -const ( - // Unsharded is for routing a dml statement - // to an unsharded keyspace. - Unsharded = DMLOpcode(iota) - // Equal is for routing an dml statement to a single shard. - // Requires: A Vindex, and a single Value. - Equal - // In is for routing an dml statement to a multi shard. - // Requires: A Vindex, and a multi Values. - In - // Scatter is for routing a scattered dml statement. - Scatter - // ByDestination is to route explicitly to a given target destination. - // Is used when the query explicitly sets a target destination: - // in the clause e.g: UPDATE `keyspace[-]`.x1 SET foo=1 - ByDestination -) - -var opcodeName = map[DMLOpcode]string{ +var opcodeName = map[Opcode]string{ Unsharded: "Unsharded", Equal: "Equal", In: "In", @@ -105,7 +82,7 @@ var opcodeName = map[DMLOpcode]string{ ByDestination: "ByDestination", } -func (op DMLOpcode) String() string { +func (op Opcode) String() string { return opcodeName[op] } diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 22ae9caf201..070ede6d5fe 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -25,9 +25,6 @@ import ( "time" "vitess.io/vitess/go/mysql/collations" - "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/sqlparser" - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/vtgate/evalengine" @@ -248,6 +245,29 @@ func (route *Route) SetTruncateColumnCount(count int) { route.TruncateColumnCount = count } +// GetGenericOpcode gets the Opcode which is used for routing +func (route *Route) GetGenericOpcode() Opcode { + switch route.Opcode { + case SelectDBA: + return DBA + case SelectUnsharded, SelectNext, SelectReference: + return Unsharded + case SelectScatter: + return Scatter + case SelectEqual, SelectEqualUnique: + return Equal + case SelectIN: + return In + case SelectMultiEqual: + return MultiEqual + case SelectNone: + return None + default: + // Unreachable. + return None + } +} + // TryExecute performs a non-streaming exec. func (route *Route) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { if route.QueryTimeout != 0 { @@ -300,9 +320,15 @@ func (route *Route) executeInternal(vcursor VCursor, bindVars map[string]*queryp } func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + params := RoutingParameters{ + opcode: route.GetGenericOpcode(), + keyspace: route.Keyspace, + sysTableTableName: route.SysTableTableName, + sysTableTableSchema: route.SysTableTableSchema, + } switch route.Opcode { case SelectDBA: - return route.paramsSystemQuery(vcursor, bindVars) + return params.systemQuery(vcursor, bindVars) case SelectUnsharded, SelectNext, SelectReference: return route.paramsAnyShard(vcursor, bindVars) case SelectScatter: @@ -438,134 +464,6 @@ func (route *Route) paramsAllShards(vcursor VCursor, bindVars map[string]*queryp return rss, multiBindVars, nil } -func (route *Route) paramsSystemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - destinations, err := route.routeInfoSchemaQuery(vcursor, bindVars) - if err != nil { - return nil, nil, err - } - - return destinations, []map[string]*querypb.BindVariable{bindVars}, nil -} - -func (route *Route) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, error) { - defaultRoute := func() ([]*srvtopo.ResolvedShard, error) { - ks := route.Keyspace.Name - destinations, _, err := vcursor.ResolveDestinations(ks, nil, []key.Destination{key.DestinationAnyShard{}}) - return destinations, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", ks) - } - - if len(route.SysTableTableName) == 0 && len(route.SysTableTableSchema) == 0 { - return defaultRoute() - } - - env := evalengine.EnvWithBindVars(bindVars) - var specifiedKS string - for _, tableSchema := range route.SysTableTableSchema { - result, err := env.Evaluate(tableSchema) - if err != nil { - return nil, err - } - ks := result.Value().ToString() - if specifiedKS == "" { - specifiedKS = ks - } - if specifiedKS != ks { - return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "specifying two different database in the query is not supported") - } - } - if specifiedKS != "" { - bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) - } - - tableNames := map[string]string{} - for tblBvName, sysTableName := range route.SysTableTableName { - val, err := env.Evaluate(sysTableName) - if err != nil { - return nil, err - } - tabName := val.Value().ToString() - tableNames[tblBvName] = tabName - bindVars[tblBvName] = sqltypes.StringBindVariable(tabName) - } - - // if the table_schema is system schema, route to default keyspace. - if sqlparser.SystemSchema(specifiedKS) { - return defaultRoute() - } - - // the use has specified a table_name - let's check if it's a routed table - if len(tableNames) > 0 { - rss, err := route.paramsRoutedTable(vcursor, bindVars, specifiedKS, tableNames) - if err != nil { - // Only if keyspace is not found in vschema, we try with default keyspace. - // As the in the table_schema predicates for a keyspace 'ks' it can contain 'vt_ks'. - if vterrors.ErrState(err) == vterrors.BadDb { - return defaultRoute() - } - return nil, err - } - if rss != nil { - return rss, nil - } - } - - // it was not a routed table, and we dont have a schema name to look up. give up - if specifiedKS == "" { - return defaultRoute() - } - - // we only have table_schema to work with - destinations, _, err := vcursor.ResolveDestinations(specifiedKS, nil, []key.Destination{key.DestinationAnyShard{}}) - if err != nil { - log.Errorf("failed to route information_schema query to keyspace [%s]", specifiedKS) - bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) - return defaultRoute() - } - setReplaceSchemaName(bindVars) - return destinations, nil -} - -func (route *Route) paramsRoutedTable(vcursor VCursor, bindVars map[string]*querypb.BindVariable, tableSchema string, tableNames map[string]string) ([]*srvtopo.ResolvedShard, error) { - var routedKs *vindexes.Keyspace - for tblBvName, tableName := range tableNames { - tbl := sqlparser.TableName{ - Name: sqlparser.NewTableIdent(tableName), - Qualifier: sqlparser.NewTableIdent(tableSchema), - } - routedTable, err := vcursor.FindRoutedTable(tbl) - if err != nil { - return nil, err - } - - if routedTable != nil { - // if we were able to find information about this table, let's use it - - // check if the query is send to single keyspace. - if routedKs == nil { - routedKs = routedTable.Keyspace - } - if routedKs.Name != routedTable.Keyspace.Name { - return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot send the query to multiple keyspace due to different table_name: %s, %s", routedKs.Name, routedTable.Keyspace.Name) - } - - shards, _, err := vcursor.ResolveDestinations(routedTable.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) - bindVars[tblBvName] = sqltypes.StringBindVariable(routedTable.Name.String()) - if tableSchema != "" { - setReplaceSchemaName(bindVars) - } - return shards, err - } - // no routed table info found. we'll return nil and check on the outside if we can find the table_schema - bindVars[tblBvName] = sqltypes.StringBindVariable(tableName) - } - return nil, nil -} - -func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { - delete(bindVars, sqltypes.BvSchemaName) - bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) -} - func (route *Route) paramsAnyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) if err != nil { diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go new file mode 100644 index 00000000000..2b7441f10b7 --- /dev/null +++ b/go/vt/vtgate/engine/routing.go @@ -0,0 +1,211 @@ +/* +Copyright 2022 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package engine + +import ( + "vitess.io/vitess/go/sqltypes" + "vitess.io/vitess/go/vt/key" + "vitess.io/vitess/go/vt/log" + querypb "vitess.io/vitess/go/vt/proto/query" + vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" + "vitess.io/vitess/go/vt/sqlparser" + "vitess.io/vitess/go/vt/srvtopo" + "vitess.io/vitess/go/vt/vterrors" + "vitess.io/vitess/go/vt/vtgate/evalengine" + "vitess.io/vitess/go/vt/vtgate/vindexes" +) + +// Opcode is a number representing the opcode +// for any engine primitve. +type Opcode int + +// This is the list of Opcode values. +const ( + // None is used for queries which do not need routing + None = Opcode(iota) + // Unsharded is for routing a statement + // to an unsharded keyspace. + Unsharded + // Equal is for routing a statement to a single shard. + // Requires: A Vindex, and a single Value. + Equal + // In is for routing a statement to a multi shard. + // Requires: A Vindex, and a multi Values. + In + // MultiEqual is used for routing queries with IN with tuple clause + // Requires: A Vindex, and a multi Tuple Values. + MultiEqual + // Scatter is for routing a scattered statement. + Scatter + // ByDestination is to route explicitly to a given target destination. + // Is used when the query explicitly sets a target destination: + // in the clause e.g: UPDATE `keyspace[-]`.x1 SET foo=1 + ByDestination + // DBA is used for routing DBA queries + // e.g: Select * from information_schema.tables where schema_name = "a" + DBA +) + +type RoutingParameters struct { + // Required for - All + opcode Opcode + keyspace *vindexes.Keyspace + + // Required for - DBA + sysTableTableSchema []evalengine.Expr + sysTableTableName map[string]evalengine.Expr +} + +func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + switch params.opcode { + case DBA: + return params.systemQuery(vcursor, bindVars) + case None: + return nil, nil, nil + default: + // Unreachable. + return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", params.opcode) + } +} + +func (params *RoutingParameters) systemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + destinations, err := params.routeInfoSchemaQuery(vcursor, bindVars) + if err != nil { + return nil, nil, err + } + + return destinations, []map[string]*querypb.BindVariable{bindVars}, nil +} + +func (params *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, error) { + defaultRoute := func() ([]*srvtopo.ResolvedShard, error) { + ks := params.keyspace.Name + destinations, _, err := vcursor.ResolveDestinations(ks, nil, []key.Destination{key.DestinationAnyShard{}}) + return destinations, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", ks) + } + + if len(params.sysTableTableName) == 0 && len(params.sysTableTableSchema) == 0 { + return defaultRoute() + } + + env := evalengine.EnvWithBindVars(bindVars) + var specifiedKS string + for _, tableSchema := range params.sysTableTableSchema { + result, err := env.Evaluate(tableSchema) + if err != nil { + return nil, err + } + ks := result.Value().ToString() + if specifiedKS == "" { + specifiedKS = ks + } + if specifiedKS != ks { + return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "specifying two different database in the query is not supported") + } + } + if specifiedKS != "" { + bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) + } + + tableNames := map[string]string{} + for tblBvName, sysTableName := range params.sysTableTableName { + val, err := env.Evaluate(sysTableName) + if err != nil { + return nil, err + } + tabName := val.Value().ToString() + tableNames[tblBvName] = tabName + bindVars[tblBvName] = sqltypes.StringBindVariable(tabName) + } + + // if the table_schema is system schema, route to default keyspace. + if sqlparser.SystemSchema(specifiedKS) { + return defaultRoute() + } + + // the use has specified a table_name - let's check if it's a routed table + if len(tableNames) > 0 { + rss, err := params.routedTable(vcursor, bindVars, specifiedKS, tableNames) + if err != nil { + // Only if keyspace is not found in vschema, we try with default keyspace. + // As the in the table_schema predicates for a keyspace 'ks' it can contain 'vt_ks'. + if vterrors.ErrState(err) == vterrors.BadDb { + return defaultRoute() + } + return nil, err + } + if rss != nil { + return rss, nil + } + } + + // it was not a routed table, and we dont have a schema name to look up. give up + if specifiedKS == "" { + return defaultRoute() + } + + // we only have table_schema to work with + destinations, _, err := vcursor.ResolveDestinations(specifiedKS, nil, []key.Destination{key.DestinationAnyShard{}}) + if err != nil { + log.Errorf("failed to route information_schema query to keyspace [%s]", specifiedKS) + bindVars[sqltypes.BvSchemaName] = sqltypes.StringBindVariable(specifiedKS) + return defaultRoute() + } + setReplaceSchemaName(bindVars) + return destinations, nil +} + +func (params *RoutingParameters) routedTable(vcursor VCursor, bindVars map[string]*querypb.BindVariable, tableSchema string, tableNames map[string]string) ([]*srvtopo.ResolvedShard, error) { + var routedKs *vindexes.Keyspace + for tblBvName, tableName := range tableNames { + tbl := sqlparser.TableName{ + Name: sqlparser.NewTableIdent(tableName), + Qualifier: sqlparser.NewTableIdent(tableSchema), + } + routedTable, err := vcursor.FindRoutedTable(tbl) + if err != nil { + return nil, err + } + + if routedTable != nil { + // if we were able to find information about this table, let's use it + + // check if the query is send to single keyspace. + if routedKs == nil { + routedKs = routedTable.Keyspace + } + if routedKs.Name != routedTable.Keyspace.Name { + return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot send the query to multiple keyspace due to different table_name: %s, %s", routedKs.Name, routedTable.Keyspace.Name) + } + + shards, _, err := vcursor.ResolveDestinations(routedTable.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) + bindVars[tblBvName] = sqltypes.StringBindVariable(routedTable.Name.String()) + if tableSchema != "" { + setReplaceSchemaName(bindVars) + } + return shards, err + } + // no routed table info found. we'll return nil and check on the outside if we can find the table_schema + bindVars[tblBvName] = sqltypes.StringBindVariable(tableName) + } + return nil, nil +} + +func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { + delete(bindVars, sqltypes.BvSchemaName) + bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) +} diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index b2b782b8e5c..f17594de799 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -54,7 +54,7 @@ type Update struct { noInputs } -var updName = map[DMLOpcode]string{ +var updName = map[Opcode]string{ Unsharded: "UpdateUnsharded", Equal: "UpdateEqual", In: "UpdateIn", diff --git a/go/vt/vtgate/planbuilder/dml.go b/go/vt/vtgate/planbuilder/dml.go index ddf6e1bc6d5..9c2d9e221aa 100644 --- a/go/vt/vtgate/planbuilder/dml.go +++ b/go/vt/vtgate/planbuilder/dml.go @@ -34,7 +34,7 @@ type ( costDML struct { vindexCost int isUnique bool - opCode engine.DMLOpcode + opCode engine.Opcode } // vindexPlusPredicatesDML is a struct used to store all the predicates that the vindex can be used to query @@ -51,7 +51,7 @@ type ( values []evalengine.Expr // columns that we have seen so far. Used only for multi-column vindexes so that we can track how many columns part of the vindex we have seen colsSeen map[string]interface{} - opcode engine.DMLOpcode + opcode engine.Opcode foundVindex vindexes.Vindex cost costDML } @@ -60,7 +60,7 @@ type ( // getDMLRouting returns the vindex and values for the DML, // If it cannot find a unique vindex match, it returns an error. func getDMLRouting(where *sqlparser.Where, table *vindexes.Table) ( - engine.DMLOpcode, + engine.Opcode, *vindexes.ColumnVindex, vindexes.Vindex, []evalengine.Expr, @@ -118,7 +118,7 @@ func getBestVindexOption(exprs []sqlparser.Expr, index *vindexes.ColumnVindex) * continue } - var opcode engine.DMLOpcode + var opcode engine.Opcode switch comparison.Operator { case sqlparser.EqualOp: if !sqlparser.IsValue(valExpr) { @@ -168,7 +168,7 @@ func lessCostDML(c1, c2 costDML) bool { } // addVindexOptions adds new vindexOptionDML if it matches any column of the vindexes.ColumnVindex -func addVindexOptions(column *sqlparser.ColName, value evalengine.Expr, opcode engine.DMLOpcode, v *vindexPlusPredicatesDML) { +func addVindexOptions(column *sqlparser.ColName, value evalengine.Expr, opcode engine.Opcode, v *vindexPlusPredicatesDML) { switch v.colVindex.Vindex.(type) { case vindexes.SingleColumn: col := v.colVindex.Columns[0] @@ -239,7 +239,7 @@ func copyOptionDML(orig *vindexOptionDML) *vindexOptionDML { } // updateWithNewColumn is used to update vindexOptionDML with a new column that matches one of its unseen columns -func (option *vindexOptionDML) updateWithNewColumn(colLoweredName string, indexOfCol int, value evalengine.Expr, colVindex *vindexes.ColumnVindex, opcode engine.DMLOpcode) { +func (option *vindexOptionDML) updateWithNewColumn(colLoweredName string, indexOfCol int, value evalengine.Expr, colVindex *vindexes.ColumnVindex, opcode engine.Opcode) { option.colsSeen[colLoweredName] = true option.values[indexOfCol] = value option.ready = len(option.colsSeen) == len(colVindex.Columns) @@ -264,7 +264,7 @@ func createOptionDML( } // costForDML returns a cost struct to make route choices easier to compare -func costForDML(foundVindex *vindexes.ColumnVindex, opcode engine.DMLOpcode) costDML { +func costForDML(foundVindex *vindexes.ColumnVindex, opcode engine.Opcode) costDML { switch opcode { // For these opcodes, we should not have a vindex, so we just return the opcode as the cost case engine.Unsharded, engine.Scatter: From f8a2a8cfda9fc3d7ffad3d527a8c2f6b047dbc96 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jan 2022 12:44:42 +0530 Subject: [PATCH 02/12] refactor: move unsharded and any query routing to common routing logic Signed-off-by: Manan Gupta --- go/vt/vtgate/engine/delete.go | 9 ++++---- go/vt/vtgate/engine/route.go | 22 +++++--------------- go/vt/vtgate/engine/route_test.go | 28 ++++++++++++------------- go/vt/vtgate/engine/routing.go | 34 +++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 35 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 1ba52c37b8b..b8d415d2b1b 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -114,13 +114,14 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp } func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, _, err := vcursor.ResolveDestinations(del.Keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) + params := RoutingParameters{ + opcode: del.Opcode, + keyspace: del.Keyspace, + } + rss, _, err := params.findRoute(vcursor, bindVars) if err != nil { return nil, err } - if len(rss) != 1 { - return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot send query to multiple shards for un-sharded database: %v", rss) - } err = allowOnlyPrimary(rss...) if err != nil { return nil, err diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 070ede6d5fe..dc8ee26022c 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -250,8 +250,10 @@ func (route *Route) GetGenericOpcode() Opcode { switch route.Opcode { case SelectDBA: return DBA - case SelectUnsharded, SelectNext, SelectReference: + case SelectUnsharded, SelectNext: return Unsharded + case SelectReference: + return Any case SelectScatter: return Scatter case SelectEqual, SelectEqualUnique: @@ -327,10 +329,8 @@ func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.Bind sysTableTableSchema: route.SysTableTableSchema, } switch route.Opcode { - case SelectDBA: - return params.systemQuery(vcursor, bindVars) - case SelectUnsharded, SelectNext, SelectReference: - return route.paramsAnyShard(vcursor, bindVars) + case SelectDBA, SelectUnsharded, SelectNext, SelectReference: + return params.findRoute(vcursor, bindVars) case SelectScatter: return route.paramsAllShards(vcursor, bindVars) case SelectEqual, SelectEqualUnique: @@ -464,18 +464,6 @@ func (route *Route) paramsAllShards(vcursor VCursor, bindVars map[string]*queryp return rss, multiBindVars, nil } -func (route *Route) paramsAnyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - func (route *Route) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) value, err := env.Evaluate(route.Values[0]) diff --git a/go/vt/vtgate/engine/route_test.go b/go/vt/vtgate/engine/route_test.go index 9ec4b009680..0a43495a849 100644 --- a/go/vt/vtgate/engine/route_test.go +++ b/go/vt/vtgate/engine/route_test.go @@ -66,7 +66,7 @@ func TestSelectUnsharded(t *testing.T) { result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) expectResult(t, "sel.Execute", result, defaultSelectResult) @@ -75,7 +75,7 @@ func TestSelectUnsharded(t *testing.T) { result, err = wrapStreamExecute(sel, vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `StreamExecuteMulti dummy_select ks.0: {} `, }) expectResult(t, "sel.StreamExecute", result, defaultSelectResult) @@ -667,29 +667,29 @@ func TestSelectNext(t *testing.T) { SelectNext, &vindexes.Keyspace{ Name: "ks", - Sharded: true, + Sharded: false, }, "dummy_select", "dummy_select_field", ) vc := &loggingVCursor{ - shards: []string{"-20", "20-"}, + shards: []string{"-"}, results: []*sqltypes.Result{defaultSelectResult}, } result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, - `ExecuteMultiShard ks.-20: dummy_select {} false false`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, + `ExecuteMultiShard ks.-: dummy_select {} false false`, }) expectResult(t, "sel.Execute", result, defaultSelectResult) vc.Rewind() result, _ = wrapStreamExecute(sel, vc, map[string]*querypb.BindVariable{}, false) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, - `StreamExecuteMulti dummy_select ks.-20: {} `, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, + `StreamExecuteMulti dummy_select ks.-: {} `, }) expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } @@ -834,7 +834,7 @@ func TestRouteSort(t *testing.T) { result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) wantResult := sqltypes.MakeTestResult( @@ -922,7 +922,7 @@ func TestRouteSortWeightStrings(t *testing.T) { result, err = sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) wantResult = sqltypes.MakeTestResult( @@ -1027,7 +1027,7 @@ func TestRouteSortCollation(t *testing.T) { result, err = sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) wantResult = sqltypes.MakeTestResult( @@ -1149,7 +1149,7 @@ func TestRouteSortTruncate(t *testing.T) { result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) wantResult := sqltypes.MakeTestResult( @@ -1193,7 +1193,7 @@ func TestRouteStreamTruncate(t *testing.T) { result, err := sel.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `ExecuteMultiShard ks.0: dummy_select {} false false`, }) wantResult := sqltypes.MakeTestResult( @@ -1238,7 +1238,7 @@ func TestRouteStreamSortTruncate(t *testing.T) { result, err := wrapStreamExecute(sel, vc, map[string]*querypb.BindVariable{}, true) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationAnyShard()`, + `ResolveDestinations ks [] Destinations:DestinationAllShards()`, `StreamExecuteMulti dummy_select ks.0: {} `, }) diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index 2b7441f10b7..8ead2ab8237 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -40,6 +40,9 @@ const ( // Unsharded is for routing a statement // to an unsharded keyspace. Unsharded + // Any is for routing a statement + // to any shard of a keyspace. e.g. - Reference tables + Any // Equal is for routing a statement to a single shard. // Requires: A Vindex, and a single Value. Equal @@ -74,6 +77,10 @@ func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string] switch params.opcode { case DBA: return params.systemQuery(vcursor, bindVars) + case Unsharded: + return params.unsharded(vcursor, bindVars) + case Any: + return params.anyShard(vcursor, bindVars) case None: return nil, nil, nil default: @@ -209,3 +216,30 @@ func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { delete(bindVars, sqltypes.BvSchemaName) bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) } + +func (params *RoutingParameters) anyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} + +func (params *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) + if err != nil { + return nil, nil, err + } + if len(rss) != 1 { + return nil, nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot send query to multiple shards for un-sharded database: %v", rss) + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} From 6bde9f22250fa4bf54afada29d4f92cca43a1481 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jan 2022 12:49:57 +0530 Subject: [PATCH 03/12] refactor: move scatter query routing to common routing logic Signed-off-by: Manan Gupta --- go/vt/vtgate/engine/dbddl_test.go | 1 + go/vt/vtgate/engine/route.go | 16 +--------------- go/vt/vtgate/engine/routing.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/go/vt/vtgate/engine/dbddl_test.go b/go/vt/vtgate/engine/dbddl_test.go index 6eae0126d9d..3f61576fa28 100644 --- a/go/vt/vtgate/engine/dbddl_test.go +++ b/go/vt/vtgate/engine/dbddl_test.go @@ -68,6 +68,7 @@ func TestDBDDLDropExecute(t *testing.T) { } func TestDBDDLTimeout(t *testing.T) { + t.Skip() pluginName := "timeoutFake" plugin := &dbddlTestFake{sleep: 2} DBDDLRegister(pluginName, plugin) diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index dc8ee26022c..b30a8e19642 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -329,10 +329,8 @@ func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.Bind sysTableTableSchema: route.SysTableTableSchema, } switch route.Opcode { - case SelectDBA, SelectUnsharded, SelectNext, SelectReference: + case SelectDBA, SelectUnsharded, SelectNext, SelectReference, SelectScatter: return params.findRoute(vcursor, bindVars) - case SelectScatter: - return route.paramsAllShards(vcursor, bindVars) case SelectEqual, SelectEqualUnique: switch route.Vindex.(type) { case vindexes.MultiColumn: @@ -452,18 +450,6 @@ func (route *Route) GetFields(vcursor VCursor, bindVars map[string]*querypb.Bind return qr.Truncate(route.TruncateColumnCount), nil } -func (route *Route) paramsAllShards(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - func (route *Route) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) value, err := env.Evaluate(route.Values[0]) diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index 8ead2ab8237..36ae6a5b0a1 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -81,6 +81,8 @@ func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string] return params.unsharded(vcursor, bindVars) case Any: return params.anyShard(vcursor, bindVars) + case Scatter: + return params.allShards(vcursor, bindVars) case None: return nil, nil, nil default: @@ -243,3 +245,15 @@ func (params *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string] } return rss, multiBindVars, nil } + +func (params *RoutingParameters) allShards(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} From b1b7dcdc2d24585e8c83852c4d4dc9fc826f4d5c Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jan 2022 13:02:20 +0530 Subject: [PATCH 04/12] refactor: move byDestination query routing to common routing logic Signed-off-by: Manan Gupta --- go/vt/vtgate/engine/dbddl_test.go | 1 - go/vt/vtgate/engine/delete.go | 7 ++++++- go/vt/vtgate/engine/routing.go | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/go/vt/vtgate/engine/dbddl_test.go b/go/vt/vtgate/engine/dbddl_test.go index 3f61576fa28..6eae0126d9d 100644 --- a/go/vt/vtgate/engine/dbddl_test.go +++ b/go/vt/vtgate/engine/dbddl_test.go @@ -68,7 +68,6 @@ func TestDBDDLDropExecute(t *testing.T) { } func TestDBDDLTimeout(t *testing.T) { - t.Skip() pluginName := "timeoutFake" plugin := &dbddlTestFake{sleep: 2} DBDDLRegister(pluginName, plugin) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index b8d415d2b1b..f3842519b03 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -205,7 +205,12 @@ func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.Bi } func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - rss, _, err := vcursor.ResolveDestinations(del.Keyspace.Name, nil, []key.Destination{dest}) + params := RoutingParameters{ + opcode: del.Opcode, + keyspace: del.Keyspace, + targetDestination: dest, + } + rss, _, err := params.findRoute(vcursor, bindVars) if err != nil { return nil, err } diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index 36ae6a5b0a1..a7b45770ff5 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -71,6 +71,9 @@ type RoutingParameters struct { // Required for - DBA sysTableTableSchema []evalengine.Expr sysTableTableName map[string]evalengine.Expr + + // Required for - ByDestination + targetDestination key.Destination } func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { @@ -82,7 +85,9 @@ func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string] case Any: return params.anyShard(vcursor, bindVars) case Scatter: - return params.allShards(vcursor, bindVars) + return params.byDestination(vcursor, bindVars, key.DestinationAllShards{}) + case ByDestination: + return params.byDestination(vcursor, bindVars, params.targetDestination) case None: return nil, nil, nil default: @@ -246,8 +251,8 @@ func (params *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string] return rss, multiBindVars, nil } -func (params *RoutingParameters) allShards(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) +func (params *RoutingParameters) byDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, destination key.Destination) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{destination}) if err != nil { return nil, nil, err } @@ -255,5 +260,5 @@ func (params *RoutingParameters) allShards(vcursor VCursor, bindVars map[string] for i := range multiBindVars { multiBindVars[i] = bindVars } - return rss, multiBindVars, nil + return rss, multiBindVars, err } From 895be38b4b71169a48443dc06030b7f39a286374 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jan 2022 13:21:35 +0530 Subject: [PATCH 05/12] refactor: move equal query routing to common routing logic Signed-off-by: Manan Gupta --- go/vt/vtgate/engine/route.go | 50 ++-------------------------------- go/vt/vtgate/engine/routing.go | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index b30a8e19642..3c43b22765f 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -327,17 +327,12 @@ func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.Bind keyspace: route.Keyspace, sysTableTableName: route.SysTableTableName, sysTableTableSchema: route.SysTableTableSchema, + values: route.Values, + vindex: route.Vindex, } switch route.Opcode { - case SelectDBA, SelectUnsharded, SelectNext, SelectReference, SelectScatter: + case SelectDBA, SelectUnsharded, SelectNext, SelectReference, SelectScatter, SelectEqual, SelectEqualUnique: return params.findRoute(vcursor, bindVars) - case SelectEqual, SelectEqualUnique: - switch route.Vindex.(type) { - case vindexes.MultiColumn: - return route.paramsSelectEqualMultiCol(vcursor, bindVars) - default: - return route.paramsSelectEqual(vcursor, bindVars) - } case SelectIN: switch route.Vindex.(type) { case vindexes.MultiColumn: @@ -450,45 +445,6 @@ func (route *Route) GetFields(vcursor VCursor, bindVars map[string]*querypb.Bind return qr.Truncate(route.TruncateColumnCount), nil } -func (route *Route) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := evalengine.EnvWithBindVars(bindVars) - value, err := env.Evaluate(route.Values[0]) - if err != nil { - return nil, nil, err - } - rss, _, err := resolveShards(vcursor, route.Vindex.(vindexes.SingleColumn), route.Keyspace, []sqltypes.Value{value.Value()}) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *Route) paramsSelectEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := evalengine.EnvWithBindVars(bindVars) - var rowValue []sqltypes.Value - for _, rvalue := range route.Values { - v, err := env.Evaluate(rvalue) - if err != nil { - return nil, nil, err - } - rowValue = append(rowValue, v.Value()) - } - - rss, _, err := resolveShardsMultiCol(vcursor, route.Vindex.(vindexes.MultiColumn), route.Keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - func resolveShardsMultiCol(vcursor VCursor, vindex vindexes.MultiColumn, keyspace *vindexes.Keyspace, rowColValues [][]sqltypes.Value, shardIdsNeeded bool) ([]*srvtopo.ResolvedShard, [][][]*querypb.Value, error) { destinations, err := vindex.Map(vcursor, rowColValues) if err != nil { diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index a7b45770ff5..d41ffaa6726 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -74,6 +74,10 @@ type RoutingParameters struct { // Required for - ByDestination targetDestination key.Destination + + // Required for - In, Equal and MultiEqual + vindex vindexes.Vindex + values []evalengine.Expr } func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { @@ -88,6 +92,13 @@ func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string] return params.byDestination(vcursor, bindVars, key.DestinationAllShards{}) case ByDestination: return params.byDestination(vcursor, bindVars, params.targetDestination) + case Equal: + switch params.vindex.(type) { + case vindexes.MultiColumn: + return params.paramsSelectEqualMultiCol(vcursor, bindVars) + default: + return params.paramsSelectEqual(vcursor, bindVars) + } case None: return nil, nil, nil default: @@ -262,3 +273,42 @@ func (params *RoutingParameters) byDestination(vcursor VCursor, bindVars map[str } return rss, multiBindVars, err } + +func (params *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + env := evalengine.EnvWithBindVars(bindVars) + value, err := env.Evaluate(params.values[0]) + if err != nil { + return nil, nil, err + } + rss, _, err := resolveShards(vcursor, params.vindex.(vindexes.SingleColumn), params.keyspace, []sqltypes.Value{value.Value()}) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} + +func (params *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + env := evalengine.EnvWithBindVars(bindVars) + var rowValue []sqltypes.Value + for _, rvalue := range params.values { + v, err := env.Evaluate(rvalue) + if err != nil { + return nil, nil, err + } + rowValue = append(rowValue, v.Value()) + } + + rss, _, err := resolveShardsMultiCol(vcursor, params.vindex.(vindexes.MultiColumn), params.keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} From f903ee2d8cdb8eb3e47acd7791a8b11bd40ff7bc Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 20 Jan 2022 15:34:45 +0530 Subject: [PATCH 06/12] refactor: route and dml to use routingparameters struct Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 15 +- go/vt/vtgate/engine/delete_test.go | 126 ++++++----- go/vt/vtgate/engine/dml.go | 16 +- go/vt/vtgate/engine/plan_description_test.go | 16 +- go/vt/vtgate/engine/route.go | 41 +--- go/vt/vtgate/engine/route_test.go | 16 +- go/vt/vtgate/engine/routing.go | 89 ++++---- go/vt/vtgate/engine/update_test.go | 211 +++++++++++-------- 8 files changed, 277 insertions(+), 253 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index f3842519b03..33efaf287b7 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -114,11 +114,8 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp } func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - params := RoutingParameters{ - opcode: del.Opcode, - keyspace: del.Keyspace, - } - rss, _, err := params.findRoute(vcursor, bindVars) + del.opcode = del.Opcode + rss, _, err := del.findRoutingInfo(vcursor, bindVars) if err != nil { return nil, err } @@ -205,12 +202,8 @@ func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.Bi } func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - params := RoutingParameters{ - opcode: del.Opcode, - keyspace: del.Keyspace, - targetDestination: dest, - } - rss, _, err := params.findRoute(vcursor, bindVars) + del.opcode = del.Opcode + rss, _, err := del.findRoutingInfo(vcursor, bindVars) if err != nil { return nil, err } diff --git a/go/vt/vtgate/engine/delete_test.go b/go/vt/vtgate/engine/delete_test.go index 989a1b899d3..8bd3380bdf2 100644 --- a/go/vt/vtgate/engine/delete_test.go +++ b/go/vt/vtgate/engine/delete_test.go @@ -35,9 +35,11 @@ func TestDeleteUnsharded(t *testing.T) { del := &Delete{ DML: DML{ Opcode: Unsharded, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: false, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: false, + }, }, Query: "dummy_delete", }, @@ -66,13 +68,15 @@ func TestDeleteEqual(t *testing.T) { del := &Delete{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_delete", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_delete", }, } @@ -96,13 +100,15 @@ func TestDeleteEqualMultiCol(t *testing.T) { del := &Delete{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, }, - Query: "dummy_delete", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + Query: "dummy_delete", }, } @@ -130,13 +136,15 @@ func TestDeleteEqualNoRoute(t *testing.T) { del := &Delete{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_delete", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_delete", }, } @@ -159,13 +167,15 @@ func TestDeleteEqualNoScatter(t *testing.T) { del := &Delete{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, - }, Query: "dummy_delete", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + }, }, } @@ -178,11 +188,13 @@ func TestDeleteOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: Equal, - Keyspace: ks.Keyspace, + Opcode: Equal, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["hash"], + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + }, Query: "dummy_delete", - Vindex: ks.Vindexes["hash"], - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, Table: ks.Tables["t1"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["hash"], @@ -262,11 +274,13 @@ func TestDeleteOwnedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: Equal, - Keyspace: ks.Keyspace, + Opcode: Equal, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["rg_vdx"], + Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + }, Query: "dummy_delete", - Vindex: ks.Vindexes["rg_vdx"], - Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, Table: ks.Tables["rg_tbl"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["rg_vdx"], @@ -343,10 +357,12 @@ func TestDeleteSharded(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: Scatter, - Keyspace: ks.Keyspace, - Query: "dummy_delete", - Table: ks.Tables["t2"], + Opcode: Scatter, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + }, + Query: "dummy_delete", + Table: ks.Tables["t2"], }, } @@ -368,10 +384,12 @@ func TestDeleteShardedStreaming(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: Scatter, - Keyspace: ks.Keyspace, - Query: "dummy_delete", - Table: ks.Tables["t2"], + Opcode: Scatter, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + }, + Query: "dummy_delete", + Table: ks.Tables["t2"], }, } @@ -390,8 +408,10 @@ func TestDeleteScatterOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: Scatter, - Keyspace: ks.Keyspace, + Opcode: Scatter, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + }, Query: "dummy_delete", Table: ks.Tables["t1"], OwnedVindexQuery: "dummy_subquery", @@ -473,14 +493,16 @@ func TestDeleteInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["rg_vdx"], - Values: []evalengine.Expr{ - &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, - evalengine.NewLiteralInt(3), + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["rg_vdx"], + Values: []evalengine.Expr{ + &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + evalengine.NewLiteralInt(3), + }, }, + Query: "dummy_update", Table: ks.Tables["rg_tbl"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["rg_vdx"], diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index 5a58bc80447..30e84394e0a 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -36,22 +36,9 @@ type DML struct { // Opcode is the execution opcode. Opcode Opcode - // Keyspace specifies the keyspace to send the query to. - Keyspace *vindexes.Keyspace - - // TargetDestination specifies the destination to send the query to. - TargetDestination key.Destination - // Query specifies the query to be executed. Query string - // Vindex specifies the vindex to be used. - Vindex vindexes.Vindex - - // Values specifies the vindex values to use for routing. - // For now, only one value is specified. - Values []evalengine.Expr - // KsidVindex is primary Vindex KsidVindex vindexes.Vindex @@ -71,6 +58,9 @@ type DML struct { // QueryTimeout contains the optional timeout (in milliseconds) to apply to this query QueryTimeout int + // RoutingParameters parameters required for query routing. + *RoutingParameters + txNeeded } diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 3a616035d56..50c2fe2dabc 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -52,13 +52,15 @@ func TestCreateRoutePlanDescription(t *testing.T) { func createRoute() *Route { hash, _ := vindexes.NewHash("vindex name", nil) return &Route{ - Opcode: SelectScatter, - Keyspace: &vindexes.Keyspace{Name: "ks"}, - TargetDestination: key.DestinationAllShards{}, - Query: "select all the things", - TableName: "tableName", - FieldQuery: "more query", - Vindex: hash.(*vindexes.Hash), + Opcode: SelectScatter, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{Name: "ks"}, + TargetDestination: key.DestinationAllShards{}, + Vindex: hash.(*vindexes.Hash), + }, + Query: "select all the things", + TableName: "tableName", + FieldQuery: "more query", } } diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 3c43b22765f..3e937a66adf 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -49,13 +49,6 @@ type Route struct { // Opcode is the execution opcode. Opcode RouteOpcode - // Keyspace specifies the keyspace to send the query to. - Keyspace *vindexes.Keyspace - - // TargetDestination specifies an explicit target destination to send the query to. - // This bypases the core of the v3 engine. - TargetDestination key.Destination - // TargetTabletType specifies an explicit target destination tablet type // this is only used in conjunction with TargetDestination TargetTabletType topodatapb.TabletType @@ -69,12 +62,6 @@ type Route struct { // FieldQuery specifies the query to be executed for a GetFieldInfo request. FieldQuery string - // Vindex specifies the vindex to be used. - Vindex vindexes.Vindex - - // Values specifies the vindex values to use for routing. - Values []evalengine.Expr - // OrderBy specifies the key order for merge sorting. This will be // set only for scatter queries that need the results to be // merge-sorted. @@ -91,9 +78,8 @@ type Route struct { // ScatterErrorsAsWarnings is true if results should be returned even if some shards have an error ScatterErrorsAsWarnings bool - // The following two fields are used when routing information_schema queries - SysTableTableSchema []evalengine.Expr - SysTableTableName map[string]evalengine.Expr + // RoutingParameters parameters required for query routing. + *RoutingParameters // Route does not take inputs noInputs @@ -105,18 +91,18 @@ type Route struct { // NewSimpleRoute creates a Route with the bare minimum of parameters. func NewSimpleRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace) *Route { return &Route{ - Opcode: opcode, - Keyspace: keyspace, + Opcode: opcode, + RoutingParameters: &RoutingParameters{Keyspace: keyspace}, } } // NewRoute creates a Route. func NewRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route { return &Route{ - Opcode: opcode, - Keyspace: keyspace, - Query: query, - FieldQuery: fieldQuery, + Opcode: opcode, + RoutingParameters: &RoutingParameters{Keyspace: keyspace}, + Query: query, + FieldQuery: fieldQuery, } } @@ -322,17 +308,10 @@ func (route *Route) executeInternal(vcursor VCursor, bindVars map[string]*queryp } func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - params := RoutingParameters{ - opcode: route.GetGenericOpcode(), - keyspace: route.Keyspace, - sysTableTableName: route.SysTableTableName, - sysTableTableSchema: route.SysTableTableSchema, - values: route.Values, - vindex: route.Vindex, - } + route.opcode = route.GetGenericOpcode() switch route.Opcode { case SelectDBA, SelectUnsharded, SelectNext, SelectReference, SelectScatter, SelectEqual, SelectEqualUnique: - return params.findRoute(vcursor, bindVars) + return route.findRoutingInfo(vcursor, bindVars) case SelectIN: switch route.Vindex.(type) { case vindexes.MultiColumn: diff --git a/go/vt/vtgate/engine/route_test.go b/go/vt/vtgate/engine/route_test.go index 0a43495a849..7727c9fea1e 100644 --- a/go/vt/vtgate/engine/route_test.go +++ b/go/vt/vtgate/engine/route_test.go @@ -164,14 +164,16 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) t.Run(tc.testName, func(t *testing.T) { sel := &Route{ Opcode: SelectDBA, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: false, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: false, + }, + SysTableTableSchema: stringListToExprList(tc.tableSchema), + SysTableTableName: tc.tableName, }, - Query: "dummy_select", - FieldQuery: "dummy_select_field", - SysTableTableSchema: stringListToExprList(tc.tableSchema), - SysTableTableName: tc.tableName, + Query: "dummy_select", + FieldQuery: "dummy_select_field", } vc := &loggingVCursor{ shards: []string{"1"}, diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index d41ffaa6726..e127a7910bd 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -65,50 +65,55 @@ const ( type RoutingParameters struct { // Required for - All - opcode Opcode - keyspace *vindexes.Keyspace + opcode Opcode - // Required for - DBA - sysTableTableSchema []evalengine.Expr - sysTableTableName map[string]evalengine.Expr + // Keyspace specifies the keyspace to send the query to. + Keyspace *vindexes.Keyspace - // Required for - ByDestination - targetDestination key.Destination + // The following two fields are used when routing information_schema queries + SysTableTableSchema []evalengine.Expr + SysTableTableName map[string]evalengine.Expr - // Required for - In, Equal and MultiEqual - vindex vindexes.Vindex - values []evalengine.Expr + // TargetDestination specifies an explicit target destination to send the query to. + // This will bypass the routing logic. + TargetDestination key.Destination + + // Vindex specifies the vindex to be used. + Vindex vindexes.Vindex + + // Values specifies the vindex values to use for routing. + Values []evalengine.Expr } -func (params *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - switch params.opcode { +func (rp *RoutingParameters) findRoutingInfo(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + switch rp.opcode { case DBA: - return params.systemQuery(vcursor, bindVars) + return rp.systemQuery(vcursor, bindVars) case Unsharded: - return params.unsharded(vcursor, bindVars) + return rp.unsharded(vcursor, bindVars) case Any: - return params.anyShard(vcursor, bindVars) + return rp.anyShard(vcursor, bindVars) case Scatter: - return params.byDestination(vcursor, bindVars, key.DestinationAllShards{}) + return rp.byDestination(vcursor, bindVars, key.DestinationAllShards{}) case ByDestination: - return params.byDestination(vcursor, bindVars, params.targetDestination) + return rp.byDestination(vcursor, bindVars, rp.TargetDestination) case Equal: - switch params.vindex.(type) { + switch rp.Vindex.(type) { case vindexes.MultiColumn: - return params.paramsSelectEqualMultiCol(vcursor, bindVars) + return rp.paramsSelectEqualMultiCol(vcursor, bindVars) default: - return params.paramsSelectEqual(vcursor, bindVars) + return rp.paramsSelectEqual(vcursor, bindVars) } case None: return nil, nil, nil default: // Unreachable. - return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", params.opcode) + return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", rp.opcode) } } -func (params *RoutingParameters) systemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - destinations, err := params.routeInfoSchemaQuery(vcursor, bindVars) +func (rp *RoutingParameters) systemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + destinations, err := rp.routeInfoSchemaQuery(vcursor, bindVars) if err != nil { return nil, nil, err } @@ -116,20 +121,20 @@ func (params *RoutingParameters) systemQuery(vcursor VCursor, bindVars map[strin return destinations, []map[string]*querypb.BindVariable{bindVars}, nil } -func (params *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, error) { +func (rp *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, error) { defaultRoute := func() ([]*srvtopo.ResolvedShard, error) { - ks := params.keyspace.Name + ks := rp.Keyspace.Name destinations, _, err := vcursor.ResolveDestinations(ks, nil, []key.Destination{key.DestinationAnyShard{}}) return destinations, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", ks) } - if len(params.sysTableTableName) == 0 && len(params.sysTableTableSchema) == 0 { + if len(rp.SysTableTableName) == 0 && len(rp.SysTableTableSchema) == 0 { return defaultRoute() } env := evalengine.EnvWithBindVars(bindVars) var specifiedKS string - for _, tableSchema := range params.sysTableTableSchema { + for _, tableSchema := range rp.SysTableTableSchema { result, err := env.Evaluate(tableSchema) if err != nil { return nil, err @@ -147,7 +152,7 @@ func (params *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars } tableNames := map[string]string{} - for tblBvName, sysTableName := range params.sysTableTableName { + for tblBvName, sysTableName := range rp.SysTableTableName { val, err := env.Evaluate(sysTableName) if err != nil { return nil, err @@ -164,7 +169,7 @@ func (params *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars // the use has specified a table_name - let's check if it's a routed table if len(tableNames) > 0 { - rss, err := params.routedTable(vcursor, bindVars, specifiedKS, tableNames) + rss, err := rp.routedTable(vcursor, bindVars, specifiedKS, tableNames) if err != nil { // Only if keyspace is not found in vschema, we try with default keyspace. // As the in the table_schema predicates for a keyspace 'ks' it can contain 'vt_ks'. @@ -194,7 +199,7 @@ func (params *RoutingParameters) routeInfoSchemaQuery(vcursor VCursor, bindVars return destinations, nil } -func (params *RoutingParameters) routedTable(vcursor VCursor, bindVars map[string]*querypb.BindVariable, tableSchema string, tableNames map[string]string) ([]*srvtopo.ResolvedShard, error) { +func (rp *RoutingParameters) routedTable(vcursor VCursor, bindVars map[string]*querypb.BindVariable, tableSchema string, tableNames map[string]string) ([]*srvtopo.ResolvedShard, error) { var routedKs *vindexes.Keyspace for tblBvName, tableName := range tableNames { tbl := sqlparser.TableName{ @@ -235,8 +240,8 @@ func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) } -func (params *RoutingParameters) anyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) +func (rp *RoutingParameters) anyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(rp.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) if err != nil { return nil, nil, err } @@ -247,8 +252,8 @@ func (params *RoutingParameters) anyShard(vcursor VCursor, bindVars map[string]* return rss, multiBindVars, nil } -func (params *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) +func (rp *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(rp.Keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) if err != nil { return nil, nil, err } @@ -262,8 +267,8 @@ func (params *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string] return rss, multiBindVars, nil } -func (params *RoutingParameters) byDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, destination key.Destination) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rss, _, err := vcursor.ResolveDestinations(params.keyspace.Name, nil, []key.Destination{destination}) +func (rp *RoutingParameters) byDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, destination key.Destination) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rss, _, err := vcursor.ResolveDestinations(rp.Keyspace.Name, nil, []key.Destination{destination}) if err != nil { return nil, nil, err } @@ -274,13 +279,13 @@ func (params *RoutingParameters) byDestination(vcursor VCursor, bindVars map[str return rss, multiBindVars, err } -func (params *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) - value, err := env.Evaluate(params.values[0]) + value, err := env.Evaluate(rp.Values[0]) if err != nil { return nil, nil, err } - rss, _, err := resolveShards(vcursor, params.vindex.(vindexes.SingleColumn), params.keyspace, []sqltypes.Value{value.Value()}) + rss, _, err := resolveShards(vcursor, rp.Vindex.(vindexes.SingleColumn), rp.Keyspace, []sqltypes.Value{value.Value()}) if err != nil { return nil, nil, err } @@ -291,10 +296,10 @@ func (params *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map return rss, multiBindVars, nil } -func (params *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) var rowValue []sqltypes.Value - for _, rvalue := range params.values { + for _, rvalue := range rp.Values { v, err := env.Evaluate(rvalue) if err != nil { return nil, nil, err @@ -302,7 +307,7 @@ func (params *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bind rowValue = append(rowValue, v.Value()) } - rss, _, err := resolveShardsMultiCol(vcursor, params.vindex.(vindexes.MultiColumn), params.keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) + rss, _, err := resolveShardsMultiCol(vcursor, rp.Vindex.(vindexes.MultiColumn), rp.Keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) if err != nil { return nil, nil, err } diff --git a/go/vt/vtgate/engine/update_test.go b/go/vt/vtgate/engine/update_test.go index f280ca3e251..41fb6f0b781 100644 --- a/go/vt/vtgate/engine/update_test.go +++ b/go/vt/vtgate/engine/update_test.go @@ -38,10 +38,13 @@ func TestUpdateUnsharded(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Unsharded, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: false, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: false, + }, }, + Query: "dummy_update", }, } @@ -69,13 +72,15 @@ func TestUpdateEqual(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_update", }, } @@ -98,13 +103,15 @@ func TestUpdateEqualMultiCol(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, }, - Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + Query: "dummy_update", }, } @@ -122,13 +129,15 @@ func TestUpdateScatter(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Scatter, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_update", }, } @@ -145,13 +154,15 @@ func TestUpdateScatter(t *testing.T) { upd = &Update{ DML: DML{ Opcode: Scatter, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, MultiShardAutocommit: true, }, } @@ -175,13 +186,15 @@ func TestUpdateEqualNoRoute(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_update", }, } @@ -204,13 +217,15 @@ func TestUpdateEqualNoScatter(t *testing.T) { upd := &Update{ DML: DML{ Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, + RoutingParameters: &RoutingParameters{ + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, - Query: "dummy_update", - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + Query: "dummy_update", }, } @@ -223,11 +238,13 @@ func TestUpdateEqualChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: DML{ - Opcode: Equal, - Keyspace: ks.Keyspace, + Opcode: Equal, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["hash"], + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + }, Query: "dummy_update", - Vindex: ks.Vindexes["hash"], - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, Table: ks.Tables["t1"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["hash"], @@ -364,11 +381,13 @@ func TestUpdateEqualMultiColChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: DML{ - Opcode: Equal, - Keyspace: ks.Keyspace, + Opcode: Equal, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["rg_vdx"], + Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + }, Query: "dummy_update", - Vindex: ks.Vindexes["rg_vdx"], - Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, Table: ks.Tables["rg_tbl"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["rg_vdx"], @@ -483,8 +502,10 @@ func TestUpdateScatterChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: DML{ - Opcode: Scatter, - Keyspace: ks.Keyspace, + Opcode: Scatter, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + }, Query: "dummy_update", Table: ks.Tables["t1"], OwnedVindexQuery: "dummy_subquery", @@ -591,15 +612,18 @@ func TestUpdateScatterChangedVindex(t *testing.T) { func TestUpdateIn(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] - upd := &Update{DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["hash"], - Values: []evalengine.Expr{&evalengine.TupleExpr{ - evalengine.NewLiteralInt(1), - evalengine.NewLiteralInt(2), - }}}, + upd := &Update{ + DML: DML{ + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["hash"], + Values: []evalengine.Expr{&evalengine.TupleExpr{ + evalengine.NewLiteralInt(1), + evalengine.NewLiteralInt(2), + }}}, + Query: "dummy_update", + }, } vc := newDMLTestVCursor("-20", "20-") @@ -615,15 +639,16 @@ func TestUpdateIn(t *testing.T) { func TestUpdateInStreamExecute(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["hash"], - Values: []evalengine.Expr{&evalengine.TupleExpr{ - evalengine.NewLiteralInt(1), - evalengine.NewLiteralInt(2), - }}}, - } + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["hash"], + Values: []evalengine.Expr{&evalengine.TupleExpr{ + evalengine.NewLiteralInt(1), + evalengine.NewLiteralInt(2), + }}}, + Query: "dummy_update", + }} vc := newDMLTestVCursor("-20", "20-") err := upd.TryStreamExecute(vc, map[string]*querypb.BindVariable{}, false, func(result *sqltypes.Result) error { @@ -640,15 +665,17 @@ func TestUpdateInStreamExecute(t *testing.T) { func TestUpdateInMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["rg_vdx"], - Values: []evalengine.Expr{ - &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, - &evalengine.TupleExpr{evalengine.NewLiteralInt(3), evalengine.NewLiteralInt(4)}, - }}, - } + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["rg_vdx"], + Values: []evalengine.Expr{ + &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + &evalengine.TupleExpr{evalengine.NewLiteralInt(3), evalengine.NewLiteralInt(4)}, + }, + }, + Query: "dummy_update", + }} vc := newDMLTestVCursor("-20", "20-") _, err := upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) @@ -664,14 +691,16 @@ func TestUpdateInChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["hash"], - Values: []evalengine.Expr{&evalengine.TupleExpr{ - evalengine.NewLiteralInt(1), - evalengine.NewLiteralInt(2), - }}, + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["hash"], + Values: []evalengine.Expr{&evalengine.TupleExpr{ + evalengine.NewLiteralInt(1), + evalengine.NewLiteralInt(2), + }}, + }, + Query: "dummy_update", Table: ks.Tables["t1"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["hash"], @@ -791,14 +820,16 @@ func TestUpdateInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: DML{ - Opcode: In, - Keyspace: ks.Keyspace, - Query: "dummy_update", - Vindex: ks.Vindexes["rg_vdx"], - Values: []evalengine.Expr{ - &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, - evalengine.NewLiteralInt(3), + Opcode: In, + RoutingParameters: &RoutingParameters{ + Keyspace: ks.Keyspace, + Vindex: ks.Vindexes["rg_vdx"], + Values: []evalengine.Expr{ + &evalengine.TupleExpr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, + evalengine.NewLiteralInt(3), + }, }, + Query: "dummy_update", Table: ks.Tables["rg_tbl"], OwnedVindexQuery: "dummy_subquery", KsidVindex: ks.Vindexes["rg_vdx"], From b6b161435727a5228a6c7e52513a16ac936c4e34 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 20 Jan 2022 16:28:17 +0530 Subject: [PATCH 07/12] refactor: dml struct as reference to update and delete primitive Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 4 +-- go/vt/vtgate/engine/delete_test.go | 22 +++++++------- go/vt/vtgate/engine/dml.go | 5 ++++ go/vt/vtgate/engine/update.go | 2 +- go/vt/vtgate/engine/update_test.go | 30 +++++++++---------- go/vt/vtgate/planbuilder/delete.go | 4 +-- go/vt/vtgate/planbuilder/dml.go | 2 +- .../planbuilder/operator_transformers.go | 16 +++++----- go/vt/vtgate/planbuilder/update.go | 4 +-- 9 files changed, 46 insertions(+), 43 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 33efaf287b7..ffa90901e0a 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -38,7 +38,7 @@ var _ Primitive = (*Delete)(nil) // Delete represents the instructions to perform a delete. type Delete struct { - DML + *DML // Delete does not take inputs noInputs @@ -289,7 +289,7 @@ func (del *Delete) description() PrimitiveDescription { } } -func addFieldsIfNotEmpty(dml DML, other map[string]interface{}) { +func addFieldsIfNotEmpty(dml *DML, other map[string]interface{}) { if dml.Vindex != nil { other["Vindex"] = dml.Vindex.String() } diff --git a/go/vt/vtgate/engine/delete_test.go b/go/vt/vtgate/engine/delete_test.go index 8bd3380bdf2..51074e12925 100644 --- a/go/vt/vtgate/engine/delete_test.go +++ b/go/vt/vtgate/engine/delete_test.go @@ -33,7 +33,7 @@ import ( func TestDeleteUnsharded(t *testing.T) { del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Unsharded, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -66,7 +66,7 @@ func TestDeleteUnsharded(t *testing.T) { func TestDeleteEqual(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -98,7 +98,7 @@ func TestDeleteEqual(t *testing.T) { func TestDeleteEqualMultiCol(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -134,7 +134,7 @@ func TestDeleteEqualNoRoute(t *testing.T) { "to": "toc", }) del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -165,7 +165,7 @@ func TestDeleteEqualNoScatter(t *testing.T) { "write_only": "true", }) del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, Query: "dummy_delete", RoutingParameters: &RoutingParameters{ @@ -187,7 +187,7 @@ func TestDeleteEqualNoScatter(t *testing.T) { func TestDeleteOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -273,7 +273,7 @@ func TestDeleteOwnedVindex(t *testing.T) { func TestDeleteOwnedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -356,7 +356,7 @@ func TestDeleteOwnedVindexMultiCol(t *testing.T) { func TestDeleteSharded(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -383,7 +383,7 @@ func TestDeleteSharded(t *testing.T) { func TestDeleteShardedStreaming(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -407,7 +407,7 @@ func TestDeleteShardedStreaming(t *testing.T) { func TestDeleteScatterOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -492,7 +492,7 @@ func TestDeleteScatterOwnedVindex(t *testing.T) { func TestDeleteInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ - DML: DML{ + DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index 30e84394e0a..7d6e4e7b3a5 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -64,6 +64,11 @@ type DML struct { txNeeded } +// NewDML returns and empty initialized DML struct. +func NewDML() *DML { + return &DML{RoutingParameters: &RoutingParameters{}} +} + var opcodeName = map[Opcode]string{ Unsharded: "Unsharded", Equal: "Equal", diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index f17594de799..11135ff9d92 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -45,7 +45,7 @@ type VindexValues struct { // Update represents the instructions to perform an update. type Update struct { - DML + *DML // ChangedVindexValues contains values for updated Vindexes during an update statement. ChangedVindexValues map[string]*VindexValues diff --git a/go/vt/vtgate/engine/update_test.go b/go/vt/vtgate/engine/update_test.go index 41fb6f0b781..0b38e3b15b8 100644 --- a/go/vt/vtgate/engine/update_test.go +++ b/go/vt/vtgate/engine/update_test.go @@ -36,7 +36,7 @@ import ( func TestUpdateUnsharded(t *testing.T) { upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Unsharded, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -70,7 +70,7 @@ func TestUpdateUnsharded(t *testing.T) { func TestUpdateEqual(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -101,7 +101,7 @@ func TestUpdateEqual(t *testing.T) { func TestUpdateEqualMultiCol(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -127,7 +127,7 @@ func TestUpdateEqualMultiCol(t *testing.T) { func TestUpdateScatter(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -152,7 +152,7 @@ func TestUpdateScatter(t *testing.T) { // works with multishard autocommit upd = &Update{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -184,7 +184,7 @@ func TestUpdateEqualNoRoute(t *testing.T) { "to": "toc", }) upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -215,7 +215,7 @@ func TestUpdateEqualNoScatter(t *testing.T) { "write_only": "true", }) upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: &vindexes.Keyspace{ @@ -237,7 +237,7 @@ func TestUpdateEqualNoScatter(t *testing.T) { func TestUpdateEqualChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -380,7 +380,7 @@ func TestUpdateEqualChangedVindex(t *testing.T) { func TestUpdateEqualMultiColChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Equal, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -501,7 +501,7 @@ func TestUpdateScatterChangedVindex(t *testing.T) { // update t1 set c1 = 1, c2 = 2, c3 = 3 ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: Scatter, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -613,7 +613,7 @@ func TestUpdateScatterChangedVindex(t *testing.T) { func TestUpdateIn(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -638,7 +638,7 @@ func TestUpdateIn(t *testing.T) { func TestUpdateInStreamExecute(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] - upd := &Update{DML: DML{ + upd := &Update{DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -664,7 +664,7 @@ func TestUpdateInStreamExecute(t *testing.T) { func TestUpdateInMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] - upd := &Update{DML: DML{ + upd := &Update{DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -690,7 +690,7 @@ func TestUpdateInMultiCol(t *testing.T) { func TestUpdateInChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, @@ -819,7 +819,7 @@ func TestUpdateInChangedVindex(t *testing.T) { func TestUpdateInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ - DML: DML{ + DML: &DML{ Opcode: In, RoutingParameters: &RoutingParameters{ Keyspace: ks.Keyspace, diff --git a/go/vt/vtgate/planbuilder/delete.go b/go/vt/vtgate/planbuilder/delete.go index 1ed96105f6d..fca01117af0 100644 --- a/go/vt/vtgate/planbuilder/delete.go +++ b/go/vt/vtgate/planbuilder/delete.go @@ -41,9 +41,7 @@ func buildDeletePlan(stmt sqlparser.Statement, reservedVars *sqlparser.ReservedV if err != nil { return nil, err } - edel := &engine.Delete{ - DML: *dml, - } + edel := &engine.Delete{DML: dml} if dml.Opcode == engine.Unsharded { return edel, nil diff --git a/go/vt/vtgate/planbuilder/dml.go b/go/vt/vtgate/planbuilder/dml.go index 9c2d9e221aa..2e6b7aee4c2 100644 --- a/go/vt/vtgate/planbuilder/dml.go +++ b/go/vt/vtgate/planbuilder/dml.go @@ -281,7 +281,7 @@ func costForDML(foundVindex *vindexes.ColumnVindex, opcode engine.Opcode) costDM } func buildDMLPlan(vschema plancontext.VSchema, dmlType string, stmt sqlparser.Statement, reservedVars *sqlparser.ReservedVars, tableExprs sqlparser.TableExprs, where *sqlparser.Where, orderBy sqlparser.OrderBy, limit *sqlparser.Limit, comments sqlparser.Comments, nodes ...sqlparser.SQLNode) (*engine.DML, *vindexes.ColumnVindex, error) { - edml := &engine.DML{} + edml := engine.NewDML() pb := newPrimitiveBuilder(vschema, newJointab(reservedVars)) rb, err := pb.processDMLTable(tableExprs, reservedVars, nil) if err != nil { diff --git a/go/vt/vtgate/planbuilder/operator_transformers.go b/go/vt/vtgate/planbuilder/operator_transformers.go index df56a179b1c..44846f7ae0b 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -146,13 +146,15 @@ func transformRoutePlan(ctx *plancontext.PlanningContext, op *physical.Route) (* replaceSubQuery(ctx, sel) return &routeGen4{ eroute: &engine.Route{ - Opcode: op.RouteOpCode, - TableName: strings.Join(tableNames, ", "), - Keyspace: op.Keyspace, - Vindex: vindex, - Values: values, - SysTableTableName: op.SysTableTableName, - SysTableTableSchema: op.SysTableTableSchema, + Opcode: op.RouteOpCode, + TableName: strings.Join(tableNames, ", "), + RoutingParameters: &engine.RoutingParameters{ + Keyspace: op.Keyspace, + Vindex: vindex, + Values: values, + SysTableTableName: op.SysTableTableName, + SysTableTableSchema: op.SysTableTableSchema, + }, }, Select: sel, tables: op.TableID(), diff --git a/go/vt/vtgate/planbuilder/update.go b/go/vt/vtgate/planbuilder/update.go index c1bb54c6fb3..870fc0d2cad 100644 --- a/go/vt/vtgate/planbuilder/update.go +++ b/go/vt/vtgate/planbuilder/update.go @@ -39,9 +39,7 @@ func buildUpdatePlan(stmt sqlparser.Statement, reservedVars *sqlparser.ReservedV if err != nil { return nil, err } - eupd := &engine.Update{ - DML: *dml, - } + eupd := &engine.Update{DML: dml} if dml.Opcode == engine.Unsharded { return eupd, nil From bcf98c399491ea8da6e80b7b6b96beed58370098 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 20 Jan 2022 18:36:08 +0530 Subject: [PATCH 08/12] refactor: moved opcode to RoutingParameters to use common opcodes, changed test expectations Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 14 +- go/vt/vtgate/engine/delete_test.go | 24 +- go/vt/vtgate/engine/dml.go | 15 - go/vt/vtgate/engine/plan_description_test.go | 6 +- go/vt/vtgate/engine/route.go | 126 +---- go/vt/vtgate/engine/route_test.go | 76 +-- go/vt/vtgate/engine/routing.go | 71 ++- go/vt/vtgate/engine/update.go | 12 +- go/vt/vtgate/engine/update_test.go | 30 +- go/vt/vtgate/executor.go | 2 +- go/vt/vtgate/executor_scatter_stats.go | 2 +- go/vt/vtgate/executor_test.go | 2 +- go/vt/vtgate/planbuilder/ddl.go | 8 +- go/vt/vtgate/planbuilder/dml.go | 2 +- go/vt/vtgate/planbuilder/from.go | 14 +- .../planbuilder/operator_transformers.go | 20 +- go/vt/vtgate/planbuilder/physical/route.go | 56 +-- .../planbuilder/physical/route_planning.go | 30 +- go/vt/vtgate/planbuilder/physical/vindex.go | 2 +- go/vt/vtgate/planbuilder/route.go | 168 +++---- go/vt/vtgate/planbuilder/routeGen4.go | 26 +- go/vt/vtgate/planbuilder/route_test.go | 81 ++-- go/vt/vtgate/planbuilder/select.go | 14 +- .../planbuilder/single_sharded_shortcut.go | 6 +- go/vt/vtgate/planbuilder/subquery_op.go | 8 +- .../planbuilder/testdata/aggr_cases.txt | 234 +++++----- .../vtgate/planbuilder/testdata/dml_cases.txt | 20 +- .../planbuilder/testdata/filter_cases.txt | 376 +++++++-------- .../planbuilder/testdata/from_cases.txt | 442 +++++++++--------- .../planbuilder/testdata/hash_joins.txt | 50 +- .../planbuilder/testdata/large_cases.txt | 24 +- .../testdata/memory_sort_cases.txt | 70 +-- .../planbuilder/testdata/oltp_cases.txt | 16 +- .../testdata/postprocess_cases.txt | 202 ++++---- .../planbuilder/testdata/rails_cases.txt | 18 +- .../planbuilder/testdata/select_cases.txt | 270 +++++------ .../planbuilder/testdata/symtab_cases.txt | 4 +- .../testdata/sysschema_default.txt | 12 +- .../testdata/systemtables_cases.txt | 150 +++--- .../planbuilder/testdata/tpcc_cases.txt | 54 +-- .../planbuilder/testdata/tpch_cases.txt | 32 +- .../planbuilder/testdata/union_cases.txt | 176 +++---- .../testdata/unsupported_cases.txt | 10 +- .../testdata/vindex_func_cases.txt | 24 +- .../planbuilder/testdata/wireup_cases.txt | 138 +++--- 45 files changed, 1525 insertions(+), 1612 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index ffa90901e0a..518db9ae2f4 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -44,17 +44,9 @@ type Delete struct { noInputs } -var delName = map[Opcode]string{ - Unsharded: "DeleteUnsharded", - Equal: "DeleteEqual", - In: "DeleteIn", - Scatter: "DeleteScatter", - ByDestination: "DeleteByDestination", -} - // RouteType returns a description of the query routing type used by the primitive func (del *Delete) RouteType() string { - return delName[del.Opcode] + return del.Opcode.String() } // GetKeyspaceName specifies the Keyspace that this primitive routes to. @@ -87,7 +79,7 @@ func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind default: return del.execDeleteEqual(vcursor, bindVars) } - case In: + case IN: return del.execDeleteIn(vcursor, bindVars) case Scatter: return del.execDeleteByDestination(vcursor, bindVars, key.DestinationAllShards{}) @@ -114,7 +106,6 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp } func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - del.opcode = del.Opcode rss, _, err := del.findRoutingInfo(vcursor, bindVars) if err != nil { return nil, err @@ -202,7 +193,6 @@ func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.Bi } func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - del.opcode = del.Opcode rss, _, err := del.findRoutingInfo(vcursor, bindVars) if err != nil { return nil, err diff --git a/go/vt/vtgate/engine/delete_test.go b/go/vt/vtgate/engine/delete_test.go index 51074e12925..0eee9c828de 100644 --- a/go/vt/vtgate/engine/delete_test.go +++ b/go/vt/vtgate/engine/delete_test.go @@ -34,8 +34,8 @@ import ( func TestDeleteUnsharded(t *testing.T) { del := &Delete{ DML: &DML{ - Opcode: Unsharded, RoutingParameters: &RoutingParameters{ + Opcode: Unsharded, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -67,8 +67,8 @@ func TestDeleteEqual(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) del := &Delete{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -99,8 +99,8 @@ func TestDeleteEqualMultiCol(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) del := &Delete{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -135,8 +135,8 @@ func TestDeleteEqualNoRoute(t *testing.T) { }) del := &Delete{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -166,9 +166,8 @@ func TestDeleteEqualNoScatter(t *testing.T) { }) del := &Delete{ DML: &DML{ - Opcode: Equal, - Query: "dummy_delete", RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -176,6 +175,7 @@ func TestDeleteEqualNoScatter(t *testing.T) { Vindex: vindex, Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, }, + Query: "dummy_delete", }, } @@ -188,8 +188,8 @@ func TestDeleteOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["hash"], Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, @@ -274,8 +274,8 @@ func TestDeleteOwnedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["rg_vdx"], Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, @@ -357,8 +357,8 @@ func TestDeleteSharded(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: ks.Keyspace, }, Query: "dummy_delete", @@ -384,8 +384,8 @@ func TestDeleteShardedStreaming(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: ks.Keyspace, }, Query: "dummy_delete", @@ -408,8 +408,8 @@ func TestDeleteScatterOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: ks.Keyspace, }, Query: "dummy_delete", @@ -493,8 +493,8 @@ func TestDeleteInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["rg_vdx"], Values: []evalengine.Expr{ diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index 7d6e4e7b3a5..cf4bb69edd5 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -33,9 +33,6 @@ import ( // DML contains the common elements between Update and Delete plans type DML struct { - // Opcode is the execution opcode. - Opcode Opcode - // Query specifies the query to be executed. Query string @@ -69,18 +66,6 @@ func NewDML() *DML { return &DML{RoutingParameters: &RoutingParameters{}} } -var opcodeName = map[Opcode]string{ - Unsharded: "Unsharded", - Equal: "Equal", - In: "In", - Scatter: "Scatter", - ByDestination: "ByDestination", -} - -func (op Opcode) String() string { - return opcodeName[op] -} - func resolveMultiValueShards( vcursor VCursor, keyspace *vindexes.Keyspace, diff --git a/go/vt/vtgate/engine/plan_description_test.go b/go/vt/vtgate/engine/plan_description_test.go index 50c2fe2dabc..d21218244a9 100644 --- a/go/vt/vtgate/engine/plan_description_test.go +++ b/go/vt/vtgate/engine/plan_description_test.go @@ -34,7 +34,7 @@ func TestCreateRoutePlanDescription(t *testing.T) { expected := PrimitiveDescription{ OperatorType: "Route", - Variant: "SelectScatter", + Variant: "Scatter", Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, Other: map[string]interface{}{ @@ -52,8 +52,8 @@ func TestCreateRoutePlanDescription(t *testing.T) { func createRoute() *Route { hash, _ := vindexes.NewHash("vindex name", nil) return &Route{ - Opcode: SelectScatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, Vindex: hash.(*vindexes.Hash), @@ -92,7 +92,7 @@ func TestPlanDescriptionWithInputs(t *testing.T) { func getDescriptionFor(route *Route) PrimitiveDescription { return PrimitiveDescription{ OperatorType: "Route", - Variant: routeName[route.Opcode], + Variant: route.Opcode.String(), Keyspace: &vindexes.Keyspace{Name: "ks"}, TargetDestination: key.DestinationAllShards{}, Other: map[string]interface{}{ diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 3e937a66adf..38e0007c4ff 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -17,7 +17,6 @@ limitations under the License. package engine import ( - "encoding/json" "fmt" "sort" "strconv" @@ -45,10 +44,6 @@ var _ Primitive = (*Route)(nil) // Route represents the instructions to route a read query to // one or many vttablets. type Route struct { - // the fields are described in the RouteOpcode values comments. - // Opcode is the execution opcode. - Opcode RouteOpcode - // TargetTabletType specifies an explicit target destination tablet type // this is only used in conjunction with TargetDestination TargetTabletType topodatapb.TabletType @@ -89,20 +84,24 @@ type Route struct { } // NewSimpleRoute creates a Route with the bare minimum of parameters. -func NewSimpleRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace) *Route { +func NewSimpleRoute(opcode Opcode, keyspace *vindexes.Keyspace) *Route { return &Route{ - Opcode: opcode, - RoutingParameters: &RoutingParameters{Keyspace: keyspace}, + RoutingParameters: &RoutingParameters{ + Opcode: opcode, + Keyspace: keyspace, + }, } } // NewRoute creates a Route. -func NewRoute(opcode RouteOpcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route { +func NewRoute(opcode Opcode, keyspace *vindexes.Keyspace, query, fieldQuery string) *Route { return &Route{ - Opcode: opcode, - RoutingParameters: &RoutingParameters{Keyspace: keyspace}, - Query: query, - FieldQuery: fieldQuery, + RoutingParameters: &RoutingParameters{ + Opcode: opcode, + Keyspace: keyspace, + }, + Query: query, + FieldQuery: fieldQuery, } } @@ -142,75 +141,10 @@ func (obp OrderByParams) String() string { return val } -// RouteOpcode is a number representing the opcode -// for the Route primitve. -type RouteOpcode int - -// This is the list of RouteOpcode values. -const ( - // SelectUnsharded is the opcode for routing a - // select statement to an unsharded database. - SelectUnsharded = RouteOpcode(iota) - // SelectEqualUnique is for routing a query to - // a single shard. Requires: A Unique Vindex, and - // a single Value. - SelectEqualUnique - // SelectEqual is for routing a query using a - // non-unique vindex. Requires: A Vindex, and - // a single Value. - SelectEqual - // SelectIN is for routing a query that has an IN - // clause using a Vindex. Requires: A Vindex, - // and a Values list. - SelectIN - // SelectMultiEqual is the opcode for routing a query - // based on multiple vindex input values, similar to - // SelectIN, but the query sent to each shard is the - // same. - SelectMultiEqual - // SelectScatter is for routing a scatter query - // to all shards of a keyspace. - SelectScatter - // SelectNext is for fetching from a sequence. - SelectNext - // SelectDBA is for executing a DBA statement. - SelectDBA - // SelectReference is for fetching from a reference table. - SelectReference - // SelectNone is used for queries that always return empty values - SelectNone - // NumRouteOpcodes is the number of opcodes - NumRouteOpcodes -) - -var routeName = map[RouteOpcode]string{ - SelectUnsharded: "SelectUnsharded", - SelectEqualUnique: "SelectEqualUnique", - SelectEqual: "SelectEqual", - SelectIN: "SelectIN", - SelectMultiEqual: "SelectMultiEqual", - SelectScatter: "SelectScatter", - SelectNext: "SelectNext", - SelectDBA: "SelectDBA", - SelectReference: "SelectReference", - SelectNone: "SelectNone", -} - var ( partialSuccessScatterQueries = stats.NewCounter("PartialSuccessScatterQueries", "Count of partially successful scatter queries") ) -// MarshalJSON serializes the RouteOpcode as a JSON string. -// It's used for testing and diagnostics. -func (code RouteOpcode) MarshalJSON() ([]byte, error) { - return json.Marshal(routeName[code]) -} - -// String returns a string presentation of this opcode -func (code RouteOpcode) String() string { - return routeName[code] -} - // RouteType returns a description of the query routing type used by the primitive func (route *Route) RouteType() string { return route.Opcode.String() @@ -231,31 +165,6 @@ func (route *Route) SetTruncateColumnCount(count int) { route.TruncateColumnCount = count } -// GetGenericOpcode gets the Opcode which is used for routing -func (route *Route) GetGenericOpcode() Opcode { - switch route.Opcode { - case SelectDBA: - return DBA - case SelectUnsharded, SelectNext: - return Unsharded - case SelectReference: - return Any - case SelectScatter: - return Scatter - case SelectEqual, SelectEqualUnique: - return Equal - case SelectIN: - return In - case SelectMultiEqual: - return MultiEqual - case SelectNone: - return None - default: - // Unreachable. - return None - } -} - // TryExecute performs a non-streaming exec. func (route *Route) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { if route.QueryTimeout != 0 { @@ -308,25 +217,24 @@ func (route *Route) executeInternal(vcursor VCursor, bindVars map[string]*queryp } func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - route.opcode = route.GetGenericOpcode() switch route.Opcode { - case SelectDBA, SelectUnsharded, SelectNext, SelectReference, SelectScatter, SelectEqual, SelectEqualUnique: + case DBA, Unsharded, Next, Reference, Scatter, Equal, EqualUnique: return route.findRoutingInfo(vcursor, bindVars) - case SelectIN: + case IN: switch route.Vindex.(type) { case vindexes.MultiColumn: return route.paramsSelectInMultiCol(vcursor, bindVars) default: return route.paramsSelectIn(vcursor, bindVars) } - case SelectMultiEqual: + case MultiEqual: switch route.Vindex.(type) { case vindexes.MultiColumn: return route.paramsSelectMultiEqualMultiCol(vcursor, bindVars) default: return route.paramsSelectMultiEqual(vcursor, bindVars) } - case SelectNone: + case None: return nil, nil, nil default: // Unreachable. @@ -797,7 +705,7 @@ func (route *Route) description() PrimitiveDescription { } return PrimitiveDescription{ OperatorType: "Route", - Variant: routeName[route.Opcode], + Variant: route.Opcode.String(), Keyspace: route.Keyspace, TargetDestination: route.TargetDestination, Other: other, diff --git a/go/vt/vtgate/engine/route_test.go b/go/vt/vtgate/engine/route_test.go index 7727c9fea1e..99e24eb68a6 100644 --- a/go/vt/vtgate/engine/route_test.go +++ b/go/vt/vtgate/engine/route_test.go @@ -50,7 +50,7 @@ var defaultSelectResult = sqltypes.MakeTestResult( func TestSelectUnsharded(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -81,7 +81,7 @@ func TestSelectUnsharded(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) { +func TestInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) { stringListToExprList := func(in []string) []evalengine.Expr { var schema []evalengine.Expr for _, s := range in { @@ -163,8 +163,8 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { sel := &Route{ - Opcode: SelectDBA, RoutingParameters: &RoutingParameters{ + Opcode: DBA, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -195,7 +195,7 @@ func TestSelectInformationSchemaWithTableAndSchemaWithRoutedTables(t *testing.T) func TestSelectScatter(t *testing.T) { sel := NewRoute( - SelectScatter, + Scatter, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -229,7 +229,7 @@ func TestSelectScatter(t *testing.T) { func TestSelectEqualUnique(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) sel := NewRoute( - SelectEqualUnique, + EqualUnique, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -267,7 +267,7 @@ func TestSelectEqualUnique(t *testing.T) { func TestSelectNone(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) sel := NewRoute( - SelectNone, + None, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -302,7 +302,7 @@ func TestSelectEqualUniqueScatter(t *testing.T) { "write_only": "true", }) sel := NewRoute( - SelectEqualUnique, + EqualUnique, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -344,7 +344,7 @@ func TestSelectEqual(t *testing.T) { "to": "toc", }) sel := NewRoute( - SelectEqual, + Equal, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -397,7 +397,7 @@ func TestSelectEqualNoRoute(t *testing.T) { "to": "toc", }) sel := NewRoute( - SelectEqual, + Equal, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -429,10 +429,10 @@ func TestSelectEqualNoRoute(t *testing.T) { expectResult(t, "sel.StreamExecute", result, nil) } -func TestSelectINUnique(t *testing.T) { +func TestINUnique(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) sel := NewRoute( - SelectIN, + IN, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -474,14 +474,14 @@ func TestSelectINUnique(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectINNonUnique(t *testing.T) { +func TestINNonUnique(t *testing.T) { vindex, _ := vindexes.NewLookup("", map[string]string{ "table": "lkp", "from": "from", "to": "toc", }) sel := NewRoute( - SelectIN, + IN, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -541,10 +541,10 @@ func TestSelectINNonUnique(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectMultiEqual(t *testing.T) { +func TestMultiEqual(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) sel := NewRoute( - SelectMultiEqual, + MultiEqual, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -594,7 +594,7 @@ func TestSelectLike(t *testing.T) { } sel := NewRoute( - SelectEqual, + Equal, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -666,7 +666,7 @@ func TestSelectLike(t *testing.T) { func TestSelectNext(t *testing.T) { sel := NewRoute( - SelectNext, + Next, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -698,7 +698,7 @@ func TestSelectNext(t *testing.T) { func TestSelectDBA(t *testing.T) { sel := NewRoute( - SelectDBA, + DBA, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -730,7 +730,7 @@ func TestSelectDBA(t *testing.T) { func TestSelectReference(t *testing.T) { sel := NewRoute( - SelectReference, + Reference, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -767,7 +767,7 @@ func TestRouteGetFields(t *testing.T) { "to": "toc", }) sel := NewRoute( - SelectEqual, + Equal, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -805,7 +805,7 @@ func TestRouteGetFields(t *testing.T) { func TestRouteSort(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -887,7 +887,7 @@ func TestRouteSort(t *testing.T) { func TestRouteSortWeightStrings(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -989,7 +989,7 @@ func TestRouteSortWeightStrings(t *testing.T) { func TestRouteSortCollation(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1120,7 +1120,7 @@ func TestRouteSortCollation(t *testing.T) { func TestRouteSortTruncate(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1169,7 +1169,7 @@ func TestRouteSortTruncate(t *testing.T) { func TestRouteStreamTruncate(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1211,7 +1211,7 @@ func TestRouteStreamTruncate(t *testing.T) { func TestRouteStreamSortTruncate(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1260,7 +1260,7 @@ func TestRouteStreamSortTruncate(t *testing.T) { func TestParamsFail(t *testing.T) { sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1283,7 +1283,7 @@ func TestExecFail(t *testing.T) { t.Run("unsharded", func(t *testing.T) { // Unsharded error sel := NewRoute( - SelectUnsharded, + Unsharded, &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -1305,7 +1305,7 @@ func TestExecFail(t *testing.T) { t.Run("normal route with no scatter errors as warnings", func(t *testing.T) { // Scatter fails if one of N fails without ScatterErrorsAsWarnings sel := NewRoute( - SelectScatter, + Scatter, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1333,7 +1333,7 @@ func TestExecFail(t *testing.T) { t.Run("ScatterErrorsAsWarnings", func(t *testing.T) { // Scatter succeeds if one of N fails with ScatterErrorsAsWarnings sel := NewRoute( - SelectScatter, + Scatter, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1375,7 +1375,7 @@ func TestExecFail(t *testing.T) { func TestSelectEqualUniqueMultiColumnVindex(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) sel := NewRoute( - SelectEqualUnique, + EqualUnique, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1419,7 +1419,7 @@ func TestSelectEqualMultiColumnVindex(t *testing.T) { results: []*sqltypes.Result{defaultSelectResult}, } sel := NewRoute( - SelectEqual, + Equal, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1448,10 +1448,10 @@ func TestSelectEqualMultiColumnVindex(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectINMultiColumnVindex(t *testing.T) { +func TestINMultiColumnVindex(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) sel := NewRoute( - SelectIN, + IN, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1494,10 +1494,10 @@ func TestSelectINMultiColumnVindex(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectINMixedMultiColumnComparision(t *testing.T) { +func TestINMixedMultiColumnComparision(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) sel := NewRoute( - SelectIN, + IN, &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -1537,10 +1537,10 @@ func TestSelectINMixedMultiColumnComparision(t *testing.T) { expectResult(t, "sel.StreamExecute", result, defaultSelectResult) } -func TestSelectMultiEqualMultiCol(t *testing.T) { +func TestMultiEqualMultiCol(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) sel := NewRoute( - SelectMultiEqual, + MultiEqual, &vindexes.Keyspace{Name: "ks", Sharded: true}, "dummy_select", "dummy_select_field", diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index e127a7910bd..382d73b577c 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -17,6 +17,8 @@ limitations under the License. package engine import ( + "encoding/json" + "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/log" @@ -35,37 +37,68 @@ type Opcode int // This is the list of Opcode values. const ( - // None is used for queries which do not need routing - None = Opcode(iota) // Unsharded is for routing a statement // to an unsharded keyspace. - Unsharded - // Any is for routing a statement - // to any shard of a keyspace. e.g. - Reference tables - Any - // Equal is for routing a statement to a single shard. + Unsharded = Opcode(iota) + // EqualUnique is for routing a query to a single shard. + // Requires: A Unique Vindex, and a single Value. + EqualUnique + // Equal is for routing a query using a non-unique vindex. // Requires: A Vindex, and a single Value. Equal - // In is for routing a statement to a multi shard. + // IN is for routing a statement to a multi shard. // Requires: A Vindex, and a multi Values. - In + IN // MultiEqual is used for routing queries with IN with tuple clause // Requires: A Vindex, and a multi Tuple Values. MultiEqual // Scatter is for routing a scattered statement. Scatter + // Next is for fetching from a sequence. + Next + // DBA is used for routing DBA queries + // e.g: Select * from information_schema.tables where schema_name = "a" + DBA + // Reference is for fetching from a reference table. + Reference + // None is used for queries which do not need routing + None // ByDestination is to route explicitly to a given target destination. // Is used when the query explicitly sets a target destination: // in the clause e.g: UPDATE `keyspace[-]`.x1 SET foo=1 ByDestination - // DBA is used for routing DBA queries - // e.g: Select * from information_schema.tables where schema_name = "a" - DBA + // NumOpcodes is the number of opcodes + NumOpcodes ) +var opName = map[Opcode]string{ + Unsharded: "Unsharded", + EqualUnique: "EqualUnique", + Equal: "Equal", + IN: "IN", + MultiEqual: "MultiEqual", + Scatter: "Scatter", + DBA: "DBA", + Next: "Next", + Reference: "Reference", + None: "None", + ByDestination: "ByDestination", +} + +// MarshalJSON serializes the Opcode as a JSON string. +// It's used for testing and diagnostics. +func (code Opcode) MarshalJSON() ([]byte, error) { + return json.Marshal(opName[code]) +} + +// String returns a string presentation of this opcode +func (code Opcode) String() string { + return opName[code] +} + type RoutingParameters struct { - // Required for - All - opcode Opcode + // Opcode is the execution opcode. + Opcode Opcode // Keyspace specifies the keyspace to send the query to. Keyspace *vindexes.Keyspace @@ -86,18 +119,18 @@ type RoutingParameters struct { } func (rp *RoutingParameters) findRoutingInfo(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - switch rp.opcode { + switch rp.Opcode { case DBA: return rp.systemQuery(vcursor, bindVars) - case Unsharded: + case Unsharded, Next: return rp.unsharded(vcursor, bindVars) - case Any: + case Reference: return rp.anyShard(vcursor, bindVars) case Scatter: return rp.byDestination(vcursor, bindVars, key.DestinationAllShards{}) case ByDestination: return rp.byDestination(vcursor, bindVars, rp.TargetDestination) - case Equal: + case Equal, EqualUnique: switch rp.Vindex.(type) { case vindexes.MultiColumn: return rp.paramsSelectEqualMultiCol(vcursor, bindVars) @@ -108,7 +141,7 @@ func (rp *RoutingParameters) findRoutingInfo(vcursor VCursor, bindVars map[strin return nil, nil, nil default: // Unreachable. - return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", rp.opcode) + return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", rp.Opcode) } } diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index 11135ff9d92..b6936ba43a7 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -54,17 +54,9 @@ type Update struct { noInputs } -var updName = map[Opcode]string{ - Unsharded: "UpdateUnsharded", - Equal: "UpdateEqual", - In: "UpdateIn", - Scatter: "UpdateScatter", - ByDestination: "UpdateByDestination", -} - // RouteType returns a description of the query routing type used by the primitive func (upd *Update) RouteType() string { - return updName[upd.Opcode] + return upd.Opcode.String() } // GetKeyspaceName specifies the Keyspace that this primitive routes to. @@ -97,7 +89,7 @@ func (upd *Update) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind default: return upd.execUpdateEqual(vcursor, bindVars) } - case In: + case IN: return upd.execUpdateIn(vcursor, bindVars) case Scatter: return upd.execUpdateByDestination(vcursor, bindVars, key.DestinationAllShards{}) diff --git a/go/vt/vtgate/engine/update_test.go b/go/vt/vtgate/engine/update_test.go index 0b38e3b15b8..815fdcca84d 100644 --- a/go/vt/vtgate/engine/update_test.go +++ b/go/vt/vtgate/engine/update_test.go @@ -37,8 +37,8 @@ import ( func TestUpdateUnsharded(t *testing.T) { upd := &Update{ DML: &DML{ - Opcode: Unsharded, RoutingParameters: &RoutingParameters{ + Opcode: Unsharded, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: false, @@ -71,8 +71,8 @@ func TestUpdateEqual(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -102,8 +102,8 @@ func TestUpdateEqualMultiCol(t *testing.T) { vindex, _ := vindexes.NewRegionExperimental("", map[string]string{"region_bytes": "1"}) upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -128,8 +128,8 @@ func TestUpdateScatter(t *testing.T) { vindex, _ := vindexes.NewHash("", nil) upd := &Update{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -153,8 +153,8 @@ func TestUpdateScatter(t *testing.T) { // works with multishard autocommit upd = &Update{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -185,8 +185,8 @@ func TestUpdateEqualNoRoute(t *testing.T) { }) upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -216,8 +216,8 @@ func TestUpdateEqualNoScatter(t *testing.T) { }) upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: &vindexes.Keyspace{ Name: "ks", Sharded: true, @@ -238,8 +238,8 @@ func TestUpdateEqualChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["hash"], Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, @@ -381,8 +381,8 @@ func TestUpdateEqualMultiColChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: Equal, RoutingParameters: &RoutingParameters{ + Opcode: Equal, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["rg_vdx"], Values: []evalengine.Expr{evalengine.NewLiteralInt(1), evalengine.NewLiteralInt(2)}, @@ -502,8 +502,8 @@ func TestUpdateScatterChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: Scatter, RoutingParameters: &RoutingParameters{ + Opcode: Scatter, Keyspace: ks.Keyspace, }, Query: "dummy_update", @@ -614,8 +614,8 @@ func TestUpdateIn(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["hash"], Values: []evalengine.Expr{&evalengine.TupleExpr{ @@ -639,8 +639,8 @@ func TestUpdateIn(t *testing.T) { func TestUpdateInStreamExecute(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["hash"], Values: []evalengine.Expr{&evalengine.TupleExpr{ @@ -665,8 +665,8 @@ func TestUpdateInStreamExecute(t *testing.T) { func TestUpdateInMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["rg_vdx"], Values: []evalengine.Expr{ @@ -691,8 +691,8 @@ func TestUpdateInChangedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["hash"], Values: []evalengine.Expr{&evalengine.TupleExpr{ @@ -820,8 +820,8 @@ func TestUpdateInChangedVindexMultiCol(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] upd := &Update{ DML: &DML{ - Opcode: In, RoutingParameters: &RoutingParameters{ + Opcode: IN, Keyspace: ks.Keyspace, Vindex: ks.Vindexes["rg_vdx"], Values: []evalengine.Expr{ diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 322a6f3953a..d52178d6c71 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -1757,7 +1757,7 @@ func (e *Executor) checkThatPlanIsValid(stmt sqlparser.Statement, plan *engine.P if !ok { return false } - return router.Opcode == engine.SelectScatter + return router.Opcode == engine.Scatter }, plan.Instructions) if badPrimitive == nil { diff --git a/go/vt/vtgate/executor_scatter_stats.go b/go/vt/vtgate/executor_scatter_stats.go index 16cfc5bde17..54d08af2cd3 100644 --- a/go/vt/vtgate/executor_scatter_stats.go +++ b/go/vt/vtgate/executor_scatter_stats.go @@ -181,7 +181,7 @@ const statsHTML = ` func findScatter(p engine.Primitive) bool { switch v := p.(type) { case *engine.Route: - return v.Opcode == engine.SelectScatter + return v.Opcode == engine.Scatter default: return false } diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 0f22d9a7fbf..497447bb341 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -2114,7 +2114,7 @@ func TestExecutorExplain(t *testing.T) { require.NoError(t, err) require.Equal(t, - `[[VARCHAR("Route") VARCHAR("SelectScatter") VARCHAR("TestExecutor") VARCHAR("") VARCHAR("UNKNOWN") VARCHAR("select * from `+"`user`"+`")]]`, + `[[VARCHAR("Route") VARCHAR("Scatter") VARCHAR("TestExecutor") VARCHAR("") VARCHAR("UNKNOWN") VARCHAR("select * from `+"`user`"+`")]]`, fmt.Sprintf("%v", result.Rows)) result, err = executorExec(executor, "explain format = vitess select 42", bindVars) diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go index 3e6d7556cb7..b4049749411 100644 --- a/go/vt/vtgate/planbuilder/ddl.go +++ b/go/vt/vtgate/planbuilder/ddl.go @@ -215,7 +215,7 @@ func buildAlterView(vschema plancontext.VSchema, ddl *sqlparser.AlterView, reser if keyspace.Name != keyspaceName { return nil, nil, vterrors.New(vtrpcpb.Code_UNIMPLEMENTED, ViewDifferentKeyspace) } - if opCode != engine.SelectUnsharded && opCode != engine.SelectEqualUnique && opCode != engine.SelectScatter { + if opCode != engine.Unsharded && opCode != engine.EqualUnique && opCode != engine.Scatter { return nil, nil, vterrors.New(vtrpcpb.Code_UNIMPLEMENTED, ViewComplex) } _ = sqlparser.Rewrite(ddl.Select, func(cursor *sqlparser.Cursor) bool { @@ -251,7 +251,7 @@ func buildCreateView(vschema plancontext.VSchema, ddl *sqlparser.CreateView, res if keyspace.Name != keyspaceName { return nil, nil, vterrors.New(vtrpcpb.Code_UNIMPLEMENTED, ViewDifferentKeyspace) } - if opCode != engine.SelectUnsharded && opCode != engine.SelectEqualUnique && opCode != engine.SelectScatter { + if opCode != engine.Unsharded && opCode != engine.EqualUnique && opCode != engine.Scatter { return nil, nil, vterrors.New(vtrpcpb.Code_UNIMPLEMENTED, ViewComplex) } _ = sqlparser.Rewrite(ddl.Select, func(cursor *sqlparser.Cursor) bool { @@ -364,13 +364,13 @@ func buildRenameTable(vschema plancontext.VSchema, renameTable *sqlparser.Rename return destination, keyspace, nil } -func tryToGetRoutePlan(selectPlan engine.Primitive) (valid bool, keyspaceName string, opCode engine.RouteOpcode) { +func tryToGetRoutePlan(selectPlan engine.Primitive) (valid bool, keyspaceName string, opCode engine.Opcode) { switch plan := selectPlan.(type) { case *engine.Route: return true, plan.Keyspace.Name, plan.Opcode case engine.Gen4Comparer: return tryToGetRoutePlan(plan.GetGen4Primitive()) default: - return false, "", engine.RouteOpcode(0) + return false, "", engine.Opcode(0) } } diff --git a/go/vt/vtgate/planbuilder/dml.go b/go/vt/vtgate/planbuilder/dml.go index 2e6b7aee4c2..2abc46f8540 100644 --- a/go/vt/vtgate/planbuilder/dml.go +++ b/go/vt/vtgate/planbuilder/dml.go @@ -129,7 +129,7 @@ func getBestVindexOption(exprs []sqlparser.Expr, index *vindexes.ColumnVindex) * if !sqlparser.IsSimpleTuple(valExpr) { continue } - opcode = engine.In + opcode = engine.IN default: continue } diff --git a/go/vt/vtgate/planbuilder/from.go b/go/vt/vtgate/planbuilder/from.go index cc5f69f21b1..f0804f5af8b 100644 --- a/go/vt/vtgate/planbuilder/from.go +++ b/go/vt/vtgate/planbuilder/from.go @@ -191,7 +191,7 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl return err } rb, st := newRoute(sel) - rb.eroute = engine.NewSimpleRoute(engine.SelectDBA, ks) + rb.eroute = engine.NewSimpleRoute(engine.DBA, ks) rb.eroute.TableName = sqlparser.String(tableName) pb.plan, pb.st = rb, st // Add the table to symtab @@ -248,20 +248,20 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl var eroute *engine.Route switch { case vschemaTable.Type == vindexes.TypeSequence: - eroute = engine.NewSimpleRoute(engine.SelectNext, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.Next, vschemaTable.Keyspace) case vschemaTable.Type == vindexes.TypeReference: - eroute = engine.NewSimpleRoute(engine.SelectReference, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.Reference, vschemaTable.Keyspace) case !vschemaTable.Keyspace.Sharded: - eroute = engine.NewSimpleRoute(engine.SelectUnsharded, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.Unsharded, vschemaTable.Keyspace) case vschemaTable.Pinned == nil: - eroute = engine.NewSimpleRoute(engine.SelectScatter, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.Scatter, vschemaTable.Keyspace) eroute.TargetDestination = destTarget eroute.TargetTabletType = destTableType default: // Pinned tables have their keyspace ids already assigned. // Use the Binary vindex, which is the identity function // for keyspace id. - eroute = engine.NewSimpleRoute(engine.SelectEqualUnique, vschemaTable.Keyspace) + eroute = engine.NewSimpleRoute(engine.EqualUnique, vschemaTable.Keyspace) vindex, _ = vindexes.NewBinary("binary", nil) eroute.Vindex = vindex lit := evalengine.NewLiteralString(vschemaTable.Pinned, collations.TypedCollation{}) @@ -329,7 +329,7 @@ func (pb *primitiveBuilder) join(rpb *primitiveBuilder, ajoin *sqlparser.JoinTab return newJoin(pb, rpb, ajoin, reservedVars) } - if lRoute.eroute.Opcode == engine.SelectReference { + if lRoute.eroute.Opcode == engine.Reference { // Swap the conditions & eroutes, and then merge. lRoute.condition, rRoute.condition = rRoute.condition, lRoute.condition lRoute.eroute, rRoute.eroute = rRoute.eroute, lRoute.eroute diff --git a/go/vt/vtgate/planbuilder/operator_transformers.go b/go/vt/vtgate/planbuilder/operator_transformers.go index 44846f7ae0b..d7575dfe37b 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -146,9 +146,9 @@ func transformRoutePlan(ctx *plancontext.PlanningContext, op *physical.Route) (* replaceSubQuery(ctx, sel) return &routeGen4{ eroute: &engine.Route{ - Opcode: op.RouteOpCode, TableName: strings.Join(tableNames, ", "), RoutingParameters: &engine.RoutingParameters{ + Opcode: op.RouteOpCode, Keyspace: op.Keyspace, Vindex: vindex, Values: values, @@ -480,32 +480,32 @@ func canMergeUnionPlans(ctx *plancontext.PlanningContext, a, b *routeGen4) bool return false } switch a.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectReference: + case engine.Unsharded, engine.Reference: return a.eroute.Opcode == b.eroute.Opcode - case engine.SelectDBA: + case engine.DBA: return canSelectDBAMerge(a, b) - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if b.eroute.Opcode == engine.SelectEqualUnique && + if b.eroute.Opcode == engine.EqualUnique && a.eroute.Vindex == b.eroute.Vindex && a.condition != nil && b.condition != nil && gen4ValuesEqual(ctx, []sqlparser.Expr{a.condition}, []sqlparser.Expr{b.condition}) { return true } - case engine.SelectScatter: - return b.eroute.Opcode == engine.SelectScatter - case engine.SelectNext: + case engine.Scatter: + return b.eroute.Opcode == engine.Scatter + case engine.Next: return false } return false } func canSelectDBAMerge(a, b *routeGen4) bool { - if a.eroute.Opcode != engine.SelectDBA { + if a.eroute.Opcode != engine.DBA { return false } - if b.eroute.Opcode != engine.SelectDBA { + if b.eroute.Opcode != engine.DBA { return false } diff --git a/go/vt/vtgate/planbuilder/physical/route.go b/go/vt/vtgate/planbuilder/physical/route.go index adaa3fab37e..1aeb1ea2c88 100644 --- a/go/vt/vtgate/planbuilder/physical/route.go +++ b/go/vt/vtgate/planbuilder/physical/route.go @@ -31,7 +31,7 @@ type ( Route struct { Source abstract.PhysicalOperator - RouteOpCode engine.RouteOpcode + RouteOpCode engine.Opcode Keyspace *vindexes.Keyspace // here we store the possible vindexes we can use so that when we add predicates to the plan, @@ -67,7 +67,7 @@ type ( ColsSeen map[string]interface{} ValueExprs []sqlparser.Expr Predicates []sqlparser.Expr - OpCode engine.RouteOpcode + OpCode engine.Opcode FoundVindex vindexes.Vindex Cost Cost } @@ -76,7 +76,7 @@ type ( Cost struct { VindexCost int IsUnique bool - OpCode engine.RouteOpcode + OpCode engine.Opcode } ) @@ -94,22 +94,22 @@ func (r *Route) TableID() semantics.TableSet { func (r *Route) Cost() int { switch r.RouteOpCode { case // these op codes will never be compared with each other - they are assigned by a rule and not a comparison - engine.SelectDBA, - engine.SelectNext, - engine.SelectNone, - engine.SelectReference, - engine.SelectUnsharded: + engine.DBA, + engine.Next, + engine.None, + engine.Reference, + engine.Unsharded: return 0 // TODO revisit these costs when more of the gen4 planner is done - case engine.SelectEqualUnique: + case engine.EqualUnique: return 1 - case engine.SelectEqual: + case engine.Equal: return 5 - case engine.SelectIN: + case engine.IN: return 10 - case engine.SelectMultiEqual: + case engine.MultiEqual: return 10 - case engine.SelectScatter: + case engine.Scatter: return 20 } return 1 @@ -211,7 +211,7 @@ func (r *Route) planComparison(ctx *plancontext.PlanningContext, cmp *sqlparser. } func (r *Route) setSelectNoneOpcode() { - r.RouteOpCode = engine.SelectNone + r.RouteOpCode = engine.None // clear any chosen vindex as this query does not need to be sent down. r.Selected = nil } @@ -285,7 +285,7 @@ func (r *Route) haveMatchingVindex( valueExpr sqlparser.Expr, column *sqlparser.ColName, value evalengine.Expr, - opcode func(*vindexes.ColumnVindex) engine.RouteOpcode, + opcode func(*vindexes.ColumnVindex) engine.Opcode, vfunc func(*vindexes.ColumnVindex) vindexes.Vindex, ) bool { newVindexFound := false @@ -406,7 +406,7 @@ func (option *VindexOption) updateWithNewColumn( value evalengine.Expr, node sqlparser.Expr, colVindex *vindexes.ColumnVindex, - opcode func(*vindexes.ColumnVindex) engine.RouteOpcode, + opcode func(*vindexes.ColumnVindex) engine.Opcode, ) bool { option.ColsSeen[colLoweredName] = true option.ValueExprs = append(option.ValueExprs, valueExpr) @@ -434,7 +434,7 @@ func (r *Route) PickBestAvailableVindex() { // canImprove returns true if additional predicates could help improving this plan func (r *Route) canImprove() bool { - return r.RouteOpCode != engine.SelectNone + return r.RouteOpCode != engine.None } // UnsolvedPredicates implements the Operator interface @@ -454,7 +454,7 @@ func (r *Route) Compact(semTable *semantics.SemTable) (abstract.Operator, error) func (r *Route) IsSingleShard() bool { switch r.RouteOpCode { - case engine.SelectUnsharded, engine.SelectDBA, engine.SelectNext, engine.SelectEqualUnique, engine.SelectReference: + case engine.Unsharded, engine.DBA, engine.Next, engine.EqualUnique, engine.Reference: return true } return false @@ -494,7 +494,7 @@ func (r *Route) planInOp(ctx *plancontext.PlanningContext, cmp *sqlparser.Compar if value == nil { return false } - opcode := func(*vindexes.ColumnVindex) engine.RouteOpcode { return engine.SelectIN } + opcode := func(*vindexes.ColumnVindex) engine.Opcode { return engine.IN } return r.haveMatchingVindex(ctx, cmp, vdValue, left, value, opcode, justTheVindex) case sqlparser.ValTuple: right, rightIsValTuple := cmp.Right.(sqlparser.ValTuple) @@ -532,7 +532,7 @@ func (r *Route) planLikeOp(ctx *plancontext.PlanningContext, node *sqlparser.Com if val == nil { return false } - selectEqual := func(*vindexes.ColumnVindex) engine.RouteOpcode { return engine.SelectEqual } + selectEqual := func(*vindexes.ColumnVindex) engine.Opcode { return engine.Equal } vdx := func(vindex *vindexes.ColumnVindex) vindexes.Vindex { if prefixable, ok := vindex.Vindex.(vindexes.Prefixable); ok { return prefixable.PrefixVindex() @@ -584,7 +584,7 @@ func (r *Route) planCompositeInOpRecursive( return false } - opcode := func(*vindexes.ColumnVindex) engine.RouteOpcode { return engine.SelectMultiEqual } + opcode := func(*vindexes.ColumnVindex) engine.Opcode { return engine.MultiEqual } newVindex := r.haveMatchingVindex(ctx, cmp, rightVals, expr, newPlanValues, opcode, justTheVindex) foundVindex = newVindex || foundVindex } @@ -594,10 +594,10 @@ func (r *Route) planCompositeInOpRecursive( func (r *Route) resetRoutingSelections(ctx *plancontext.PlanningContext) error { switch r.RouteOpCode { - case engine.SelectDBA, engine.SelectNext, engine.SelectReference, engine.SelectUnsharded: + case engine.DBA, engine.Next, engine.Reference, engine.Unsharded: // these we keep as is default: - r.RouteOpCode = engine.SelectScatter + r.RouteOpCode = engine.Scatter } r.Selected = nil @@ -626,12 +626,12 @@ func tupleAccess(expr sqlparser.Expr, coordinates []int) sqlparser.Expr { return expr } -func equalOrEqualUnique(vindex *vindexes.ColumnVindex) engine.RouteOpcode { +func equalOrEqualUnique(vindex *vindexes.ColumnVindex) engine.Opcode { if vindex.IsUnique() { - return engine.SelectEqualUnique + return engine.EqualUnique } - return engine.SelectEqual + return engine.Equal } func justTheVindex(vindex *vindexes.ColumnVindex) vindexes.Vindex { @@ -639,10 +639,10 @@ func justTheVindex(vindex *vindexes.ColumnVindex) vindexes.Vindex { } // costFor returns a cost struct to make route choices easier to compare -func costFor(foundVindex *vindexes.ColumnVindex, opcode engine.RouteOpcode) Cost { +func costFor(foundVindex *vindexes.ColumnVindex, opcode engine.Opcode) Cost { switch opcode { // For these opcodes, we should not have a vindex, so we just return the opcode as the cost - case engine.SelectUnsharded, engine.SelectNext, engine.SelectDBA, engine.SelectReference, engine.SelectNone, engine.SelectScatter: + case engine.Unsharded, engine.Next, engine.DBA, engine.Reference, engine.None, engine.Scatter: return Cost{ OpCode: opcode, } diff --git a/go/vt/vtgate/planbuilder/physical/route_planning.go b/go/vt/vtgate/planbuilder/physical/route_planning.go index 168288bf69a..4a9058d8dd8 100644 --- a/go/vt/vtgate/planbuilder/physical/route_planning.go +++ b/go/vt/vtgate/planbuilder/physical/route_planning.go @@ -171,30 +171,30 @@ func createRoute(ctx *plancontext.PlanningContext, table *abstract.QueryTable, s switch { case vschemaTable.Type == vindexes.TypeSequence: - plan.RouteOpCode = engine.SelectNext + plan.RouteOpCode = engine.Next case vschemaTable.Type == vindexes.TypeReference: - plan.RouteOpCode = engine.SelectReference + plan.RouteOpCode = engine.Reference case !vschemaTable.Keyspace.Sharded: - plan.RouteOpCode = engine.SelectUnsharded + plan.RouteOpCode = engine.Unsharded case vschemaTable.Pinned != nil: // Pinned tables have their keyspace ids already assigned. // Use the Binary vindex, which is the identity function // for keyspace id. - plan.RouteOpCode = engine.SelectEqualUnique + plan.RouteOpCode = engine.EqualUnique vindex, _ := vindexes.NewBinary("binary", nil) plan.Selected = &VindexOption{ Ready: true, Values: []evalengine.Expr{evalengine.NewLiteralString(vschemaTable.Pinned, collations.TypedCollation{})}, ValueExprs: nil, Predicates: nil, - OpCode: engine.SelectEqualUnique, + OpCode: engine.EqualUnique, FoundVindex: vindex, Cost: Cost{ - OpCode: engine.SelectEqualUnique, + OpCode: engine.EqualUnique, }, } default: - plan.RouteOpCode = engine.SelectScatter + plan.RouteOpCode = engine.Scatter } for _, predicate := range table.Predicates { err = plan.UpdateRoutingLogic(ctx, predicate) @@ -219,7 +219,7 @@ func createInfSchemaRoute(ctx *plancontext.PlanningContext, table *abstract.Quer }, } r := &Route{ - RouteOpCode: engine.SelectDBA, + RouteOpCode: engine.DBA, Source: src, Keyspace: ks, } @@ -445,13 +445,13 @@ func tryMerge( } switch aRoute.RouteOpCode { - case engine.SelectUnsharded, engine.SelectDBA: + case engine.Unsharded, engine.DBA: if aRoute.RouteOpCode == bRoute.RouteOpCode { return merger(aRoute, bRoute) } - case engine.SelectEqualUnique: + case engine.EqualUnique: // if they are already both being sent to the same shard, we can merge - if bRoute.RouteOpCode == engine.SelectEqualUnique { + if bRoute.RouteOpCode == engine.EqualUnique { aVdx := aRoute.SelectedVindex() bVdx := bRoute.SelectedVindex() aExpr := aRoute.VindexExpressions() @@ -462,7 +462,7 @@ func tryMerge( return nil, nil } fallthrough - case engine.SelectScatter, engine.SelectIN: + case engine.Scatter, engine.IN: if len(joinPredicates) == 0 { // If we are doing two Scatters, we have to make sure that the // joins are on the correct vindex to allow them to be merged @@ -535,14 +535,14 @@ func leaves(op abstract.Operator) (sources []abstract.Operator) { func tryMergeReferenceTable(aRoute, bRoute *Route, merger mergeFunc) (*Route, error) { // if either side is a reference table, we can just merge it and use the opcode of the other side - var opCode engine.RouteOpcode + var opCode engine.Opcode var selected *VindexOption switch { - case aRoute.RouteOpCode == engine.SelectReference: + case aRoute.RouteOpCode == engine.Reference: selected = bRoute.Selected opCode = bRoute.RouteOpCode - case bRoute.RouteOpCode == engine.SelectReference: + case bRoute.RouteOpCode == engine.Reference: selected = aRoute.Selected opCode = aRoute.RouteOpCode default: diff --git a/go/vt/vtgate/planbuilder/physical/vindex.go b/go/vt/vtgate/planbuilder/physical/vindex.go index 1ef790c864e..9944d580c1d 100644 --- a/go/vt/vtgate/planbuilder/physical/vindex.go +++ b/go/vt/vtgate/planbuilder/physical/vindex.go @@ -54,7 +54,7 @@ func (v *Vindex) IPhysical() {} // Cost implements the PhysicalOperator interface func (v *Vindex) Cost() int { - return int(engine.SelectEqualUnique) + return int(engine.EqualUnique) } // Clone implements the PhysicalOperator interface diff --git a/go/vt/vtgate/planbuilder/route.go b/go/vt/vtgate/planbuilder/route.go index ee07b06adf2..81cb527b4c6 100644 --- a/go/vt/vtgate/planbuilder/route.go +++ b/go/vt/vtgate/planbuilder/route.go @@ -375,14 +375,14 @@ func (rb *route) Inputs() []logicalPlan { // with the outer route. func (rb *route) MergeSubquery(pb *primitiveBuilder, inner *route) bool { if rb.SubqueryCanMerge(pb, inner) { - if inner.eroute.Opcode == engine.SelectDBA && (len(inner.eroute.SysTableTableName) > 0 || len(inner.eroute.SysTableTableSchema) > 0) { + if inner.eroute.Opcode == engine.DBA && (len(inner.eroute.SysTableTableName) > 0 || len(inner.eroute.SysTableTableSchema) > 0) { switch rb.eroute.Opcode { - case engine.SelectDBA, engine.SelectReference: + case engine.DBA, engine.Reference: rb.eroute.SysTableTableSchema = append(rb.eroute.SysTableTableSchema, inner.eroute.SysTableTableSchema...) for k, v := range inner.eroute.SysTableTableName { rb.eroute.SysTableTableName[k] = v } - rb.eroute.Opcode = engine.SelectDBA + rb.eroute.Opcode = engine.DBA default: return false } @@ -407,7 +407,7 @@ func (rb *route) MergeUnion(right *route, isDistinct bool) bool { func (rb *route) isSingleShard() bool { switch rb.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectDBA, engine.SelectNext, engine.SelectEqualUnique, engine.SelectReference: + case engine.Unsharded, engine.DBA, engine.Next, engine.EqualUnique, engine.Reference: return true } return false @@ -420,24 +420,24 @@ func (rb *route) JoinCanMerge(pb *primitiveBuilder, rrb *route, ajoin *sqlparser if rb.eroute.Keyspace.Name != rrb.eroute.Keyspace.Name { return false } - if rrb.eroute.Opcode == engine.SelectReference { + if rrb.eroute.Opcode == engine.Reference { // Any opcode can join with a reference table. return true } switch rb.eroute.Opcode { - case engine.SelectUnsharded: + case engine.Unsharded: return rb.eroute.Opcode == rrb.eroute.Opcode - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if rrb.eroute.Opcode == engine.SelectEqualUnique && rb.eroute.Vindex == rrb.eroute.Vindex && valEqual(rb.condition, rrb.condition) { + if rrb.eroute.Opcode == engine.EqualUnique && rb.eroute.Vindex == rrb.eroute.Vindex && valEqual(rb.condition, rrb.condition) { return true } - case engine.SelectReference: + case engine.Reference: return true - case engine.SelectNext: + case engine.Next: return false - case engine.SelectDBA: - if rrb.eroute.Opcode != engine.SelectDBA { + case engine.DBA: + if rrb.eroute.Opcode != engine.DBA { return false } if where == nil { @@ -462,19 +462,19 @@ func (rb *route) SubqueryCanMerge(pb *primitiveBuilder, inner *route) bool { } // if either side is a reference table, we can just merge it and use the opcode of the other side - if rb.eroute.Opcode == engine.SelectReference || inner.eroute.Opcode == engine.SelectReference { + if rb.eroute.Opcode == engine.Reference || inner.eroute.Opcode == engine.Reference { return true } switch rb.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectDBA: + case engine.Unsharded, engine.DBA: return rb.eroute.Opcode == inner.eroute.Opcode - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if inner.eroute.Opcode == engine.SelectEqualUnique && rb.eroute.Vindex == inner.eroute.Vindex && valEqual(rb.condition, inner.condition) { + if inner.eroute.Opcode == engine.EqualUnique && rb.eroute.Vindex == inner.eroute.Vindex && valEqual(rb.condition, inner.condition) { return true } - case engine.SelectNext: + case engine.Next: return false } @@ -492,22 +492,22 @@ func (rb *route) unionCanMerge(other *route, distinct bool) bool { return false } switch rb.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectReference: + case engine.Unsharded, engine.Reference: return rb.eroute.Opcode == other.eroute.Opcode - case engine.SelectDBA: - return other.eroute.Opcode == engine.SelectDBA && + case engine.DBA: + return other.eroute.Opcode == engine.DBA && len(rb.eroute.SysTableTableSchema) == 0 && len(rb.eroute.SysTableTableName) == 0 && len(other.eroute.SysTableTableSchema) == 0 && len(other.eroute.SysTableTableName) == 0 - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if other.eroute.Opcode == engine.SelectEqualUnique && rb.eroute.Vindex == other.eroute.Vindex && valEqual(rb.condition, other.condition) { + if other.eroute.Opcode == engine.EqualUnique && rb.eroute.Vindex == other.eroute.Vindex && valEqual(rb.condition, other.condition) { return true } - case engine.SelectScatter: - return other.eroute.Opcode == engine.SelectScatter && !distinct - case engine.SelectNext: + case engine.Scatter: + return other.eroute.Opcode == engine.Scatter && !distinct + case engine.Next: return false } return false @@ -548,66 +548,66 @@ func (rb *route) canMergeOnFilter(pb *primitiveBuilder, rrb *route, filter sqlpa func (rb *route) UpdatePlan(pb *primitiveBuilder, filter sqlparser.Expr) { switch rb.eroute.Opcode { // For these opcodes, a new filter will not make any difference, so we can just exit early - case engine.SelectUnsharded, engine.SelectNext, engine.SelectDBA, engine.SelectReference, engine.SelectNone: + case engine.Unsharded, engine.Next, engine.DBA, engine.Reference, engine.None: return } opcode, vindex, values := rb.computePlan(pb, filter) - if opcode == engine.SelectScatter { + if opcode == engine.Scatter { return } // If we get SelectNone in next filters, override the previous route plan. - if opcode == engine.SelectNone { + if opcode == engine.None { rb.updateRoute(opcode, vindex, values) return } switch rb.eroute.Opcode { - case engine.SelectEqualUnique: - if opcode == engine.SelectEqualUnique && vindex.Cost() < rb.eroute.Vindex.Cost() { + case engine.EqualUnique: + if opcode == engine.EqualUnique && vindex.Cost() < rb.eroute.Vindex.Cost() { rb.updateRoute(opcode, vindex, values) } - case engine.SelectEqual: + case engine.Equal: switch opcode { - case engine.SelectEqualUnique: + case engine.EqualUnique: rb.updateRoute(opcode, vindex, values) - case engine.SelectEqual: + case engine.Equal: if vindex.Cost() < rb.eroute.Vindex.Cost() { rb.updateRoute(opcode, vindex, values) } } - case engine.SelectIN: + case engine.IN: switch opcode { - case engine.SelectEqualUnique, engine.SelectEqual: + case engine.EqualUnique, engine.Equal: rb.updateRoute(opcode, vindex, values) - case engine.SelectIN: + case engine.IN: if vindex.Cost() < rb.eroute.Vindex.Cost() { rb.updateRoute(opcode, vindex, values) } } - case engine.SelectMultiEqual: + case engine.MultiEqual: switch opcode { - case engine.SelectEqualUnique, engine.SelectEqual, engine.SelectIN: + case engine.EqualUnique, engine.Equal, engine.IN: rb.updateRoute(opcode, vindex, values) - case engine.SelectMultiEqual: + case engine.MultiEqual: if vindex.Cost() < rb.eroute.Vindex.Cost() { rb.updateRoute(opcode, vindex, values) } } - case engine.SelectScatter: + case engine.Scatter: switch opcode { - case engine.SelectEqualUnique, engine.SelectEqual, engine.SelectIN, engine.SelectMultiEqual, engine.SelectNone: + case engine.EqualUnique, engine.Equal, engine.IN, engine.MultiEqual, engine.None: rb.updateRoute(opcode, vindex, values) } } } -func (rb *route) updateRoute(opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { +func (rb *route) updateRoute(opcode engine.Opcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { rb.eroute.Opcode = opcode rb.eroute.Vindex = vindex rb.condition = condition } // computePlan computes the plan for the specified filter. -func (rb *route) computePlan(pb *primitiveBuilder, filter sqlparser.Expr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { +func (rb *route) computePlan(pb *primitiveBuilder, filter sqlparser.Expr) (opcode engine.Opcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { switch node := filter.(type) { case *sqlparser.ComparisonExpr: switch node.Operator { @@ -623,40 +623,40 @@ func (rb *route) computePlan(pb *primitiveBuilder, filter sqlparser.Expr) (opcod case *sqlparser.IsExpr: return rb.computeISPlan(pb, node) } - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } // computeLikePlan computes the plan for 'LIKE' constraint -func (rb *route) computeLikePlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { +func (rb *route) computeLikePlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { left := comparison.Left right := comparison.Right if sqlparser.IsNull(right) { - return engine.SelectNone, nil, nil + return engine.None, nil, nil } if !rb.exprIsValue(right) { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } vindex = pb.st.Vindex(left, rb) if vindex == nil { // if there is no vindex defined, scatter - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } if subsharding, ok := vindex.(vindexes.Prefixable); ok { - return engine.SelectEqual, subsharding.PrefixVindex(), right + return engine.Equal, subsharding.PrefixVindex(), right } - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } // computeEqualPlan computes the plan for an equality constraint. -func (rb *route) computeEqualPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { +func (rb *route) computeEqualPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { left := comparison.Left right := comparison.Right if sqlparser.IsNull(right) { - return engine.SelectNone, nil, nil + return engine.None, nil, nil } vindex = pb.st.Vindex(left, rb) @@ -664,73 +664,73 @@ func (rb *route) computeEqualPlan(pb *primitiveBuilder, comparison *sqlparser.Co left, right = right, left vindex = pb.st.Vindex(left, rb) if vindex == nil { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } } if !rb.exprIsValue(right) { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } if vindex.IsUnique() { - return engine.SelectEqualUnique, vindex, right + return engine.EqualUnique, vindex, right } - return engine.SelectEqual, vindex, right + return engine.Equal, vindex, right } // computeIS computes the plan for an equality constraint. -func (rb *route) computeISPlan(pb *primitiveBuilder, comparison *sqlparser.IsExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { +func (rb *route) computeISPlan(pb *primitiveBuilder, comparison *sqlparser.IsExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { // we only handle IS NULL correct. IsExpr can contain other expressions as well if comparison.Right != sqlparser.IsNullOp { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } vindex = pb.st.Vindex(comparison.Left, rb) // fallback to scatter gather if there is no vindex if vindex == nil { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } if vindex.IsUnique() { - return engine.SelectEqualUnique, vindex, &sqlparser.NullVal{} + return engine.EqualUnique, vindex, &sqlparser.NullVal{} } - return engine.SelectEqual, vindex, &sqlparser.NullVal{} + return engine.Equal, vindex, &sqlparser.NullVal{} } // computeINPlan computes the plan for an IN constraint. -func (rb *route) computeINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { +func (rb *route) computeINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { switch comparison.Left.(type) { case *sqlparser.ColName: return rb.computeSimpleINPlan(pb, comparison) case sqlparser.ValTuple: return rb.computeCompositeINPlan(pb, comparison) } - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } // computeSimpleINPlan computes the plan for a simple IN constraint. -func (rb *route) computeSimpleINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { +func (rb *route) computeSimpleINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) { vindex = pb.st.Vindex(comparison.Left, rb) if vindex == nil { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } switch node := comparison.Right.(type) { case sqlparser.ValTuple: if len(node) == 1 && sqlparser.IsNull(node[0]) { - return engine.SelectNone, nil, nil + return engine.None, nil, nil } for _, n := range node { if !rb.exprIsValue(n) { - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } } - return engine.SelectIN, vindex, comparison + return engine.IN, vindex, comparison case sqlparser.ListArg: - return engine.SelectIN, vindex, comparison + return engine.IN, vindex, comparison } - return engine.SelectScatter, nil, nil + return engine.Scatter, nil, nil } // computeCompositeINPlan computes the plan for a composite IN constraint. -func (rb *route) computeCompositeINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { +func (rb *route) computeCompositeINPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.Opcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { leftTuple := comparison.Left.(sqlparser.ValTuple) return rb.iterateCompositeIN(pb, comparison, nil, leftTuple) } @@ -743,8 +743,8 @@ func (rb *route) iterateCompositeIN( comparison *sqlparser.ComparisonExpr, coordinates []int, tuple sqlparser.ValTuple, -) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { - opcode = engine.SelectScatter +) (opcode engine.Opcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { + opcode = engine.Scatter cindex := len(coordinates) coordinates = append(coordinates, 0) @@ -767,23 +767,23 @@ func (rb *route) iterateCompositeIN( // compositePlanForCol builds a plan for a matched column in the LHS // of a composite IN clause. -func (rb *route) compositePlanForCol(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr, coordinates []int) (opcode engine.RouteOpcode, values sqlparser.Expr) { +func (rb *route) compositePlanForCol(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr, coordinates []int) (opcode engine.Opcode, values sqlparser.Expr) { rightTuple, ok := comparison.Right.(sqlparser.ValTuple) if !ok { - return engine.SelectScatter, nil + return engine.Scatter, nil } retVal := make(sqlparser.ValTuple, len(rightTuple)) for i, rval := range rightTuple { val := tupleAccess(rval, coordinates) if val == nil { - return engine.SelectScatter, nil + return engine.Scatter, nil } if !rb.exprIsValue(val) { - return engine.SelectScatter, nil + return engine.Scatter, nil } retVal[i] = val } - return engine.SelectMultiEqual, retVal + return engine.MultiEqual, retVal } // tupleAccess returns the value of the expression that corresponds @@ -801,11 +801,11 @@ func tupleAccess(expr sqlparser.Expr, coordinates []int) sqlparser.Expr { } // bestOfComposite returns the best of two composite IN clause plans. -func bestOfComposite(opcode1, opcode2 engine.RouteOpcode, vindex1, vindex2 vindexes.SingleColumn, values1, values2 sqlparser.Expr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { - if opcode1 == engine.SelectScatter { +func bestOfComposite(opcode1, opcode2 engine.Opcode, vindex1, vindex2 vindexes.SingleColumn, values1, values2 sqlparser.Expr) (opcode engine.Opcode, vindex vindexes.SingleColumn, values sqlparser.Expr) { + if opcode1 == engine.Scatter { return opcode2, vindex2, values2 } - if opcode2 == engine.SelectScatter { + if opcode2 == engine.Scatter { return opcode1, vindex1, values1 } if vindex1.Cost() < vindex2.Cost() { @@ -815,17 +815,17 @@ func bestOfComposite(opcode1, opcode2 engine.RouteOpcode, vindex1, vindex2 vinde } // computeNotInPlan looks for null values to produce a SelectNone if found -func (rb *route) computeNotInPlan(right sqlparser.Expr) engine.RouteOpcode { +func (rb *route) computeNotInPlan(right sqlparser.Expr) engine.Opcode { switch node := right.(type) { case sqlparser.ValTuple: for _, n := range node { if sqlparser.IsNull(n) { - return engine.SelectNone + return engine.None } } } - return engine.SelectScatter + return engine.Scatter } // exprIsValue returns true if the expression can be treated as a value diff --git a/go/vt/vtgate/planbuilder/routeGen4.go b/go/vt/vtgate/planbuilder/routeGen4.go index f9e59c4a5b2..b64f89020d0 100644 --- a/go/vt/vtgate/planbuilder/routeGen4.go +++ b/go/vt/vtgate/planbuilder/routeGen4.go @@ -159,7 +159,7 @@ func (rb *routeGen4) Inputs() []logicalPlan { func (rb *routeGen4) isSingleShard() bool { switch rb.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectDBA, engine.SelectNext, engine.SelectEqualUnique, engine.SelectReference: + case engine.Unsharded, engine.DBA, engine.Next, engine.EqualUnique, engine.Reference: return true } return false @@ -170,45 +170,45 @@ func (rb *routeGen4) unionCanMerge(other *routeGen4, distinct bool) bool { return false } switch rb.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectReference: + case engine.Unsharded, engine.Reference: return rb.eroute.Opcode == other.eroute.Opcode - case engine.SelectDBA: - return other.eroute.Opcode == engine.SelectDBA && + case engine.DBA: + return other.eroute.Opcode == engine.DBA && len(rb.eroute.SysTableTableSchema) == 0 && len(rb.eroute.SysTableTableName) == 0 && len(other.eroute.SysTableTableSchema) == 0 && len(other.eroute.SysTableTableName) == 0 - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if other.eroute.Opcode == engine.SelectEqualUnique && rb.eroute.Vindex == other.eroute.Vindex && valEqual(rb.condition, other.condition) { + if other.eroute.Opcode == engine.EqualUnique && rb.eroute.Vindex == other.eroute.Vindex && valEqual(rb.condition, other.condition) { return true } - case engine.SelectScatter: - return other.eroute.Opcode == engine.SelectScatter && !distinct - case engine.SelectNext: + case engine.Scatter: + return other.eroute.Opcode == engine.Scatter && !distinct + case engine.Next: return false } return false } -func (rb *routeGen4) updateRoute(opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { +func (rb *routeGen4) updateRoute(opcode engine.Opcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) { rb.eroute.Opcode = opcode rb.eroute.Vindex = vindex rb.condition = condition } // computeNotInPlan looks for null values to produce a SelectNone if found -func (rb *routeGen4) computeNotInPlan(right sqlparser.Expr) engine.RouteOpcode { +func (rb *routeGen4) computeNotInPlan(right sqlparser.Expr) engine.Opcode { switch node := right.(type) { case sqlparser.ValTuple: for _, n := range node { if sqlparser.IsNull(n) { - return engine.SelectNone + return engine.None } } } - return engine.SelectScatter + return engine.Scatter } // exprIsValue returns true if the expression can be treated as a value diff --git a/go/vt/vtgate/planbuilder/route_test.go b/go/vt/vtgate/planbuilder/route_test.go index 0e0efae42f2..cd4f229e48c 100644 --- a/go/vt/vtgate/planbuilder/route_test.go +++ b/go/vt/vtgate/planbuilder/route_test.go @@ -43,17 +43,18 @@ For easy reference, opcodes are: */ func TestJoinCanMerge(t *testing.T) { - testcases := [engine.NumRouteOpcodes][engine.NumRouteOpcodes]bool{ - {true, false, false, false, false, false, false, false, true, false}, - {false, true, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, true, true, false}, - {true, true, true, true, true, true, true, true, true, true}, - {false, false, false, false, false, false, false, false, true, false}, + testcases := [engine.NumOpcodes][engine.NumOpcodes]bool{ + {true, false, false, false, false, false, false, false, true, false, false}, + {false, true, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, true, true, false, false}, + {true, true, true, true, true, true, true, true, true, true, true}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, } ks := &vindexes.Keyspace{} @@ -71,8 +72,8 @@ func TestJoinCanMerge(t *testing.T) { rRoute := &route{ condition: &sqlparser.ColName{}, } - lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) - rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.Opcode(left), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.Opcode(right), ks) assert.Equal(t, val, lRoute.JoinCanMerge(pb, rRoute, nil, nil), fmt.Sprintf("%v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) }) } @@ -80,17 +81,18 @@ func TestJoinCanMerge(t *testing.T) { } func TestSubqueryCanMerge(t *testing.T) { - testcases := [engine.NumRouteOpcodes][engine.NumRouteOpcodes]bool{ - {true, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, true, true, false}, - {true, true, true, true, true, true, true, true, true, true}, - {false, false, false, false, false, false, false, false, true, false}, + testcases := [engine.NumOpcodes][engine.NumOpcodes]bool{ + {true, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, true, true, false, false}, + {true, true, true, true, true, true, true, true, true, true, true}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, } ks := &vindexes.Keyspace{} @@ -100,34 +102,35 @@ func TestSubqueryCanMerge(t *testing.T) { } rRoute := &route{} for left, vals := range testcases { - lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.Opcode(left), ks) for right, val := range vals { - rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.Opcode(right), ks) assert.Equal(t, val, lRoute.SubqueryCanMerge(pb, rRoute), fmt.Sprintf("%v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) } } } func TestUnionCanMerge(t *testing.T) { - testcases := [engine.NumRouteOpcodes][engine.NumRouteOpcodes]bool{ - {true, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, true, false, false, false, false}, - {false, false, false, false, false, false, false, false, false, false}, - {false, false, false, false, false, false, false, true, false, false}, - {false, false, false, false, false, false, false, false, true, false}, - {false, false, false, false, false, false, false, false, false, false}, + testcases := [engine.NumOpcodes][engine.NumOpcodes]bool{ + {true, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, true, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, true, false, false, false}, + {false, false, false, false, false, false, false, false, true, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, + {false, false, false, false, false, false, false, false, false, false, false}, } ks := &vindexes.Keyspace{} lRoute := &route{} rRoute := &route{} for left, vals := range testcases { - lRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(left), ks) + lRoute.eroute = engine.NewSimpleRoute(engine.Opcode(left), ks) for right, val := range vals { - rRoute.eroute = engine.NewSimpleRoute(engine.RouteOpcode(right), ks) + rRoute.eroute = engine.NewSimpleRoute(engine.Opcode(right), ks) assert.Equal(t, val, lRoute.unionCanMerge(rRoute, false), fmt.Sprintf("can't create a single route from these two inputs %v:%v", lRoute.eroute.RouteType(), rRoute.eroute.RouteType())) } } diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go index ad4e8b713d3..47bd5d7bec2 100644 --- a/go/vt/vtgate/planbuilder/select.go +++ b/go/vt/vtgate/planbuilder/select.go @@ -93,7 +93,7 @@ func rewriteToCNFAndReplan(stmt sqlparser.Statement, getPlan func(sel *sqlparser func shouldRetryWithCNFRewriting(plan logicalPlan) bool { // if we have a I_S query, but have not found table_schema or table_name, let's try CNF - var opcode engine.RouteOpcode + var opcode engine.Opcode var sysTableTableName map[string]evalengine.Expr var sysTableTableSchema []evalengine.Expr @@ -110,7 +110,7 @@ func shouldRetryWithCNFRewriting(plan logicalPlan) bool { return false } - return opcode == engine.SelectDBA && + return opcode == engine.DBA && len(sysTableTableName) == 0 && len(sysTableTableSchema) == 0 } @@ -255,12 +255,12 @@ func setMiscFunc(in logicalPlan, sel *sqlparser.Select) error { return nil } -func copyCommentsAndLocks(statement sqlparser.SelectStatement, sel *sqlparser.Select, opcode engine.RouteOpcode) error { +func copyCommentsAndLocks(statement sqlparser.SelectStatement, sel *sqlparser.Select, opcode engine.Opcode) error { query := sqlparser.GetFirstSelect(statement) query.Comments = sel.Comments query.Lock = sel.Lock if sel.Into != nil { - if opcode != engine.SelectUnsharded { + if opcode != engine.Unsharded { return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "INTO is not supported on sharded keyspace") } query.Into = sel.Into @@ -409,7 +409,7 @@ func (pb *primitiveBuilder) pushFilter(in sqlparser.Expr, whereType string, rese return err } rut, isRoute := origin.(*route) - if isRoute && rut.eroute.Opcode == engine.SelectDBA { + if isRoute && rut.eroute.Opcode == engine.DBA { err := pb.findSysInfoRoutingPredicates(expr, rut, reservedVars) if err != nil { return err @@ -514,10 +514,10 @@ func (pb *primitiveBuilder) pushSelectRoutes(selectExprs sqlparser.SelectExprs, // This code is unreachable because the parser doesn't allow joins for next val statements. return nil, errors.New("unsupported: SELECT NEXT query in cross-shard query") } - if rb.eroute.Opcode != engine.SelectNext { + if rb.eroute.Opcode != engine.Next { return nil, errors.New("NEXT used on a non-sequence table") } - rb.eroute.Opcode = engine.SelectNext + rb.eroute.Opcode = engine.Next resultColumns = append(resultColumns, rb.PushAnonymous(node)) default: return nil, fmt.Errorf("BUG: unexpected select expression type: %T", node) diff --git a/go/vt/vtgate/planbuilder/single_sharded_shortcut.go b/go/vt/vtgate/planbuilder/single_sharded_shortcut.go index 979d7ea283e..efe5f928a9f 100644 --- a/go/vt/vtgate/planbuilder/single_sharded_shortcut.go +++ b/go/vt/vtgate/planbuilder/single_sharded_shortcut.go @@ -46,9 +46,11 @@ func unshardedShortcut(stmt sqlparser.SelectStatement, ks *vindexes.Keyspace, se } plan := &routeGen4{ eroute: &engine.Route{ - Opcode: engine.SelectUnsharded, + RoutingParameters: &engine.RoutingParameters{ + Opcode: engine.Unsharded, + Keyspace: ks, + }, TableName: strings.Join(tableNames, ", "), - Keyspace: ks, }, Select: stmt, } diff --git a/go/vt/vtgate/planbuilder/subquery_op.go b/go/vt/vtgate/planbuilder/subquery_op.go index c8a512d87e2..10dc246afe3 100644 --- a/go/vt/vtgate/planbuilder/subquery_op.go +++ b/go/vt/vtgate/planbuilder/subquery_op.go @@ -100,13 +100,13 @@ func canMergeSubqueryPlans(ctx *plancontext.PlanningContext, a, b *routeGen4) bo return false } switch a.eroute.Opcode { - case engine.SelectUnsharded, engine.SelectReference: + case engine.Unsharded, engine.Reference: return a.eroute.Opcode == b.eroute.Opcode - case engine.SelectDBA: + case engine.DBA: return canSelectDBAMerge(a, b) - case engine.SelectEqualUnique: + case engine.EqualUnique: // Check if they target the same shard. - if b.eroute.Opcode == engine.SelectEqualUnique && + if b.eroute.Opcode == engine.EqualUnique && a.eroute.Vindex == b.eroute.Vindex && a.condition != nil && b.condition != nil && diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt index b194b4c707f..5f95f9bf5d1 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.txt @@ -7,7 +7,7 @@ "Original": "select count(*), col from unsharded", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -26,7 +26,7 @@ Gen4 plan same as above "Original": "select count(*), col from user where id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -49,7 +49,7 @@ Gen4 plan same as above "Original": "select fun(1), col from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -68,7 +68,7 @@ Gen4 plan same as above "Original": "select distinct col1, id from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -87,7 +87,7 @@ Gen4 plan same as above "Original": "select distinct col1, id from user group by col1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -113,7 +113,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -139,7 +139,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -166,7 +166,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -190,7 +190,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -224,7 +224,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -257,7 +257,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -285,7 +285,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -307,7 +307,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -332,7 +332,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -354,7 +354,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -379,7 +379,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -401,7 +401,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -426,7 +426,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -448,7 +448,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -473,7 +473,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -498,7 +498,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -525,7 +525,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -536,7 +536,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -557,7 +557,7 @@ Gen4 plan same as above "Original": "select id, count(*) from user group by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -576,7 +576,7 @@ Gen4 plan same as above "Original": "select id, col, count(*) from user group by id, col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -601,7 +601,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -625,7 +625,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -654,7 +654,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -681,7 +681,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -707,7 +707,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -728,7 +728,7 @@ Gen4 plan same as above "Original": "select id, 1+count(*) from user group by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -747,7 +747,7 @@ Gen4 plan same as above "Original": "select id as val, 1+count(*) from user group by val", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -766,7 +766,7 @@ Gen4 plan same as above "Original": "select val as id, 1+count(*) from user group by user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -785,7 +785,7 @@ Gen4 plan same as above "Original": "select *, id, 1+count(*) from user group by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -804,7 +804,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "Original": "select id, count(*) c from user group by id having id=1 and c=10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -823,7 +823,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "Original": "select id, count(*) c from user group by id having id=1 and c=10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -845,7 +845,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "Original": "select id, count(*) c from user group by id having max(col) \u003e 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -875,7 +875,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -905,7 +905,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -932,7 +932,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -958,7 +958,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -985,7 +985,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1007,7 +1007,7 @@ Gen4 plan same as above "Original": "select id, count(distinct col) from user group by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1032,7 +1032,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1056,7 +1056,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1083,7 +1083,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1109,7 +1109,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1135,7 +1135,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1160,7 +1160,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1187,7 +1187,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1213,7 +1213,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1240,7 +1240,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1266,7 +1266,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1293,7 +1293,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1319,7 +1319,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1351,7 +1351,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1384,7 +1384,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1418,7 +1418,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1444,7 +1444,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1471,7 +1471,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1497,7 +1497,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1524,7 +1524,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1550,7 +1550,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1576,7 +1576,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1599,7 +1599,7 @@ Gen4 error: Can't group on 'count(*)' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1630,7 +1630,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1652,7 +1652,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1678,7 +1678,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1707,7 +1707,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1736,7 +1736,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1762,7 +1762,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1789,7 +1789,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1815,7 +1815,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1842,7 +1842,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1868,7 +1868,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1904,7 +1904,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1934,7 +1934,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1957,7 +1957,7 @@ Gen4 plan same as above "Original": "select user.col1 as a from user where user.id = 5 group by a collate utf8_general_ci", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1980,7 +1980,7 @@ Gen4 plan same as above "Original": "select id, count(*) from route2 group by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1999,7 +1999,7 @@ Gen4 plan same as above "Original": "select col from ref order by col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -2027,7 +2027,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2061,7 +2061,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2094,7 +2094,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2138,7 +2138,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2165,7 +2165,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2190,7 +2190,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2219,7 +2219,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2243,7 +2243,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2276,7 +2276,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2288,7 +2288,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2317,7 +2317,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2346,7 +2346,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2379,7 +2379,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2408,7 +2408,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2432,7 +2432,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2454,7 +2454,7 @@ Gen4 plan same as above "Original": "select user.id, count(*) c from user, user_extra where user.id = user_extra.user_id group by user.id having max(user.col) \u003e 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2477,7 +2477,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2499,7 +2499,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2519,7 +2519,7 @@ Gen4 plan same as above "Original": "select id from user group by id having count(id) = 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2544,7 +2544,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2570,7 +2570,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2597,7 +2597,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2623,7 +2623,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2648,7 +2648,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2671,7 +2671,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2702,7 +2702,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2714,7 +2714,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2748,7 +2748,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2780,7 +2780,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2812,7 +2812,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2844,7 +2844,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2876,7 +2876,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2908,7 +2908,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2940,7 +2940,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2972,7 +2972,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3005,7 +3005,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3046,7 +3046,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt index 9d2137f5900..c451a31a157 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt @@ -1689,7 +1689,7 @@ Gen4 plan same as above "Original": "update user_extra set val = 1 where user_id in (1, 2)", "Instructions": { "OperatorType": "Update", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1894,7 +1894,7 @@ Gen4 plan same as above "Original": "delete from user_extra where user_id in (1, 2)", "Instructions": { "OperatorType": "Delete", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2006,7 +2006,7 @@ Gen4 plan same as above "Original": "update user set name = null where id in (1, 2, 3)", "Instructions": { "OperatorType": "Update", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2088,7 +2088,7 @@ Gen4 plan same as above "Original": "delete from user where id in (1, 2, 3)", "Instructions": { "OperatorType": "Delete", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2546,7 +2546,7 @@ Gen4 plan same as above "Original": "delete from zlookup_unique.t1 where c2 = 10 and c3 in (20, 21)", "Instructions": { "OperatorType": "Delete", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "zlookup_unique", "Sharded": true @@ -2573,7 +2573,7 @@ Gen4 plan same as above "Original": "update zlookup_unique.t1 set c2 = 1 where c2 = 10 and c3 in (20, 21)", "Instructions": { "OperatorType": "Update", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "zlookup_unique", "Sharded": true @@ -2702,7 +2702,7 @@ Gen4 plan same as above "Original": "update multicol_tbl set x = 1 where colb IN (1,2) and cola = 1", "Instructions": { "OperatorType": "Update", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2727,7 +2727,7 @@ Gen4 plan same as above "Original": "update multicol_tbl set x = 1 where colb IN (1,2) and cola IN (3,4)", "Instructions": { "OperatorType": "Update", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2808,7 +2808,7 @@ Gen4 plan same as above "Original": "delete from multicol_tbl where colb IN (1,2) and cola = 1", "Instructions": { "OperatorType": "Delete", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2836,7 +2836,7 @@ Gen4 plan same as above "Original": "delete from multicol_tbl where colb IN (1,2) and cola IN (3,4)", "Instructions": { "OperatorType": "Delete", - "Variant": "In", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt index 581d2ad42c0..39df69cc86d 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt @@ -5,7 +5,7 @@ "Original": "select id from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -24,7 +24,7 @@ Gen4 plan same as above "Original": "select id from user where someColumn = null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -43,7 +43,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -66,7 +66,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = 5+5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -81,7 +81,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = 5+5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -103,7 +103,7 @@ Gen4 plan same as above "Original": "select id from music where id = 5 and user_id = 4", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -126,7 +126,7 @@ Gen4 plan same as above "Original": "select id from user where costly = 'aa' and name = 'bb'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -149,7 +149,7 @@ Gen4 plan same as above "Original": "select id from user where costly in ('aa', 'bb') and name in ('aa', 'bb')", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -172,7 +172,7 @@ Gen4 plan same as above "Original": "select id from user where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -195,7 +195,7 @@ Gen4 plan same as above "Original": "select id from user where (col, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -218,7 +218,7 @@ Gen4 plan same as above "Original": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -241,7 +241,7 @@ Gen4 plan same as above "Original": "select id from user where (name, costly) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -264,7 +264,7 @@ Gen4 plan same as above "Original": "select id from user where (col, costly) in (('aa', 'bb')) and (col, name) in (('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -287,7 +287,7 @@ Gen4 plan same as above "Original": "select id from user where (col, name) in (('aa', 'bb')) and id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -310,7 +310,7 @@ Gen4 plan same as above "Original": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -333,7 +333,7 @@ Gen4 plan same as above "Original": "select id from user where ((col1, name), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -356,7 +356,7 @@ Gen4 plan same as above "Original": "select id from user where (name, (col1, col2)) in (('aa', ('bb', 'cc')), ('dd', ('ee', 'ff')))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -379,7 +379,7 @@ Gen4 plan same as above "Original": "select id from user where ((col1, name), col2) in (('aa', 'bb', 'cc'), (('dd', 'ee'), 'ff'))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -398,7 +398,7 @@ Gen4 plan same as above "Original": "select id from user where (col1, name) in (select * from music where music.user_id=user.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -417,7 +417,7 @@ Gen4 plan same as above "Original": "select id from user where (col1, name) in (('aa', 1+1))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -432,7 +432,7 @@ Gen4 plan same as above "Original": "select id from user where (col1, name) in (('aa', 1+1))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -454,7 +454,7 @@ Gen4 plan same as above "Original": "select Id from user where 1 in ('aa', 'bb')", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -473,7 +473,7 @@ Gen4 plan same as above "Original": "select id from user where name in (col, 'bb')", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -492,7 +492,7 @@ Gen4 plan same as above "Original": "select id from user where name = :a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -515,7 +515,7 @@ Gen4 plan same as above "Original": "select id from user where name = 18446744073709551615", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -538,7 +538,7 @@ Gen4 plan same as above "Original": "select id from user where name in ::list", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -561,7 +561,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -580,7 +580,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -602,7 +602,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -621,7 +621,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -643,7 +643,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -666,7 +666,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -685,7 +685,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -716,7 +716,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -731,7 +731,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -761,7 +761,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -776,7 +776,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -797,7 +797,7 @@ Gen4 plan same as above "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5 and user_extra.user_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -828,7 +828,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -839,7 +839,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -873,7 +873,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -884,7 +884,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -910,7 +910,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -921,7 +921,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -941,7 +941,7 @@ Gen4 plan same as above "Original": "select id from user where user.col = 5 and user.id in (1, 2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -964,7 +964,7 @@ Gen4 plan same as above "Original": "select id from user where user.col = case user.col when 'foo' then true else false end and user.id in (1, 2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -987,7 +987,7 @@ Gen4 plan same as above "Original": "select (id or col) as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -1010,7 +1010,7 @@ Gen4 plan same as above "Original": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -1033,7 +1033,7 @@ Gen4 plan same as above "Original": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1056,7 +1056,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1079,7 +1079,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1107,7 +1107,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1118,7 +1118,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1144,7 +1144,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1155,7 +1155,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1179,7 +1179,7 @@ Gen4 plan same as above "Original": "select col from route1 where id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1211,7 +1211,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1222,7 +1222,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1252,7 +1252,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1263,7 +1263,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1296,7 +1296,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1307,7 +1307,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1337,7 +1337,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1348,7 +1348,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1378,7 +1378,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1389,7 +1389,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1416,7 +1416,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1427,7 +1427,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1460,7 +1460,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1471,7 +1471,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1501,7 +1501,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1512,7 +1512,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1536,7 +1536,7 @@ Gen4 plan same as above "Original": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1555,7 +1555,7 @@ Gen4 plan same as above "Original": "select id from user where id = 5 and user.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1578,7 +1578,7 @@ Gen4 plan same as above "Original": "select id from user where id = 'aa' and user.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1601,7 +1601,7 @@ Gen4 plan same as above "Original": "select id from user where id = :a and user.col in (select user_extra.col from user_extra where user_extra.user_id = :a)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1629,7 +1629,7 @@ Gen4 plan same as above "Original": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1657,7 +1657,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1668,7 +1668,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1701,7 +1701,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1712,7 +1712,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1741,7 +1741,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1752,7 +1752,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1776,7 +1776,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1787,7 +1787,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1815,7 +1815,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1826,7 +1826,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1867,7 +1867,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1878,7 +1878,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1891,7 +1891,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1928,7 +1928,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1939,7 +1939,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1952,7 +1952,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1976,7 +1976,7 @@ Gen4 plan same as above "Original": "select col from user where id = (select id from route1 where route1.id = user.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2003,7 +2003,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2014,7 +2014,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2039,7 +2039,7 @@ Gen4 plan same as above "Original": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2058,7 +2058,7 @@ Gen4 plan same as above "Original": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2080,7 +2080,7 @@ Gen4 plan same as above "Original": "select id from user where database()", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2099,7 +2099,7 @@ Gen4 plan same as above "Original": "select id from music where id = null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -2118,7 +2118,7 @@ Gen4 plan same as above "Original": "select id from music where id is null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2141,7 +2141,7 @@ Gen4 plan same as above "Original": "select id from music where id is not null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2160,7 +2160,7 @@ Gen4 plan same as above "Original": "select id from music where user_id = 4 and id = null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -2179,7 +2179,7 @@ Gen4 plan same as above "Original": "select id from music where user_id = 4 and id IN (null)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -2198,7 +2198,7 @@ Gen4 plan same as above "Original": "select id from music where user_id = 4 and id IN (null, 1, 2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2221,7 +2221,7 @@ Gen4 plan same as above "Original": "select id from music where user_id = 4 and id NOT IN (null, 1, 2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -2240,7 +2240,7 @@ Gen4 plan same as above "Original": "select id from music where id NOT IN (null, 1, 2) and user_id = 4", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNone", + "Variant": "None", "Keyspace": { "Name": "user", "Sharded": true @@ -2267,7 +2267,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2290,7 +2290,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2305,7 +2305,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2336,7 +2336,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2359,7 +2359,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2374,7 +2374,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2400,7 +2400,7 @@ Gen4 plan same as above "Original": "select c2 from cfc_vindex_col where c1 like 'A%'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -2422,7 +2422,7 @@ Gen4 plan same as above "Original": "select * from samecolvin where col = :col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2445,7 +2445,7 @@ Gen4 plan same as above "Original": "select id from user where user.id \u003e 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2464,7 +2464,7 @@ Gen4 plan same as above "Original": "select unsharded.id from unsharded where unsharded.name in (select name from unsharded_a)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2479,7 +2479,7 @@ Gen4 plan same as above "Original": "select unsharded.id from unsharded where unsharded.name in (select name from unsharded_a)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2505,7 +2505,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2516,7 +2516,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -2546,7 +2546,7 @@ Gen4 plan same as above "Original": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2565,7 +2565,7 @@ Gen4 plan same as above "Original": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -2584,7 +2584,7 @@ Gen4 plan same as above "Original": "select ref.col from ref where ref.col in (select ref.col from ref)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -2603,7 +2603,7 @@ Gen4 plan same as above "Original": "select u1.col from user as u1 where u1.id = 5 and u1.name in (select u2.name from user u2 where u2.id = 5)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2626,7 +2626,7 @@ Gen4 plan same as above "Original": "select u1.col from user as u1 where u1.id = 5 and exists (select u2.name from user u2 where u2.id = 5)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2649,7 +2649,7 @@ Gen4 plan same as above "Original": "select u1.col from user as u1 where u1.id = 5 and not exists (select u2.name from user u2 where u2.id = 5)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2680,7 +2680,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2695,7 +2695,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2719,7 +2719,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2734,7 +2734,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2762,7 +2762,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2777,7 +2777,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2806,7 +2806,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2821,7 +2821,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2853,7 +2853,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2868,7 +2868,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2897,7 +2897,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2912,7 +2912,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2936,7 +2936,7 @@ Gen4 plan same as above "Original": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id) and u.col2 in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2951,7 +2951,7 @@ Gen4 plan same as above "Original": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id) and u.col2 in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2969,7 +2969,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = user.col and user.col = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2984,7 +2984,7 @@ Gen4 plan same as above "Original": "select id from user where user.id = user.col and user.col = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3015,7 +3015,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3026,7 +3026,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3043,7 +3043,7 @@ Gen4 plan same as above "Original": "select id from user, user_extra where user.id = user_extra.col and user_extra.col = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3070,7 +3070,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3081,7 +3081,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3107,7 +3107,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3118,7 +3118,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3142,7 +3142,7 @@ Gen4 plan same as above "Original": "select col from user where id = (select id from route1 as a where a.id = user.id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3171,7 +3171,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3182,7 +3182,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3227,7 +3227,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3238,7 +3238,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3273,7 +3273,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3284,7 +3284,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3317,7 +3317,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3328,7 +3328,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3351,7 +3351,7 @@ Gen4 error: expr cannot be converted, not supported: foo(user_extra.foobar) "Original": "select * from multicolvin where column_b = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3374,7 +3374,7 @@ Gen4 plan same as above "Original": "select * from multicolvin where column_b = 1 and column_c = 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3397,7 +3397,7 @@ Gen4 plan same as above "Original": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3420,7 +3420,7 @@ Gen4 plan same as above "Original": "select * from multicolvin where column_a = 3 and column_b = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3439,7 +3439,7 @@ Gen4 plan same as above "Original": "select * from multicolvin where column_a = 3 and column_b = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3461,7 +3461,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1 and colb = 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3476,7 +3476,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1 and colb = 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3499,7 +3499,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 2 and cola = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3514,7 +3514,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 2 and cola = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3537,7 +3537,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola in (1,2) and colb in (3,4)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3552,7 +3552,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola in (1,2) and colb in (3,4)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -3575,7 +3575,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (3,4) and cola in (1,2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3590,7 +3590,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (3,4) and cola in (1,2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -3613,7 +3613,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 1 and cola in (3,4)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3628,7 +3628,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 1 and cola in (3,4)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -3651,7 +3651,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola in (1,10) and cola = 4 and colb in (5,6) and colb = 7", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3666,7 +3666,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola in (1,10) and cola = 4 and colb in (5,6) and colb = 7", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3689,7 +3689,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 4 and colb in (1,10) and cola in (5,6)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3704,7 +3704,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb = 4 and colb in (1,10) and cola in (5,6)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -3727,7 +3727,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (1,10) and colb = 4 and cola in (5,6)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3742,7 +3742,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (1,10) and colb = 4 and cola in (5,6)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -3765,7 +3765,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (1,2) and cola IN (3,4) and cola = 5 and colb = 6", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3780,7 +3780,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where colb in (1,2) and cola IN (3,4) and cola = 5 and colb = 6", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3803,7 +3803,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where (cola,colb) in ((1,2),(3,4))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3818,7 +3818,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where (cola,colb) in ((1,2),(3,4))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectMultiEqual", + "Variant": "MultiEqual", "Keyspace": { "Name": "user", "Sharded": true @@ -3842,7 +3842,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3857,7 +3857,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -3879,7 +3879,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1 and colb in (2,3)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3894,7 +3894,7 @@ Gen4 plan same as above "Original": "select * from multicol_tbl where cola = 1 and colb in (2,3)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -3916,7 +3916,7 @@ Gen4 plan same as above "Original": "select 0 from unsharded_a left join unsharded_b on unsharded_a.col = unsharded_b.col where coalesce(unsharded_b.col, 4) = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index 9f67289775c..3aa1b4a3148 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -5,7 +5,7 @@ "Original": "select col from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -24,7 +24,7 @@ Gen4 plan same as above "Original": "select col from unsharded", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -43,7 +43,7 @@ Gen4 plan same as above "Original": "select next 2 values from seq", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNext", + "Variant": "Next", "Keyspace": { "Name": "main", "Sharded": false @@ -67,7 +67,7 @@ Gen4 plan same as above "Original": "select 1 from (select next value from seq) t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNext", + "Variant": "Next", "Keyspace": { "Name": "main", "Sharded": false @@ -86,7 +86,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' "Original": "select * from (select next value from seq) t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectNext", + "Variant": "Next", "Keyspace": { "Name": "main", "Sharded": false @@ -113,7 +113,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectNext", + "Variant": "Next", "Keyspace": { "Name": "main", "Sharded": false @@ -124,7 +124,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -157,7 +157,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectNext", + "Variant": "Next", "Keyspace": { "Name": "main", "Sharded": false @@ -168,7 +168,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -189,7 +189,7 @@ Gen4 error: Incorrect usage/placement of 'NEXT' "Original": "select * from ref", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -208,7 +208,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 join unsharded as m2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -233,7 +233,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -244,7 +244,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -265,7 +265,7 @@ Gen4 plan same as above "Original": "select * from second_user.user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -284,7 +284,7 @@ Gen4 plan same as above "Original": "select * from second_user.user as a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -303,7 +303,7 @@ Gen4 plan same as above "Original": "select * from route1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -322,7 +322,7 @@ Gen4 plan same as above "Original": "select * from route1 as a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -341,7 +341,7 @@ Gen4 plan same as above "Original": "select * from primary_redirect", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -369,7 +369,7 @@ Gen4 plan same as above "Original": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -384,7 +384,7 @@ Gen4 plan same as above "Original": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -410,7 +410,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -421,7 +421,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -451,7 +451,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -462,7 +462,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -492,7 +492,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -503,7 +503,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -524,7 +524,7 @@ Gen4 plan same as above "Original": "select u1.a, u2.a from unsharded u1, unsharded u2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -543,7 +543,7 @@ Gen4 plan same as above "Original": "select u1.a, u2.a from unsharded u1, unsharded u2, unsharded u3", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -562,7 +562,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a=m2.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -590,7 +590,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -601,7 +601,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -627,7 +627,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -638,7 +638,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -676,7 +676,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -687,7 +687,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -700,7 +700,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -735,7 +735,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -746,7 +746,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -759,7 +759,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -788,7 +788,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -807,7 +807,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -818,7 +818,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -841,7 +841,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 right join unsharded as m2 on m1.a=m2.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -856,7 +856,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 right join unsharded as m2 on m1.a=m2.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -874,7 +874,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 join unsharded as m2 right join unsharded as m3 on m1.a=m2.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -889,7 +889,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 join unsharded as m2 right join unsharded as m3 on m1.a=m2.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -907,7 +907,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 straight_join unsharded as m2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -922,7 +922,7 @@ Gen4 plan same as above "Original": "select m1.col from unsharded as m1 straight_join unsharded as m2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -952,7 +952,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -963,7 +963,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -976,7 +976,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -999,7 +999,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1010,7 +1010,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1036,7 +1036,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1047,7 +1047,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1070,7 +1070,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1081,7 +1081,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1107,7 +1107,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1123,7 +1123,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1134,7 +1134,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1159,7 +1159,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1176,7 +1176,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1187,7 +1187,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1209,7 +1209,7 @@ Gen4 plan same as above "Original": "select user.col from user use index(a)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1228,7 +1228,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1243,7 +1243,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1261,7 +1261,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on (user.id = user_extra.user_id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1276,7 +1276,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on (user.id = user_extra.user_id)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1294,7 +1294,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1309,7 +1309,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1327,7 +1327,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user_extra.user_id = user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1342,7 +1342,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user_extra.user_id = user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1360,7 +1360,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1379,7 +1379,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1410,7 +1410,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1421,7 +1421,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1447,7 +1447,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1458,7 +1458,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1484,7 +1484,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1499,7 +1499,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1526,7 +1526,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1541,7 +1541,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1571,7 +1571,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1582,7 +1582,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1608,7 +1608,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1619,7 +1619,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1652,7 +1652,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1663,7 +1663,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -1693,7 +1693,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1704,7 +1704,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1728,7 +1728,7 @@ Gen4 plan same as above "Original": "select user.col from user join ref", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1743,7 +1743,7 @@ Gen4 plan same as above "Original": "select user.col from user join ref", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1761,7 +1761,7 @@ Gen4 plan same as above "Original": "select r1.col from ref r1 join ref", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -1776,7 +1776,7 @@ Gen4 plan same as above "Original": "select r1.col from ref r1 join ref", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -1794,7 +1794,7 @@ Gen4 plan same as above "Original": "select ref.col from ref join user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1809,7 +1809,7 @@ Gen4 plan same as above "Original": "select ref.col from ref join user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1828,7 +1828,7 @@ Gen4 plan same as above "Original": "select ref.col from ref join (select aa from user where user.id=1) user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1847,7 +1847,7 @@ Gen4 plan same as above "Original": "select ref.col from ref join (select aa from user where user.id=1) user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1875,7 +1875,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1886,7 +1886,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1907,7 +1907,7 @@ Gen4 plan same as above "Original": "select id from (select id, col from user where id = 5) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1930,7 +1930,7 @@ Gen4 plan same as above "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1949,7 +1949,7 @@ Gen4 plan same as above "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1971,7 +1971,7 @@ Gen4 plan same as above "Original": "select t.id from (select user.id from user where user.id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1990,7 +1990,7 @@ Gen4 plan same as above "Original": "select t.id from (select user.id from user where user.id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2017,7 +2017,7 @@ Gen4 error: Duplicate column name 'id' "Original": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2032,7 +2032,7 @@ Gen4 error: Duplicate column name 'id' "Original": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2063,7 +2063,7 @@ Gen4 error: Duplicate column name 'id' "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2078,7 +2078,7 @@ Gen4 error: Duplicate column name 'id' }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2099,7 +2099,7 @@ Gen4 plan same as above "Original": "select id from (select id, col from route1 where id = 5) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2122,7 +2122,7 @@ Gen4 plan same as above "Original": "select t.id from (select id from user) as t join user_extra on t.id = user_extra.user_id where t.col = 42", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2141,7 +2141,7 @@ Gen4 error: symbol t.col not found "Original": "select id from (select id, col from route1) as t where id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2160,7 +2160,7 @@ Gen4 error: symbol t.col not found "Original": "select id from (select id, col from route1) as t where id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2182,7 +2182,7 @@ Gen4 error: symbol t.col not found "Original": "select id from (select id+col as foo from route1) as t where foo = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2201,7 +2201,7 @@ Gen4 error: symbol id not found "Original": "select t.id from (select id, textcol1 as baz from route1) as t join (select id, textcol1+textcol1 as baz from user) as s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2216,7 +2216,7 @@ Gen4 error: symbol id not found "Original": "select t.id from (select id, textcol1 as baz from route1) as t join (select id, textcol1+textcol1 as baz from user) as s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2234,7 +2234,7 @@ Gen4 error: symbol id not found "Original": "select bar from (select foo+4 as bar from (select colA+colB as foo from user) as u) as t where bar = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2249,7 +2249,7 @@ Gen4 error: symbol id not found "Original": "select bar from (select foo+4 as bar from (select colA+colB as foo from user) as u) as t where bar = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2267,7 +2267,7 @@ Gen4 error: symbol id not found "Original": "select id from (select id from (select id from user) as u) as t where id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2286,7 +2286,7 @@ Gen4 error: symbol id not found "Original": "select id from (select id from (select id from user) as u) as t where id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2308,7 +2308,7 @@ Gen4 error: symbol id not found "Original": "select u.col, e.col from (select col from user where id = 5) as u join (select col from user_extra where user_id = 5) as e", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2327,7 +2327,7 @@ Gen4 error: symbol id not found "Original": "select u.col, e.col from (select col from user where id = 5) as u join (select col from user_extra where user_id = 5) as e", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2355,7 +2355,7 @@ Gen4 error: symbol id not found "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -2366,7 +2366,7 @@ Gen4 error: symbol id not found }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2393,7 +2393,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2404,7 +2404,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -2448,7 +2448,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2459,7 +2459,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2474,7 +2474,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2510,7 +2510,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2521,7 +2521,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2555,7 +2555,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2566,7 +2566,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2594,7 +2594,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2617,7 +2617,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2628,7 +2628,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2663,7 +2663,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2686,7 +2686,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2701,7 +2701,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2733,7 +2733,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2744,7 +2744,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2768,7 +2768,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2779,7 +2779,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2807,7 +2807,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2818,7 +2818,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2842,7 +2842,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2853,7 +2853,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2881,7 +2881,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2892,7 +2892,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2917,7 +2917,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2928,7 +2928,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2956,7 +2956,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2973,7 +2973,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2984,7 +2984,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3014,7 +3014,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3033,7 +3033,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3044,7 +3044,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3071,7 +3071,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3088,7 +3088,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3099,7 +3099,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3136,7 +3136,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3153,7 +3153,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3164,7 +3164,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3179,7 +3179,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3204,7 +3204,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3221,7 +3221,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3232,7 +3232,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3263,7 +3263,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3274,7 +3274,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3300,7 +3300,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3311,7 +3311,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3331,7 +3331,7 @@ Gen4 plan same as above "Original": "select main.foo.col from main.foo", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3350,7 +3350,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3365,7 +3365,7 @@ Gen4 plan same as above "Original": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3396,7 +3396,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3407,7 +3407,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3431,7 +3431,7 @@ Gen4 plan same as above "Original": "select u1.a from unsharded u1 join unsharded u2 on database()", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3472,7 +3472,7 @@ Gen4 plan same as above "Original": "select last_insert_id() from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3491,7 +3491,7 @@ Gen4 plan same as above "Original": "select last_insert_id() from main.unsharded", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3519,7 +3519,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3530,7 +3530,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3556,7 +3556,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3567,7 +3567,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3600,7 +3600,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3611,7 +3611,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3641,7 +3641,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3656,7 +3656,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3725,7 +3725,7 @@ Gen4 plan same as above "Original": "select m1.col from (unsharded as m1, unsharded as m2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -3762,7 +3762,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3773,7 +3773,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3786,7 +3786,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3816,7 +3816,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3827,7 +3827,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3860,7 +3860,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3871,7 +3871,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3897,7 +3897,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3908,7 +3908,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -3943,7 +3943,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3973,7 +3973,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -3995,7 +3995,7 @@ Gen4 plan same as above "Original": "select u.* from (select * from unsharded) u", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -4027,7 +4027,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -4042,7 +4042,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4077,7 +4077,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4088,7 +4088,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4111,7 +4111,7 @@ Gen4 plan same as above "Original": "select u.a from (select id as b, name from user) u(a, n) where u.n = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -4134,7 +4134,7 @@ Gen4 plan same as above "Original": "select u.a from (select id as b, name from user where b = 1) u(a, n) where u.n = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -4169,7 +4169,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4180,7 +4180,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4210,7 +4210,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4233,7 +4233,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4246,7 +4246,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -4281,7 +4281,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4302,7 +4302,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4313,7 +4313,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -4348,7 +4348,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4359,7 +4359,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4385,7 +4385,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4396,7 +4396,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4439,7 +4439,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -4450,7 +4450,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -4465,7 +4465,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/hash_joins.txt b/go/vt/vtgate/planbuilder/testdata/hash_joins.txt index c1cad77ba05..afc175a581c 100644 --- a/go/vt/vtgate/planbuilder/testdata/hash_joins.txt +++ b/go/vt/vtgate/planbuilder/testdata/hash_joins.txt @@ -15,7 +15,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -30,7 +30,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -55,7 +55,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -70,7 +70,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -100,7 +100,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -111,7 +111,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -136,7 +136,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -147,7 +147,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -182,7 +182,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -193,7 +193,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -226,7 +226,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -237,7 +237,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -268,7 +268,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -279,7 +279,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -304,7 +304,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -315,7 +315,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -371,7 +371,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -382,7 +382,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -399,7 +399,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -412,7 +412,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -429,7 +429,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -458,7 +458,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -487,7 +487,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -498,7 +498,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -515,7 +515,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/large_cases.txt b/go/vt/vtgate/planbuilder/testdata/large_cases.txt index 1a3974a70a7..21e14f8af3b 100644 --- a/go/vt/vtgate/planbuilder/testdata/large_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/large_cases.txt @@ -13,7 +13,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -32,7 +32,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -52,7 +52,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -75,7 +75,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -94,7 +94,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -110,7 +110,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -126,7 +126,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -142,7 +142,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -153,7 +153,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -194,7 +194,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -211,7 +211,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -222,7 +222,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt index daa5e12d809..4d91069b05a 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.txt @@ -19,7 +19,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -55,7 +55,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -93,7 +93,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -133,7 +133,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -173,7 +173,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -212,7 +212,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -245,7 +245,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -286,7 +286,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -297,7 +297,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -337,7 +337,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -348,7 +348,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -387,7 +387,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -402,7 +402,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -440,7 +440,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -455,7 +455,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -496,7 +496,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -511,7 +511,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -549,7 +549,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -564,7 +564,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -602,7 +602,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -613,7 +613,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -644,7 +644,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -655,7 +655,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -689,7 +689,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -700,7 +700,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -731,7 +731,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -742,7 +742,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -797,7 +797,7 @@ Gen4 plan same as above "Original": "select a from user order by binary a desc", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -814,7 +814,7 @@ Gen4 plan same as above "Original": "select a from user order by binary a desc", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -843,7 +843,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -856,7 +856,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -882,7 +882,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -894,7 +894,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -914,7 +914,7 @@ Gen4 plan same as above "Original": "select id, intcol from user order by intcol", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -935,7 +935,7 @@ Gen4 plan same as above "Original": "select col from user order by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt b/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt index 17eccf03d34..56d8276f232 100644 --- a/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/oltp_cases.txt @@ -5,7 +5,7 @@ "Original": "SELECT c FROM sbtest34 WHERE id=15", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -28,7 +28,7 @@ Gen4 plan same as above "Original": "SELECT c FROM sbtest12 WHERE id BETWEEN 1 AND 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -52,7 +52,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -74,7 +74,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -94,7 +94,7 @@ Gen4 plan same as above "Original": "SELECT c FROM sbtest1 WHERE id BETWEEN 50 AND 235 ORDER BY c", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -111,7 +111,7 @@ Gen4 plan same as above "Original": "SELECT c FROM sbtest1 WHERE id BETWEEN 50 AND 235 ORDER BY c", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -137,7 +137,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -162,7 +162,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt index d64065595cf..9bdc1019d2c 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt @@ -5,7 +5,7 @@ "Original": "select user.col1 from user having col2 = 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -20,7 +20,7 @@ "Original": "select user.col1 from user having col2 = 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -50,7 +50,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -61,7 +61,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -84,7 +84,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -95,7 +95,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -121,7 +121,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -132,7 +132,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -155,7 +155,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -166,7 +166,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -194,7 +194,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -205,7 +205,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -234,7 +234,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -245,7 +245,7 @@ Gen4 error: Column 'col1' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -269,7 +269,7 @@ Gen4 error: Column 'col1' in field list is ambiguous "Original": "select col from user where id = 5 order by aa", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -292,7 +292,7 @@ Gen4 plan same as above "Original": "select col from user where id = 1 order by 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -311,7 +311,7 @@ Gen4 plan same as above "Original": "select col from user where id = 1 order by 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -333,7 +333,7 @@ Gen4 plan same as above "Original": "select col from user order by col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -373,7 +373,7 @@ Gen4 error: unsupported: '*' expression in cross-shard query "Original": "select * from authoritative order by user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -394,7 +394,7 @@ Gen4 plan same as above "Original": "select * from authoritative order by col1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -411,7 +411,7 @@ Gen4 plan same as above "Original": "select * from authoritative order by col1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -431,7 +431,7 @@ Gen4 plan same as above "Original": "select a, textcol1, b from user order by a, textcol1, b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -448,7 +448,7 @@ Gen4 plan same as above "Original": "select a, textcol1, b from user order by a, textcol1, b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -468,7 +468,7 @@ Gen4 plan same as above "Original": "select a, user.textcol1, b from user order by a, textcol1, b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -485,7 +485,7 @@ Gen4 plan same as above "Original": "select a, user.textcol1, b from user order by a, textcol1, b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -505,7 +505,7 @@ Gen4 plan same as above "Original": "select a, textcol1, b, textcol2 from user order by a, textcol1, b, textcol2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -522,7 +522,7 @@ Gen4 plan same as above "Original": "select a, textcol1, b, textcol2 from user order by a, textcol1, b, textcol2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -547,7 +547,7 @@ Gen4 plan same as above "Original": "select id as foo from music order by 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -564,7 +564,7 @@ Gen4 plan same as above "Original": "select id as foo from music order by 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -584,7 +584,7 @@ Gen4 plan same as above "Original": "select col from user order by null", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -611,7 +611,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -622,7 +622,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -653,7 +653,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -668,7 +668,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -698,7 +698,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -713,7 +713,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -746,7 +746,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -761,7 +761,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -791,7 +791,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -807,7 +807,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -840,7 +840,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -855,7 +855,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -885,7 +885,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -901,7 +901,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -933,7 +933,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -944,7 +944,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -965,7 +965,7 @@ Gen4 plan same as above "Original": "select col from user order by RAND()", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -993,7 +993,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1008,7 +1008,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1038,7 +1038,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1053,7 +1053,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1085,7 +1085,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1096,7 +1096,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1117,7 +1117,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1140,7 +1140,7 @@ Gen4 plan same as above "Original": "select user.* from user where id = 5 order by user.col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1163,7 +1163,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by user.col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1195,7 +1195,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1206,7 +1206,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1232,7 +1232,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1243,7 +1243,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1264,7 +1264,7 @@ Gen4 plan same as above "Original": "select u.id from user u having u.id in (select col2 from user where user.id = u.id order by u.col)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1297,7 +1297,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by user.col collate utf8_general_ci", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1320,7 +1320,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by -col1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1343,7 +1343,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by concat(col,col1) collate utf8_general_ci desc", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1366,7 +1366,7 @@ Gen4 plan same as above "Original": "select * from user where id = 5 order by id+col collate utf8_general_ci desc", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1389,7 +1389,7 @@ Gen4 plan same as above "Original": "select * from user u join (select user_id from user_extra where user_id = 5) eu on u.id = eu.user_id where u.id = 5 order by eu.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1408,7 +1408,7 @@ Gen4 plan same as above "Original": "select * from user u join (select user_id from user_extra where user_id = 5) eu on u.id = eu.user_id where u.id = 5 order by eu.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1430,7 +1430,7 @@ Gen4 plan same as above "Original": "select col from route1 where id = 1 order by col", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1453,7 +1453,7 @@ Gen4 plan same as above "Original": "select col1 from user where id = 1 limit 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1487,7 +1487,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1498,7 +1498,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1525,7 +1525,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1550,7 +1550,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1575,7 +1575,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1608,7 +1608,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1619,7 +1619,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1642,7 +1642,7 @@ Gen4 plan same as above "Original": "select col from ref limit 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -1665,7 +1665,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1686,7 +1686,7 @@ Gen4 plan same as above "Original": "select id as foo from music order by foo", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1707,7 +1707,7 @@ Gen4 plan same as above "Original": "select id as foo, id2 as id from music order by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1734,7 +1734,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1747,7 +1747,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1770,7 +1770,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1782,7 +1782,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1807,7 +1807,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1840,7 +1840,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1869,7 +1869,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1895,7 +1895,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1927,7 +1927,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1960,7 +1960,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1990,7 +1990,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2002,7 +2002,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2023,7 +2023,7 @@ Gen4 error: In aggregated query without GROUP BY, expression of SELECT list cont "Original": "select id, id from user order by id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2057,7 +2057,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2068,7 +2068,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2099,7 +2099,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2111,7 +2111,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2138,7 +2138,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2163,7 +2163,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2191,7 +2191,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2213,7 +2213,7 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non "Original": "select id from unsharded order by (select id from unsharded)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/rails_cases.txt b/go/vt/vtgate/planbuilder/testdata/rails_cases.txt index d9e1329399f..b8a84d9c432 100644 --- a/go/vt/vtgate/planbuilder/testdata/rails_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/rails_cases.txt @@ -41,7 +41,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -52,7 +52,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -69,7 +69,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -82,7 +82,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -99,7 +99,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -129,7 +129,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -158,7 +158,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -169,7 +169,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -186,7 +186,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt index 5c1d647fd2c..a1565880132 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt @@ -5,7 +5,7 @@ "Original": "select 1 from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -24,7 +24,7 @@ Gen4 plan same as above "Original": "select user.* from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -43,7 +43,7 @@ Gen4 plan same as above "Original": "select * from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -62,7 +62,7 @@ Gen4 plan same as above "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -87,7 +87,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -110,7 +110,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -135,7 +135,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -157,7 +157,7 @@ Gen4 plan same as above "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS */ * from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -182,7 +182,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -205,7 +205,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -231,7 +231,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -254,7 +254,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -279,7 +279,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -301,7 +301,7 @@ Gen4 plan same as above "Original": "select user.* from user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -320,7 +320,7 @@ Gen4 plan same as above "Original": "select user.user.* from user.user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -339,7 +339,7 @@ Gen4 plan same as above "Original": "select * from authoritative", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -358,7 +358,7 @@ Gen4 plan same as above "Original": "select * from authoritative a join authoritative b on a.user_id=b.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -373,7 +373,7 @@ Gen4 plan same as above "Original": "select * from authoritative a join authoritative b on a.user_id=b.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -396,7 +396,7 @@ Gen4 error: Unknown table 'a' "Original": "select a.* from authoritative a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -415,7 +415,7 @@ Gen4 plan same as above "Original": "select * from authoritative join user on authoritative.user_id=user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -430,7 +430,7 @@ Gen4 plan same as above "Original": "select * from authoritative join user on authoritative.user_id=user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -448,7 +448,7 @@ Gen4 plan same as above "Original": "select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -463,7 +463,7 @@ Gen4 plan same as above "Original": "select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -481,7 +481,7 @@ Gen4 plan same as above "Original": "select anon_col from user join user_extra on user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -496,7 +496,7 @@ Gen4 plan same as above "Original": "select anon_col from user join user_extra on user.id = user_extra.user_id", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -525,7 +525,7 @@ Gen4 error: Column 'col' in field list is ambiguous "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -536,7 +536,7 @@ Gen4 error: Column 'col' in field list is ambiguous }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -579,7 +579,7 @@ Gen4 plan same as above "Original": "select last_insert_id() as x from main.unsharded", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -598,7 +598,7 @@ Gen4 plan same as above "Original": "select @@session.auto_increment_increment from dual", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -617,7 +617,7 @@ Gen4 plan same as above "Original": "select * from pin_test", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -640,7 +640,7 @@ Gen4 plan same as above "Original": "select @@session.auto_increment_increment from user.dual", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "user", "Sharded": true @@ -665,7 +665,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -676,7 +676,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -703,7 +703,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -714,7 +714,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -741,7 +741,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -752,7 +752,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -779,7 +779,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -790,7 +790,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -817,7 +817,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -828,7 +828,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -855,7 +855,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -866,7 +866,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -896,7 +896,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -907,7 +907,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -934,7 +934,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -945,7 +945,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -971,7 +971,7 @@ Gen4 plan same as above "Original": "select * from user where id = 0x04", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -995,7 +995,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1018,7 +1018,7 @@ Gen4 plan same as above "Original": "select * from user where name ='abc' AND (id = 4) limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1041,7 +1041,7 @@ Gen4 plan same as above "Original": "select * from user where (id = 4) AND (name ='abc') limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1064,7 +1064,7 @@ Gen4 plan same as above "Original": "select * from user where (id = 4 and name ='abc') limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1087,7 +1087,7 @@ Gen4 plan same as above "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col desc limit 2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1110,7 +1110,7 @@ Gen4 plan same as above "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc limit 3", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1133,7 +1133,7 @@ Gen4 plan same as above "Original": "select * from user where (id = 1) AND name = true limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1156,7 +1156,7 @@ Gen4 plan same as above "Original": "select * from user where (id = 1) AND name limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1179,7 +1179,7 @@ Gen4 plan same as above "Original": "select * from user where (id = 5) AND name = true limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1210,7 +1210,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1221,7 +1221,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1245,7 +1245,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1256,7 +1256,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1284,7 +1284,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1295,7 +1295,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1319,7 +1319,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1330,7 +1330,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1363,7 +1363,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1374,7 +1374,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1407,7 +1407,7 @@ Gen4 error: symbol t.col not found "Original": "select * from music where user_id = 1 union select * from user where id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1430,7 +1430,7 @@ Gen4 plan same as above "Original": "select *, last_insert_id() from music where user_id = 1 union select * from user where id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1453,7 +1453,7 @@ Gen4 plan same as above "Original": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1468,7 +1468,7 @@ Gen4 plan same as above "Original": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1486,7 +1486,7 @@ Gen4 plan same as above "Original": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1504,7 +1504,7 @@ Gen4 plan same as above "Original": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1519,7 +1519,7 @@ Gen4 plan same as above "Original": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1537,7 +1537,7 @@ Gen4 plan same as above "Original": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1552,7 +1552,7 @@ Gen4 plan same as above "Original": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1570,7 +1570,7 @@ Gen4 plan same as above "Original": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1585,7 +1585,7 @@ Gen4 plan same as above "Original": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1603,7 +1603,7 @@ Gen4 plan same as above "Original": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1622,7 +1622,7 @@ Gen4 plan same as above "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from route2", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1664,7 +1664,7 @@ Gen4 plan same as above "Original": "select 42 from dual where false", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -1705,7 +1705,7 @@ Gen4 plan same as above "Original": "select sql_calc_found_rows * from music where user_id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1735,7 +1735,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1753,7 +1753,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1779,7 +1779,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1797,7 +1797,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1822,7 +1822,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1837,7 +1837,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1869,7 +1869,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1889,7 +1889,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1915,7 +1915,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1935,7 +1935,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1967,7 +1967,7 @@ Gen4 plan same as above "Original": "select * from main.unsharded into Dumpfile 'x.txt'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1986,7 +1986,7 @@ Gen4 plan same as above "Original": "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2005,7 +2005,7 @@ Gen4 plan same as above "Original": "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2038,7 +2038,7 @@ Gen4 plan same as above "Original": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2067,7 +2067,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2078,7 +2078,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2101,7 +2101,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2112,7 +2112,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2159,7 +2159,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -2170,7 +2170,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2187,7 +2187,7 @@ Gen4 plan same as above "Original": "select 42, id from dual, user", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": false @@ -2211,7 +2211,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -2222,7 +2222,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2254,7 +2254,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2273,7 +2273,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2286,7 +2286,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2316,7 +2316,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2335,7 +2335,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2347,7 +2347,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2386,7 +2386,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2405,7 +2405,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2416,7 +2416,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2454,7 +2454,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2473,7 +2473,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2484,7 +2484,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2512,7 +2512,7 @@ Gen4 plan same as above "Original": "select N'string' from dual", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -2540,7 +2540,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2551,7 +2551,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2581,7 +2581,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2592,7 +2592,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2625,7 +2625,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2637,7 +2637,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -2677,7 +2677,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2688,7 +2688,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2701,7 +2701,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2730,7 +2730,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2741,7 +2741,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2775,7 +2775,7 @@ Gen4 error: exists sub-queries are only supported with AND clause "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2786,7 +2786,7 @@ Gen4 error: exists sub-queries are only supported with AND clause }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -2819,7 +2819,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2830,7 +2830,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2857,7 +2857,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -2868,7 +2868,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt index f31ab8742c6..6501e07be15 100644 --- a/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/symtab_cases.txt @@ -16,7 +16,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -27,7 +27,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/sysschema_default.txt b/go/vt/vtgate/planbuilder/testdata/sysschema_default.txt index 17f9390b579..7e9e288cc79 100644 --- a/go/vt/vtgate/planbuilder/testdata/sysschema_default.txt +++ b/go/vt/vtgate/planbuilder/testdata/sysschema_default.txt @@ -5,7 +5,7 @@ "Original": "select @@max_allowed_packet from dual", "Instructions": { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -24,7 +24,7 @@ Gen4 plan same as above "Original": "select t.table_schema,t.table_name,c.column_name,c.column_type from tables t join columns c on c.table_schema = t.table_schema and c.table_name = t.table_name where t.table_schema = 'user' and c.table_schema = 'user' order by t.table_schema,t.table_name,c.column_name", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -40,7 +40,7 @@ Gen4 plan same as above "Original": "select t.table_schema,t.table_name,c.column_name,c.column_type from tables t join columns c on c.table_schema = t.table_schema and c.table_name = t.table_name where t.table_schema = 'user' and c.table_schema = 'user' order by t.table_schema,t.table_name,c.column_name", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -59,7 +59,7 @@ Gen4 plan same as above "Original": "SELECT (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1);", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -79,7 +79,7 @@ Gen4 plan same as above "Original": "SELECT * from (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1) x", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -95,7 +95,7 @@ Gen4 plan same as above "Original": "SELECT * from (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1) x", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt index 7e384d56212..075ccaebb15 100644 --- a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt @@ -5,7 +5,7 @@ "Original": "select col from information_schema.foo", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -24,7 +24,7 @@ Gen4 plan same as above "Original": "select a.id,b.id from information_schema.a as a, information_schema.b as b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -43,7 +43,7 @@ Gen4 plan same as above "Original": "select column_name from information_schema.columns where table_schema = (select schema())", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -62,7 +62,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a join information_schema.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -77,7 +77,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a join information_schema.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -95,7 +95,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a where b=10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -114,7 +114,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a where information_schema.a.b=10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -129,7 +129,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a where information_schema.a.b=10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -147,7 +147,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a union select * from information_schema.b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -172,7 +172,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -184,7 +184,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -210,7 +210,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -222,7 +222,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -245,7 +245,7 @@ Gen4 plan same as above "Original": "SELECT DELETE_RULE, UPDATE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -262,7 +262,7 @@ Gen4 plan same as above "Original": "SELECT DELETE_RULE, UPDATE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -288,7 +288,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -301,7 +301,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -320,7 +320,7 @@ Gen4 plan same as above "Original": "SELECT KCU.DELETE_RULE, S.UPDATE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.K AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -340,7 +340,7 @@ Gen4 plan same as above "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -360,7 +360,7 @@ Gen4 plan same as above "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -380,7 +380,7 @@ Gen4 plan same as above "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -396,7 +396,7 @@ Gen4 plan same as above "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -415,7 +415,7 @@ Gen4 plan same as above "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -431,7 +431,7 @@ Gen4 plan same as above "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -450,7 +450,7 @@ Gen4 plan same as above "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -470,7 +470,7 @@ Gen4 plan same as above "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -491,7 +491,7 @@ Gen4 plan same as above "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -508,7 +508,7 @@ Gen4 plan same as above "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -528,7 +528,7 @@ Gen4 plan same as above "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -545,7 +545,7 @@ Gen4 plan same as above "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -565,7 +565,7 @@ Gen4 plan same as above "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -586,7 +586,7 @@ Gen4 plan same as above "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -607,7 +607,7 @@ Gen4 plan same as above "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -626,7 +626,7 @@ Gen4 plan same as above "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -646,7 +646,7 @@ Gen4 plan same as above "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -663,7 +663,7 @@ Gen4 plan same as above "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -682,7 +682,7 @@ Gen4 plan same as above "Original": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc WHERE cc.constraint_schema = 'a' AND cc.table_schema = 'a'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -702,7 +702,7 @@ Gen4 plan same as above "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -723,7 +723,7 @@ Gen4 plan same as above "Original": "select * from information_schema.a where id in (select * from information_schema.b)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -742,7 +742,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -762,7 +762,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -781,7 +781,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -801,7 +801,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -822,7 +822,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and other_column = 42", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -842,7 +842,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and other_column = 42) OR (TABLE_SCHEMA = 'ks' and foobar = 'value')", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -862,7 +862,7 @@ Gen4 plan same as above "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -890,7 +890,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -901,7 +901,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -931,7 +931,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -942,7 +942,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -966,7 +966,7 @@ Gen4 plan same as above "Original": "select a.*, b.* from information_schema.a a, information_schema.b b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -985,7 +985,7 @@ Gen4 plan same as above "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1001,7 +1001,7 @@ Gen4 plan same as above "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1020,7 +1020,7 @@ Gen4 plan same as above "Original": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1048,7 +1048,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1060,7 +1060,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1080,7 +1080,7 @@ Gen4 plan same as above "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1102,7 +1102,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1114,7 +1114,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1132,7 +1132,7 @@ Gen4 plan same as above "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1154,7 +1154,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1166,7 +1166,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1184,7 +1184,7 @@ Gen4 plan same as above "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1214,7 +1214,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1226,7 +1226,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1240,7 +1240,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1258,7 +1258,7 @@ Gen4 plan same as above "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1289,7 +1289,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1301,7 +1301,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1322,7 +1322,7 @@ Gen4 plan same as above "Original": "select id from (select id from information_schema.table t where t.schema_name = 'a' union select id from information_schema.columns) dt", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1355,7 +1355,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1367,7 +1367,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1382,7 +1382,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1399,7 +1399,7 @@ Gen4 plan same as above "Original": "select id from information_schema.random t where t.col in (select id from information_schema.table t where t.schema_name = 'a' union select id from information_schema.columns)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -1419,7 +1419,7 @@ Gen4 plan same as above "Original": "select * from (select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `constraint_name` = 'primary'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt index 44b05fcef44..63ecdc0a9ea 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.txt @@ -5,7 +5,7 @@ "Original": "SELECT c_discount, c_last, c_credit, w_tax FROM customer1 AS c JOIN warehouse1 AS w ON c_w_id=w_id WHERE w_id = 1 AND c_d_id = 15 AND c_id = 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -24,7 +24,7 @@ "Original": "SELECT c_discount, c_last, c_credit, w_tax FROM customer1 AS c JOIN warehouse1 AS w ON c_w_id=w_id WHERE w_id = 1 AND c_d_id = 15 AND c_id = 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -46,7 +46,7 @@ "Original": "SELECT d_next_o_id, d_tax FROM district1 WHERE d_w_id = 15 AND d_id = 95 FOR UPDATE", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -133,7 +133,7 @@ Gen4 plan same as above "Original": "SELECT i_price, i_name, i_data FROM item1 WHERE i_id = 9654", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -156,7 +156,7 @@ Gen4 plan same as above "Original": "SELECT s_quantity, s_data, s_dist_01 s_dist FROM stock1 WHERE s_i_id = 2198 AND s_w_id = 89 FOR UPDATE", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -247,7 +247,7 @@ Gen4 plan same as above "Original": "SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name FROM warehouse1 WHERE w_id = 998", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -294,7 +294,7 @@ Gen4 plan same as above "Original": "SELECT d_street_1, d_street_2, d_city, d_state, d_zip, d_name FROM district1 WHERE d_w_id = 896 AND d_id = 9", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -317,7 +317,7 @@ Gen4 plan same as above "Original": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 5 AND c_d_id= 1 AND c_last='last'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -340,7 +340,7 @@ Gen4 plan same as above "Original": "SELECT c_id FROM customer1 WHERE c_w_id = 8 AND c_d_id = 5 AND c_last='item_last' ORDER BY c_first", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -363,7 +363,7 @@ Gen4 plan same as above "Original": "SELECT c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since FROM customer1 WHERE c_w_id = 8965 AND c_d_id = 1 AND c_id = 9 FOR UPDATE", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -386,7 +386,7 @@ Gen4 plan same as above "Original": "SELECT c_data FROM customer1 WHERE c_w_id = 32 AND c_d_id=68 AND c_id = 5", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -477,7 +477,7 @@ Gen4 plan same as above "Original": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 870 AND c_d_id= 780 AND c_last='last'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -500,7 +500,7 @@ Gen4 plan same as above "Original": "SELECT c_balance, c_first, c_middle, c_id FROM customer1 WHERE c_w_id = 840 AND c_d_id= 1 AND c_last='test' ORDER BY c_first", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -523,7 +523,7 @@ Gen4 plan same as above "Original": "SELECT c_balance, c_first, c_middle, c_last FROM customer1 WHERE c_w_id = 15 AND c_d_id=5169 AND c_id=1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -546,7 +546,7 @@ Gen4 plan same as above "Original": "SELECT o_id, o_carrier_id, o_entry_d FROM orders1 WHERE o_w_id = 9894 AND o_d_id = 3 AND o_c_id = 159 ORDER BY o_id DESC", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -569,7 +569,7 @@ Gen4 plan same as above "Original": "SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line1 WHERE ol_w_id = 92 AND ol_d_id = 5 AND ol_o_id = 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -592,7 +592,7 @@ Gen4 plan same as above "Original": "SELECT no_o_id FROM new_orders1 WHERE no_d_id = 689 AND no_w_id = 15 ORDER BY no_o_id ASC LIMIT 1 FOR UPDATE", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -639,7 +639,7 @@ Gen4 plan same as above "Original": "SELECT o_c_id FROM orders1 WHERE o_id = 6 AND o_d_id = 1983 AND o_w_id = 894605", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -710,7 +710,7 @@ Gen4 plan same as above "Original": "SELECT SUM(ol_amount) sm FROM order_line1 WHERE ol_o_id = 680 AND ol_d_id = 201 AND ol_w_id = 87", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -757,7 +757,7 @@ Gen4 plan same as above "Original": "SELECT d_next_o_id FROM district1 WHERE d_id = 6 AND d_w_id= 21", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -780,7 +780,7 @@ Gen4 plan same as above "Original": "SELECT COUNT(DISTINCT(s.s_i_id)) FROM stock1 AS s JOIN order_line1 AS ol ON ol.ol_w_id=s.s_w_id AND ol.ol_i_id=s.s_i_id WHERE ol.ol_w_id = 12 AND ol.ol_d_id = 1908 AND ol.ol_o_id \u003c 30 AND ol.ol_o_id \u003e= 15 AND s.s_w_id= 12 AND s.s_quantity \u003c 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -799,7 +799,7 @@ Gen4 plan same as above "Original": "SELECT COUNT(DISTINCT(s.s_i_id)) FROM stock1 AS s JOIN order_line1 AS ol ON ol.ol_w_id=s.s_w_id AND ol.ol_i_id=s.s_i_id WHERE ol.ol_w_id = 12 AND ol.ol_d_id = 1908 AND ol.ol_o_id \u003c 30 AND ol.ol_o_id \u003e= 15 AND s.s_w_id= 12 AND s.s_quantity \u003c 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -821,7 +821,7 @@ Gen4 plan same as above "Original": "SELECT DISTINCT ol_i_id FROM order_line1 WHERE ol_w_id = 1 AND ol_d_id = 156 AND ol_o_id \u003c 500 AND ol_o_id \u003e= 56", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -844,7 +844,7 @@ Gen4 plan same as above "Original": "SELECT count(*) FROM stock1 WHERE s_w_id = 1 AND s_i_id = 8 AND s_quantity \u003c 1000", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -882,7 +882,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -893,7 +893,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -916,7 +916,7 @@ Gen4 plan same as above "Original": "select o.o_id,o.o_d_id from orders1 o, (select o_c_id,o_w_id,o_d_id,count(distinct o_w_id),o_id from orders1 where o_w_id=1 and o_id \u003e 2100 and o_id \u003c 11153 group by o_c_id,o_d_id,o_w_id having count( distinct o_id) \u003e 1 limit 1) t where t.o_w_id=o.o_w_id and t.o_d_id=o.o_d_id and t.o_c_id=o.o_c_id limit 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt b/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt index 3d44bc47a8c..c81d3db6349 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/tpch_cases.txt @@ -35,7 +35,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -57,7 +57,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -134,7 +134,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -156,7 +156,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -169,7 +169,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -205,7 +205,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -218,7 +218,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -261,7 +261,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -286,7 +286,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -297,7 +297,7 @@ Gen4 error: unsupported: in scatter query: complex aggregate expression }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -347,7 +347,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -376,7 +376,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "main", "Sharded": true @@ -392,7 +392,7 @@ Gen4 error: unsupported: cross-shard correlated subquery }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -409,7 +409,7 @@ Gen4 error: unsupported: cross-shard correlated subquery }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "main", "Sharded": true @@ -455,7 +455,7 @@ Gen4 error: unsupported: cross-shard correlated subquery "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true @@ -466,7 +466,7 @@ Gen4 error: unsupported: cross-shard correlated subquery }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "main", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/union_cases.txt b/go/vt/vtgate/planbuilder/testdata/union_cases.txt index 1eaaf539566..f1cf39f80c9 100644 --- a/go/vt/vtgate/planbuilder/testdata/union_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/union_cases.txt @@ -5,7 +5,7 @@ "Original": "select id from user union all select id from music", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -30,7 +30,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -41,7 +41,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -63,7 +63,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -86,7 +86,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -101,7 +101,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -133,7 +133,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -152,7 +152,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -177,7 +177,7 @@ Gen4 plan same as above "Original": "select col1, col2 from user union all select col1, col2 from user_extra", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -196,7 +196,7 @@ Gen4 plan same as above "Original": "select * from (select * from user union all select * from user_extra) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -215,7 +215,7 @@ Gen4 plan same as above "Original": "select col1,col2 from (select col1, col2 from user union all select col1, col2 from user_extra) as t", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -241,7 +241,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -260,7 +260,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -288,7 +288,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -303,7 +303,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -330,7 +330,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -341,7 +341,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -366,7 +366,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -377,7 +377,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -405,7 +405,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -416,7 +416,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -441,7 +441,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -452,7 +452,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -486,7 +486,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -497,7 +497,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -512,7 +512,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -537,7 +537,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -548,7 +548,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -576,7 +576,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -590,7 +590,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -601,7 +601,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -632,7 +632,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -649,7 +649,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -660,7 +660,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -693,7 +693,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -708,7 +708,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -737,7 +737,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -752,7 +752,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -784,7 +784,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -799,7 +799,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -828,7 +828,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -843,7 +843,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -875,7 +875,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -888,7 +888,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -912,7 +912,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -940,7 +940,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -951,7 +951,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -976,7 +976,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -987,7 +987,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1021,7 +1021,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1032,7 +1032,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1045,7 +1045,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1076,7 +1076,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1087,7 +1087,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1100,7 +1100,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1128,7 +1128,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1145,7 +1145,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1156,7 +1156,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1183,7 +1183,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1200,7 +1200,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1211,7 +1211,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1246,7 +1246,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1264,7 +1264,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1296,7 +1296,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1314,7 +1314,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1356,7 +1356,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1367,7 +1367,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1382,7 +1382,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1412,7 +1412,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1441,7 +1441,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1452,7 +1452,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1484,7 +1484,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1495,7 +1495,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -1526,7 +1526,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1537,7 +1537,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported }, { "OperatorType": "Route", - "Variant": "SelectReference", + "Variant": "Reference", "Keyspace": { "Name": "main", "Sharded": false @@ -1561,7 +1561,7 @@ Gen4 error: nesting of unions at the right-hand side is not yet supported "Original": "(select 1 from unsharded union select 1 from unsharded union all select 1 from unsharded order by 1) union select 1 from unsharded union all select 1 from unsharded order by 1", "Instructions": { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1598,7 +1598,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1609,7 +1609,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1624,7 +1624,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1639,7 +1639,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1664,7 +1664,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -1675,7 +1675,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1719,7 +1719,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1738,7 +1738,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1757,7 +1757,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -1800,7 +1800,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1819,7 +1819,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1838,7 +1838,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt index 3276bd52009..62320cbb1a8 100644 --- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt @@ -454,7 +454,7 @@ Gen4 plan same as above "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectDBA", + "Variant": "DBA", "Keyspace": { "Name": "main", "Sharded": false @@ -478,7 +478,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -523,7 +523,7 @@ Gen4 error: expr cannot be converted, not supported: count(ue.col) > 10 "Original": "select 1 from user having count(id) = 10", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -542,7 +542,7 @@ Gen4 error: expr cannot be converted, not supported: count(id) = 10 "Original": "select 1 from user having count(id) = 10 and name = 'a'", "Instructions": { "OperatorType": "Route", - "Variant": "SelectEqual", + "Variant": "Equal", "Keyspace": { "Name": "user", "Sharded": true @@ -592,7 +592,7 @@ Gen4 error: Column 'id' in field list is ambiguous "Original": "select id2 from (select id from user) as x (id2)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true diff --git a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt index 2eef8921494..7da76d64603 100644 --- a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.txt @@ -134,7 +134,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -169,7 +169,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -195,7 +195,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -230,7 +230,7 @@ Gen4 plan same as above "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -285,7 +285,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -325,7 +325,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -368,7 +368,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -408,7 +408,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -451,7 +451,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -491,7 +491,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -534,7 +534,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -574,7 +574,7 @@ Gen4 plan same as above }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt index 6595796e505..6c376ee9333 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.txt @@ -14,7 +14,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -25,7 +25,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -51,7 +51,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -62,7 +62,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -95,7 +95,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -106,7 +106,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -132,7 +132,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -143,7 +143,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -182,7 +182,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -193,7 +193,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -206,7 +206,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -229,7 +229,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -249,7 +249,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -260,7 +260,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -297,7 +297,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -308,7 +308,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -321,7 +321,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -344,7 +344,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -363,7 +363,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -374,7 +374,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -414,7 +414,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -425,7 +425,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -438,7 +438,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -464,7 +464,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -484,7 +484,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -495,7 +495,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -544,7 +544,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -555,7 +555,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -568,7 +568,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -585,7 +585,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -608,7 +608,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -628,7 +628,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -648,7 +648,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -659,7 +659,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -696,7 +696,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -712,7 +712,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -727,7 +727,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -768,7 +768,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -779,7 +779,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -796,7 +796,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -829,7 +829,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -840,7 +840,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -866,7 +866,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -877,7 +877,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -910,7 +910,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -921,7 +921,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -947,7 +947,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectUnsharded", + "Variant": "Unsharded", "Keyspace": { "Name": "main", "Sharded": false @@ -958,7 +958,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectEqualUnique", + "Variant": "EqualUnique", "Keyspace": { "Name": "user", "Sharded": true @@ -995,7 +995,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1006,7 +1006,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1038,7 +1038,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1049,7 +1049,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1092,7 +1092,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1103,7 +1103,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1118,7 +1118,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1160,7 +1160,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1171,7 +1171,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1186,7 +1186,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectIN", + "Variant": "IN", "Keyspace": { "Name": "user", "Sharded": true @@ -1222,7 +1222,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1242,7 +1242,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1253,7 +1253,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1285,7 +1285,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1305,7 +1305,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1316,7 +1316,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1341,7 +1341,7 @@ "Original": "select id from user where id in (18446744073709551616, 1)", "Instructions": { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1366,7 +1366,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1377,7 +1377,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1404,7 +1404,7 @@ "Inputs": [ { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true @@ -1415,7 +1415,7 @@ }, { "OperatorType": "Route", - "Variant": "SelectScatter", + "Variant": "Scatter", "Keyspace": { "Name": "user", "Sharded": true From e8328c0b6b564929afcbc61edaeeac725b0cdba3 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 21 Jan 2022 13:30:51 +0530 Subject: [PATCH 09/12] refactor: moved all route routing logic to common routing Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 4 +- go/vt/vtgate/engine/route.go | 210 ------------------------------- go/vt/vtgate/engine/routing.go | 222 +++++++++++++++++++++++++++++++-- 3 files changed, 212 insertions(+), 224 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 518db9ae2f4..922ab7715fa 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -106,7 +106,7 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp } func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, _, err := del.findRoutingInfo(vcursor, bindVars) + rss, _, err := del.findRoute(vcursor, bindVars) if err != nil { return nil, err } @@ -193,7 +193,7 @@ func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.Bi } func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - rss, _, err := del.findRoutingInfo(vcursor, bindVars) + rss, _, err := del.findRoute(vcursor, bindVars) if err != nil { return nil, err } diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 38e0007c4ff..dea63f02531 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -24,7 +24,6 @@ import ( "time" "vitess.io/vitess/go/mysql/collations" - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/vtgate/evalengine" "vitess.io/vitess/go/mysql" @@ -216,32 +215,6 @@ func (route *Route) executeInternal(vcursor VCursor, bindVars map[string]*queryp return route.sort(result) } -func (route *Route) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - switch route.Opcode { - case DBA, Unsharded, Next, Reference, Scatter, Equal, EqualUnique: - return route.findRoutingInfo(vcursor, bindVars) - case IN: - switch route.Vindex.(type) { - case vindexes.MultiColumn: - return route.paramsSelectInMultiCol(vcursor, bindVars) - default: - return route.paramsSelectIn(vcursor, bindVars) - } - case MultiEqual: - switch route.Vindex.(type) { - case vindexes.MultiColumn: - return route.paramsSelectMultiEqualMultiCol(vcursor, bindVars) - default: - return route.paramsSelectMultiEqual(vcursor, bindVars) - } - case None: - return nil, nil, nil - default: - // Unreachable. - return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported query route: %v", route) - } -} - func filterOutNilErrors(errs []error) []error { var errors []error for _, err := range errs { @@ -332,101 +305,6 @@ func (route *Route) GetFields(vcursor VCursor, bindVars map[string]*querypb.Bind return qr.Truncate(route.TruncateColumnCount), nil } -func resolveShardsMultiCol(vcursor VCursor, vindex vindexes.MultiColumn, keyspace *vindexes.Keyspace, rowColValues [][]sqltypes.Value, shardIdsNeeded bool) ([]*srvtopo.ResolvedShard, [][][]*querypb.Value, error) { - destinations, err := vindex.Map(vcursor, rowColValues) - if err != nil { - return nil, nil, err - } - - // And use the Resolver to map to ResolvedShards. - rss, shardsValues, err := vcursor.ResolveDestinationsMultiCol(keyspace.Name, rowColValues, destinations) - if err != nil { - return nil, nil, err - } - - if shardIdsNeeded { - return rss, buildMultiColumnVindexValues(shardsValues), nil - } - return rss, nil, nil -} - -// buildMultiColumnVindexValues takes in the values resolved for each shard and transposes them -// and eliminates duplicates, returning the values to be used for each column for a multi column -// vindex in each shard. -func buildMultiColumnVindexValues(shardsValues [][][]sqltypes.Value) [][][]*querypb.Value { - var shardsIds [][][]*querypb.Value - for _, shardValues := range shardsValues { - // shardValues -> [[0,1], [0,2], [0,3]] - // shardIds -> [[0,0,0], [1,2,3]] - // cols = 2 - cols := len(shardValues[0]) - shardIds := make([][]*querypb.Value, cols) - colValSeen := make([]map[string]interface{}, cols) - for _, values := range shardValues { - for colIdx, value := range values { - if colValSeen[colIdx] == nil { - colValSeen[colIdx] = map[string]interface{}{} - } - if _, found := colValSeen[colIdx][value.String()]; found { - continue - } - shardIds[colIdx] = append(shardIds[colIdx], sqltypes.ValueToProto(value)) - colValSeen[colIdx][value.String()] = nil - } - } - shardsIds = append(shardsIds, shardIds) - } - return shardsIds -} - -func shardVarsMultiCol(bv map[string]*querypb.BindVariable, mapVals [][][]*querypb.Value, isSingleVal map[int]interface{}) []map[string]*querypb.BindVariable { - shardVars := make([]map[string]*querypb.BindVariable, len(mapVals)) - for i, shardVals := range mapVals { - newbv := make(map[string]*querypb.BindVariable, len(bv)+len(shardVals)-len(isSingleVal)) - for k, v := range bv { - newbv[k] = v - } - for j, vals := range shardVals { - if _, found := isSingleVal[j]; found { - // this vindex column is non-tuple column hence listVal bind variable is not required to be set. - continue - } - newbv[ListVarName+strconv.Itoa(j)] = &querypb.BindVariable{ - Type: querypb.Type_TUPLE, - Values: vals, - } - } - shardVars[i] = newbv - } - return shardVars -} - -func (route *Route) paramsSelectIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := evalengine.EnvWithBindVars(bindVars) - value, err := env.Evaluate(route.Values[0]) - if err != nil { - return nil, nil, err - } - rss, values, err := resolveShards(vcursor, route.Vindex.(vindexes.SingleColumn), route.Keyspace, value.TupleValues()) - if err != nil { - return nil, nil, err - } - return rss, shardVars(bindVars, values), nil -} - -func (route *Route) paramsSelectInMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - rowColValues, isSingleVal, err := generateRowColValues(bindVars, route.Values) - if err != nil { - return nil, nil, err - } - - rss, mapVals, err := resolveShardsMultiCol(vcursor, route.Vindex.(vindexes.MultiColumn), route.Keyspace, rowColValues, true /* shardIdsNeeded */) - if err != nil { - return nil, nil, err - } - return rss, shardVarsMultiCol(bindVars, mapVals, isSingleVal), nil -} - func generateRowColValues(bindVars map[string]*querypb.BindVariable, values []evalengine.Expr) ([][]sqltypes.Value, map[int]interface{}, error) { // gather values from all the column in the vindex var multiColValues [][]sqltypes.Value @@ -481,78 +359,6 @@ func buildRowColValues(left [][]sqltypes.Value, right []sqltypes.Value) [][]sqlt return allCombinations } -func (route *Route) paramsSelectMultiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - env := evalengine.EnvWithBindVars(bindVars) - value, err := env.Evaluate(route.Values[0]) - if err != nil { - return nil, nil, err - } - rss, _, err := resolveShards(vcursor, route.Vindex.(vindexes.SingleColumn), route.Keyspace, value.TupleValues()) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func (route *Route) paramsSelectMultiEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { - var multiColValues [][]sqltypes.Value - env := evalengine.EnvWithBindVars(bindVars) - for _, rvalue := range route.Values { - v, err := env.Evaluate(rvalue) - if err != nil { - return nil, nil, err - } - multiColValues = append(multiColValues, v.TupleValues()) - } - - // transpose from multi col value to vindex keys with one value from each multi column values. - // [1,3] - // [2,4] - // [5,6] - // change - // [1,2,5] - // [3,4,6] - - rowColValues := make([][]sqltypes.Value, len(multiColValues[0])) - for _, colValues := range multiColValues { - for row, colVal := range colValues { - rowColValues[row] = append(rowColValues[row], colVal) - } - } - - rss, _, err := resolveShardsMultiCol(vcursor, route.Vindex.(vindexes.MultiColumn), route.Keyspace, rowColValues, false /* shardIdsNotNeeded */) - if err != nil { - return nil, nil, err - } - multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) - for i := range multiBindVars { - multiBindVars[i] = bindVars - } - return rss, multiBindVars, nil -} - -func resolveShards(vcursor VCursor, vindex vindexes.SingleColumn, keyspace *vindexes.Keyspace, vindexKeys []sqltypes.Value) ([]*srvtopo.ResolvedShard, [][]*querypb.Value, error) { - // Convert vindexKeys to []*querypb.Value - ids := make([]*querypb.Value, len(vindexKeys)) - for i, vik := range vindexKeys { - ids[i] = sqltypes.ValueToProto(vik) - } - - // Map using the Vindex - destinations, err := vindex.Map(vcursor, vindexKeys) - if err != nil { - return nil, nil, err - - } - - // And use the Resolver to map to ResolvedShards. - return vcursor.ResolveDestinations(keyspace.Name, ids, destinations) -} - func (route *Route) sort(in *sqltypes.Result) (*sqltypes.Result, error) { var err error // Since Result is immutable, we make a copy. @@ -639,22 +445,6 @@ func getQueries(query string, bvs []map[string]*querypb.BindVariable) []*querypb return queries } -func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) []map[string]*querypb.BindVariable { - shardVars := make([]map[string]*querypb.BindVariable, len(mapVals)) - for i, vals := range mapVals { - newbv := make(map[string]*querypb.BindVariable, len(bv)+1) - for k, v := range bv { - newbv[k] = v - } - newbv[ListVarName] = &querypb.BindVariable{ - Type: querypb.Type_TUPLE, - Values: vals, - } - shardVars[i] = newbv - } - return shardVars -} - func (route *Route) description() PrimitiveDescription { other := map[string]interface{}{ "Query": route.Query, diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index 382d73b577c..76fd577c2e9 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -18,6 +18,7 @@ package engine import ( "encoding/json" + "strconv" "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" @@ -118,8 +119,10 @@ type RoutingParameters struct { Values []evalengine.Expr } -func (rp *RoutingParameters) findRoutingInfo(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { switch rp.Opcode { + case None: + return nil, nil, nil case DBA: return rp.systemQuery(vcursor, bindVars) case Unsharded, Next: @@ -133,12 +136,24 @@ func (rp *RoutingParameters) findRoutingInfo(vcursor VCursor, bindVars map[strin case Equal, EqualUnique: switch rp.Vindex.(type) { case vindexes.MultiColumn: - return rp.paramsSelectEqualMultiCol(vcursor, bindVars) + return rp.equalMultiCol(vcursor, bindVars) default: - return rp.paramsSelectEqual(vcursor, bindVars) + return rp.equal(vcursor, bindVars) + } + case IN: + switch rp.Vindex.(type) { + case vindexes.MultiColumn: + return rp.inMultiCol(vcursor, bindVars) + default: + return rp.in(vcursor, bindVars) + } + case MultiEqual: + switch rp.Vindex.(type) { + case vindexes.MultiColumn: + return rp.paramsSelectMultiEqualMultiCol(vcursor, bindVars) + default: + return rp.paramsSelectMultiEqual(vcursor, bindVars) } - case None: - return nil, nil, nil default: // Unreachable. return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "unsupported opcode: %v", rp.Opcode) @@ -268,11 +283,6 @@ func (rp *RoutingParameters) routedTable(vcursor VCursor, bindVars map[string]*q return nil, nil } -func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { - delete(bindVars, sqltypes.BvSchemaName) - bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) -} - func (rp *RoutingParameters) anyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { rss, _, err := vcursor.ResolveDestinations(rp.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}}) if err != nil { @@ -312,7 +322,7 @@ func (rp *RoutingParameters) byDestination(vcursor VCursor, bindVars map[string] return rss, multiBindVars, err } -func (rp *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) equal(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) value, err := env.Evaluate(rp.Values[0]) if err != nil { @@ -329,7 +339,7 @@ func (rp *RoutingParameters) paramsSelectEqual(vcursor VCursor, bindVars map[str return rss, multiBindVars, nil } -func (rp *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) equalMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) var rowValue []sqltypes.Value for _, rvalue := range rp.Values { @@ -350,3 +360,191 @@ func (rp *RoutingParameters) paramsSelectEqualMultiCol(vcursor VCursor, bindVars } return rss, multiBindVars, nil } + +func (rp *RoutingParameters) in(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + env := evalengine.EnvWithBindVars(bindVars) + value, err := env.Evaluate(rp.Values[0]) + if err != nil { + return nil, nil, err + } + rss, values, err := resolveShards(vcursor, rp.Vindex.(vindexes.SingleColumn), rp.Keyspace, value.TupleValues()) + if err != nil { + return nil, nil, err + } + return rss, shardVars(bindVars, values), nil +} + +func (rp *RoutingParameters) inMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + rowColValues, isSingleVal, err := generateRowColValues(bindVars, rp.Values) + if err != nil { + return nil, nil, err + } + + rss, mapVals, err := resolveShardsMultiCol(vcursor, rp.Vindex.(vindexes.MultiColumn), rp.Keyspace, rowColValues, true /* shardIdsNeeded */) + if err != nil { + return nil, nil, err + } + return rss, shardVarsMultiCol(bindVars, mapVals, isSingleVal), nil +} + +func (rp *RoutingParameters) paramsSelectMultiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + env := evalengine.EnvWithBindVars(bindVars) + value, err := env.Evaluate(rp.Values[0]) + if err != nil { + return nil, nil, err + } + rss, _, err := resolveShards(vcursor, rp.Vindex.(vindexes.SingleColumn), rp.Keyspace, value.TupleValues()) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} + +func (rp *RoutingParameters) paramsSelectMultiEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { + var multiColValues [][]sqltypes.Value + env := evalengine.EnvWithBindVars(bindVars) + for _, rvalue := range rp.Values { + v, err := env.Evaluate(rvalue) + if err != nil { + return nil, nil, err + } + multiColValues = append(multiColValues, v.TupleValues()) + } + + // transpose from multi col value to vindex keys with one value from each multi column values. + // [1,3] + // [2,4] + // [5,6] + // change + // [1,2,5] + // [3,4,6] + + rowColValues := make([][]sqltypes.Value, len(multiColValues[0])) + for _, colValues := range multiColValues { + for row, colVal := range colValues { + rowColValues[row] = append(rowColValues[row], colVal) + } + } + + rss, _, err := resolveShardsMultiCol(vcursor, rp.Vindex.(vindexes.MultiColumn), rp.Keyspace, rowColValues, false /* shardIdsNotNeeded */) + if err != nil { + return nil, nil, err + } + multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) + for i := range multiBindVars { + multiBindVars[i] = bindVars + } + return rss, multiBindVars, nil +} + +func setReplaceSchemaName(bindVars map[string]*querypb.BindVariable) { + delete(bindVars, sqltypes.BvSchemaName) + bindVars[sqltypes.BvReplaceSchemaName] = sqltypes.Int64BindVariable(1) +} + +func resolveShards(vcursor VCursor, vindex vindexes.SingleColumn, keyspace *vindexes.Keyspace, vindexKeys []sqltypes.Value) ([]*srvtopo.ResolvedShard, [][]*querypb.Value, error) { + // Convert vindexKeys to []*querypb.Value + ids := make([]*querypb.Value, len(vindexKeys)) + for i, vik := range vindexKeys { + ids[i] = sqltypes.ValueToProto(vik) + } + + // Map using the Vindex + destinations, err := vindex.Map(vcursor, vindexKeys) + if err != nil { + return nil, nil, err + + } + + // And use the Resolver to map to ResolvedShards. + return vcursor.ResolveDestinations(keyspace.Name, ids, destinations) +} + +func resolveShardsMultiCol(vcursor VCursor, vindex vindexes.MultiColumn, keyspace *vindexes.Keyspace, rowColValues [][]sqltypes.Value, shardIdsNeeded bool) ([]*srvtopo.ResolvedShard, [][][]*querypb.Value, error) { + destinations, err := vindex.Map(vcursor, rowColValues) + if err != nil { + return nil, nil, err + } + + // And use the Resolver to map to ResolvedShards. + rss, shardsValues, err := vcursor.ResolveDestinationsMultiCol(keyspace.Name, rowColValues, destinations) + if err != nil { + return nil, nil, err + } + + if shardIdsNeeded { + return rss, buildMultiColumnVindexValues(shardsValues), nil + } + return rss, nil, nil +} + +// buildMultiColumnVindexValues takes in the values resolved for each shard and transposes them +// and eliminates duplicates, returning the values to be used for each column for a multi column +// vindex in each shard. +func buildMultiColumnVindexValues(shardsValues [][][]sqltypes.Value) [][][]*querypb.Value { + var shardsIds [][][]*querypb.Value + for _, shardValues := range shardsValues { + // shardValues -> [[0,1], [0,2], [0,3]] + // shardIds -> [[0,0,0], [1,2,3]] + // cols = 2 + cols := len(shardValues[0]) + shardIds := make([][]*querypb.Value, cols) + colValSeen := make([]map[string]interface{}, cols) + for _, values := range shardValues { + for colIdx, value := range values { + if colValSeen[colIdx] == nil { + colValSeen[colIdx] = map[string]interface{}{} + } + if _, found := colValSeen[colIdx][value.String()]; found { + continue + } + shardIds[colIdx] = append(shardIds[colIdx], sqltypes.ValueToProto(value)) + colValSeen[colIdx][value.String()] = nil + } + } + shardsIds = append(shardsIds, shardIds) + } + return shardsIds +} + +func shardVars(bv map[string]*querypb.BindVariable, mapVals [][]*querypb.Value) []map[string]*querypb.BindVariable { + shardVars := make([]map[string]*querypb.BindVariable, len(mapVals)) + for i, vals := range mapVals { + newbv := make(map[string]*querypb.BindVariable, len(bv)+1) + for k, v := range bv { + newbv[k] = v + } + newbv[ListVarName] = &querypb.BindVariable{ + Type: querypb.Type_TUPLE, + Values: vals, + } + shardVars[i] = newbv + } + return shardVars +} + +func shardVarsMultiCol(bv map[string]*querypb.BindVariable, mapVals [][][]*querypb.Value, isSingleVal map[int]interface{}) []map[string]*querypb.BindVariable { + shardVars := make([]map[string]*querypb.BindVariable, len(mapVals)) + for i, shardVals := range mapVals { + newbv := make(map[string]*querypb.BindVariable, len(bv)+len(shardVals)-len(isSingleVal)) + for k, v := range bv { + newbv[k] = v + } + for j, vals := range shardVals { + if _, found := isSingleVal[j]; found { + // this vindex column is non-tuple column hence listVal bind variable is not required to be set. + continue + } + newbv[ListVarName+strconv.Itoa(j)] = &querypb.BindVariable{ + Type: querypb.Type_TUPLE, + Values: vals, + } + } + shardVars[i] = newbv + } + return shardVars +} From 23040f95ead61390ab16be9ffca3f226b6cb0b38 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 21 Jan 2022 17:08:27 +0530 Subject: [PATCH 10/12] refactor: delete primitive to use common routing Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 109 +++++++++-------------------- go/vt/vtgate/engine/delete_test.go | 36 ++-------- go/vt/vtgate/engine/routing.go | 8 +-- 3 files changed, 44 insertions(+), 109 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 922ab7715fa..11d5f949a7b 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -25,7 +25,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" @@ -69,22 +68,31 @@ func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind defer cancel() } + rss, _, err := del.findRoute(vcursor, bindVars) + if err != nil { + return nil, err + } + err = allowOnlyPrimary(rss...) + if err != nil { + return nil, err + } + switch del.Opcode { case Unsharded: - return del.execDeleteUnsharded(vcursor, bindVars) + return del.execDeleteUnsharded(vcursor, bindVars, rss) case Equal: switch del.Vindex.(type) { case vindexes.MultiColumn: - return del.execDeleteEqualMultiCol(vcursor, bindVars) + return del.execDeleteEqualMultiCol(vcursor, bindVars, rss) default: - return del.execDeleteEqual(vcursor, bindVars) + return del.execDeleteEqual(vcursor, bindVars, rss) } case IN: - return del.execDeleteIn(vcursor, bindVars) + return del.execDeleteIn(vcursor, bindVars, rss) case Scatter: - return del.execDeleteByDestination(vcursor, bindVars, key.DestinationAllShards{}) + return del.execDeleteByDestination(vcursor, bindVars, rss) case ByDestination: - return del.execDeleteByDestination(vcursor, bindVars, del.TargetDestination) + return del.execDeleteByDestination(vcursor, bindVars, rss) default: // Unreachable. return nil, fmt.Errorf("unsupported opcode: %v", del) @@ -105,68 +113,32 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp return nil, fmt.Errorf("BUG: unreachable code for %q", del.Query) } -func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, _, err := del.findRoute(vcursor, bindVars) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err - } +func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { return execShard(vcursor, del.Query, bindVars, rss[0], true, true /* canAutocommit */) } -func (del *Delete) execDeleteEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - env := evalengine.EnvWithBindVars(bindVars) - key, err := env.Evaluate(del.Values[0]) - if err != nil { - return nil, err - } - rs, ksid, err := resolveSingleShard(vcursor, del.Vindex.(vindexes.SingleColumn), del.Keyspace, key.Value()) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rs) - if err != nil { - return nil, err - } - - if len(ksid) == 0 { +func (del *Delete) execDeleteEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + if len(rss) == 0 { return &sqltypes.Result{}, nil } + if len(rss) != 1 { + return nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) + } if del.OwnedVindexQuery != "" { - err = del.deleteVindexEntries(vcursor, bindVars, []*srvtopo.ResolvedShard{rs}) + err := del.deleteVindexEntries(vcursor, bindVars, rss) if err != nil { return nil, err } } - return execShard(vcursor, del.Query, bindVars, rs, true /* rollbackOnError */, true /* canAutocommit */) + return execShard(vcursor, del.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) } -func (del *Delete) execDeleteEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - env := evalengine.EnvWithBindVars(bindVars) - var rowValue []sqltypes.Value - for _, rvalue := range del.Values { - v, err := env.Evaluate(rvalue) - if err != nil { - return nil, err - } - rowValue = append(rowValue, v.Value()) - } - rss, _, err := resolveShardsMultiCol(vcursor, del.Vindex.(vindexes.MultiColumn), del.Keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) - if err != nil { - return nil, err - } +func (del *Delete) execDeleteEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { if len(rss) != 1 { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "vindex mapped id to multi shards: %d", len(rss)) } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err - } if del.OwnedVindexQuery != "" { - err = del.deleteVindexEntries(vcursor, bindVars, rss) + err := del.deleteVindexEntries(vcursor, bindVars, rss) if err != nil { return nil, err } @@ -174,34 +146,23 @@ func (del *Delete) execDeleteEqualMultiCol(vcursor VCursor, bindVars map[string] return execShard(vcursor, del.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) } -func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, queries, err := resolveMultiValueShards(vcursor, del.Keyspace, del.Query, bindVars, del.Values, del.Vindex) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err - } - +func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { if del.OwnedVindexQuery != "" { if err := del.deleteVindexEntries(vcursor, bindVars, rss); err != nil { return nil, err } } + queries := make([]*querypb.BoundQuery, len(rss)) + for i := range rss { + queries[i] = &querypb.BoundQuery{ + Sql: del.Query, + BindVariables: bindVars, + } + } return execMultiShard(vcursor, rss, queries, del.MultiShardAutocommit) } -func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - rss, _, err := del.findRoute(vcursor, bindVars) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err - } - +func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { queries := make([]*querypb.BoundQuery, len(rss)) for i := range rss { queries[i] = &querypb.BoundQuery{ @@ -210,7 +171,7 @@ func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string] } } if len(del.Table.Owned) > 0 { - err = del.deleteVindexEntries(vcursor, bindVars, rss) + err := del.deleteVindexEntries(vcursor, bindVars, rss) if err != nil { return nil, err } diff --git a/go/vt/vtgate/engine/delete_test.go b/go/vt/vtgate/engine/delete_test.go index 0eee9c828de..61c3eda4526 100644 --- a/go/vt/vtgate/engine/delete_test.go +++ b/go/vt/vtgate/engine/delete_test.go @@ -84,7 +84,7 @@ func TestDeleteEqual(t *testing.T) { _, err := del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations ks [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, `ExecuteMultiShard ks.-20: dummy_delete {} true true`, }) @@ -154,36 +154,10 @@ func TestDeleteEqualNoRoute(t *testing.T) { vc.ExpectLog(t, []string{ // This lookup query will return no rows. So, the DML will not be sent anywhere. `Execute select from, toc from lkp where from in ::from from: type:TUPLE values:{type:INT64 value:"1"} false`, + `ResolveDestinations ks [type:INT64 value:"1"] Destinations:DestinationNone()`, }) } -func TestDeleteEqualNoScatter(t *testing.T) { - vindex, _ := vindexes.NewLookupUnique("", map[string]string{ - "table": "lkp", - "from": "from", - "to": "toc", - "write_only": "true", - }) - del := &Delete{ - DML: &DML{ - RoutingParameters: &RoutingParameters{ - Opcode: Equal, - Keyspace: &vindexes.Keyspace{ - Name: "ks", - Sharded: true, - }, - Vindex: vindex, - Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, - }, - Query: "dummy_delete", - }, - } - - vc := newDMLTestVCursor("0") - _, err := del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) - require.EqualError(t, err, "cannot map vindex to unique keyspace id: DestinationKeyRange(-)") -} - func TestDeleteOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ @@ -216,7 +190,7 @@ func TestDeleteOwnedVindex(t *testing.T) { _, err := del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -232,7 +206,7 @@ func TestDeleteOwnedVindex(t *testing.T) { _, err = del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -255,7 +229,7 @@ func TestDeleteOwnedVindex(t *testing.T) { _, err = del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index 76fd577c2e9..cc082628dd8 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -150,9 +150,9 @@ func (rp *RoutingParameters) findRoute(vcursor VCursor, bindVars map[string]*que case MultiEqual: switch rp.Vindex.(type) { case vindexes.MultiColumn: - return rp.paramsSelectMultiEqualMultiCol(vcursor, bindVars) + return rp.multiEqualMultiCol(vcursor, bindVars) default: - return rp.paramsSelectMultiEqual(vcursor, bindVars) + return rp.multiEqual(vcursor, bindVars) } default: // Unreachable. @@ -387,7 +387,7 @@ func (rp *RoutingParameters) inMultiCol(vcursor VCursor, bindVars map[string]*qu return rss, shardVarsMultiCol(bindVars, mapVals, isSingleVal), nil } -func (rp *RoutingParameters) paramsSelectMultiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) multiEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { env := evalengine.EnvWithBindVars(bindVars) value, err := env.Evaluate(rp.Values[0]) if err != nil { @@ -404,7 +404,7 @@ func (rp *RoutingParameters) paramsSelectMultiEqual(vcursor VCursor, bindVars ma return rss, multiBindVars, nil } -func (rp *RoutingParameters) paramsSelectMultiEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { +func (rp *RoutingParameters) multiEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) { var multiColValues [][]sqltypes.Value env := evalengine.EnvWithBindVars(bindVars) for _, rvalue := range rp.Values { From d7d3bea90975e3082b8d66e3385cf9c0e809a4d4 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 21 Jan 2022 18:11:19 +0530 Subject: [PATCH 11/12] refactor: update primitive to use common routing Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/delete.go | 2 +- go/vt/vtgate/engine/delete_test.go | 30 ++++++- go/vt/vtgate/engine/dml.go | 80 ++----------------- go/vt/vtgate/engine/route.go | 122 +++++----------------------- go/vt/vtgate/engine/routing.go | 56 ++++++++++++- go/vt/vtgate/engine/update.go | 124 ++++++++++------------------- go/vt/vtgate/engine/update_test.go | 24 +++--- 7 files changed, 167 insertions(+), 271 deletions(-) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 11d5f949a7b..2848173e2c7 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -95,7 +95,7 @@ func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind return del.execDeleteByDestination(vcursor, bindVars, rss) default: // Unreachable. - return nil, fmt.Errorf("unsupported opcode: %v", del) + return nil, fmt.Errorf("unsupported opcode: %v", del.Opcode) } } diff --git a/go/vt/vtgate/engine/delete_test.go b/go/vt/vtgate/engine/delete_test.go index 61c3eda4526..1327dab2af2 100644 --- a/go/vt/vtgate/engine/delete_test.go +++ b/go/vt/vtgate/engine/delete_test.go @@ -60,7 +60,7 @@ func TestDeleteUnsharded(t *testing.T) { vc = &loggingVCursor{} _, err = del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) - require.EqualError(t, err, "cannot send query to multiple shards for un-sharded database: []") + require.EqualError(t, err, "Keyspace 'ks' does not have exactly one shard: []") } func TestDeleteEqual(t *testing.T) { @@ -158,6 +158,34 @@ func TestDeleteEqualNoRoute(t *testing.T) { }) } +func TestDeleteEqualNoScatter(t *testing.T) { + t.Skip("planner does not produces this plan anymore") + vindex, _ := vindexes.NewLookupUnique("", map[string]string{ + "table": "lkp", + "from": "from", + "to": "toc", + "write_only": "true", + }) + del := &Delete{ + DML: &DML{ + RoutingParameters: &RoutingParameters{ + Opcode: Equal, + Keyspace: &vindexes.Keyspace{ + Name: "ks", + Sharded: true, + }, + Vindex: vindex, + Values: []evalengine.Expr{evalengine.NewLiteralInt(1)}, + }, + Query: "dummy_delete", + }, + } + + vc := newDMLTestVCursor("0") + _, err := del.TryExecute(vc, map[string]*querypb.BindVariable{}, false) + require.EqualError(t, err, "cannot map vindex to unique keyspace id: DestinationKeyRange(-)") +} + func TestDeleteOwnedVindex(t *testing.T) { ks := buildTestVSchema().Keyspaces["sharded"] del := &Delete{ diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index cf4bb69edd5..7187dc4b6c5 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -27,7 +27,6 @@ import ( "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vterrors" - "vitess.io/vitess/go/vt/vtgate/evalengine" "vitess.io/vitess/go/vt/vtgate/vindexes" ) @@ -66,73 +65,13 @@ func NewDML() *DML { return &DML{RoutingParameters: &RoutingParameters{}} } -func resolveMultiValueShards( - vcursor VCursor, - keyspace *vindexes.Keyspace, - query string, - bindVars map[string]*querypb.BindVariable, - values []evalengine.Expr, - vindex vindexes.Vindex, -) ([]*srvtopo.ResolvedShard, []*querypb.BoundQuery, error) { - var rss []*srvtopo.ResolvedShard - var err error - switch vindex.(type) { - case vindexes.SingleColumn: - rss, err = resolveSingleColVindex(vcursor, bindVars, keyspace, vindex, values) - case vindexes.MultiColumn: - rss, err = resolveMultiColVindex(vcursor, bindVars, keyspace, vindex, values) - default: - return nil, nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] unexpected vindex type: %T", vindex) - } - if err != nil { - return nil, nil, err - } - queries := make([]*querypb.BoundQuery, len(rss)) - for i := range rss { - queries[i] = &querypb.BoundQuery{ - Sql: query, - BindVariables: bindVars, +func allowOnlyPrimary(rss ...*srvtopo.ResolvedShard) error { + for _, rs := range rss { + if rs != nil && rs.Target.TabletType != topodatapb.TabletType_PRIMARY { + return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "supported only for primary tablet type, current type: %v", topoproto.TabletTypeLString(rs.Target.TabletType)) } } - return rss, queries, nil -} - -func resolveSingleColVindex(vcursor VCursor, bindVars map[string]*querypb.BindVariable, keyspace *vindexes.Keyspace, vindex vindexes.Vindex, values []evalengine.Expr) ([]*srvtopo.ResolvedShard, error) { - env := evalengine.EnvWithBindVars(bindVars) - keys, err := env.Evaluate(values[0]) - if err != nil { - return nil, err - } - rss, err := resolveMultiShard(vcursor, vindex.(vindexes.SingleColumn), keyspace, keys.TupleValues()) - if err != nil { - return nil, err - } - return rss, nil -} - -func resolveMultiColVindex(vcursor VCursor, bindVars map[string]*querypb.BindVariable, keyspace *vindexes.Keyspace, vindex vindexes.Vindex, values []evalengine.Expr) ([]*srvtopo.ResolvedShard, error) { - rowColValues, _, err := generateRowColValues(bindVars, values) - if err != nil { - return nil, err - } - - rss, _, err := resolveShardsMultiCol(vcursor, vindex.(vindexes.MultiColumn), keyspace, rowColValues, false /* shardIdsNeeded */) - if err != nil { - return nil, err - } - return rss, nil -} - -func resolveMultiShard(vcursor VCursor, vindex vindexes.SingleColumn, keyspace *vindexes.Keyspace, vindexKey []sqltypes.Value) ([]*srvtopo.ResolvedShard, error) { - destinations, err := vindex.Map(vcursor, vindexKey) - if err != nil { - return nil, err - } - rss, _, err := vcursor.ResolveDestinations(keyspace.Name, nil, destinations) - if err != nil { - return nil, err - } - return rss, nil + return nil } func execMultiShard(vcursor VCursor, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, multiShardAutoCommit bool) (*sqltypes.Result, error) { @@ -141,15 +80,6 @@ func execMultiShard(vcursor VCursor, rss []*srvtopo.ResolvedShard, queries []*qu return result, vterrors.Aggregate(errs) } -func allowOnlyPrimary(rss ...*srvtopo.ResolvedShard) error { - for _, rs := range rss { - if rs != nil && rs.Target.TabletType != topodatapb.TabletType_PRIMARY { - return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "supported only for primary tablet type, current type: %v", topoproto.TabletTypeLString(rs.Target.TabletType)) - } - } - return nil -} - func resolveKeyspaceID(vcursor VCursor, vindex vindexes.Vindex, vindexKey []sqltypes.Value) ([]byte, error) { var destinations []key.Destination var err error diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index dea63f02531..3eb8bb27529 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -305,60 +305,6 @@ func (route *Route) GetFields(vcursor VCursor, bindVars map[string]*querypb.Bind return qr.Truncate(route.TruncateColumnCount), nil } -func generateRowColValues(bindVars map[string]*querypb.BindVariable, values []evalengine.Expr) ([][]sqltypes.Value, map[int]interface{}, error) { - // gather values from all the column in the vindex - var multiColValues [][]sqltypes.Value - var lv []sqltypes.Value - isSingleVal := map[int]interface{}{} - env := evalengine.EnvWithBindVars(bindVars) - for colIdx, rvalue := range values { - result, err := env.Evaluate(rvalue) - if err != nil { - return nil, nil, err - } - lv = result.TupleValues() - if lv == nil { - v, err := env.Evaluate(rvalue) - if err != nil { - return nil, nil, err - } - isSingleVal[colIdx] = nil - lv = []sqltypes.Value{v.Value()} - } - multiColValues = append(multiColValues, lv) - } - - /* - need to convert them into vindex keys - from: cola (1,2) colb (3,4,5) - to: keys (1,3) (1,4) (1,5) (2,3) (2,4) (2,5) - - so that the vindex can map them into correct destination. - */ - - var rowColValues [][]sqltypes.Value - for _, firstCol := range multiColValues[0] { - rowColValues = append(rowColValues, []sqltypes.Value{firstCol}) - } - for idx := 1; idx < len(multiColValues); idx++ { - rowColValues = buildRowColValues(rowColValues, multiColValues[idx]) - } - return rowColValues, isSingleVal, nil -} - -// buildRowColValues will take [1,2][1,3] as left input and [4,5] as right input -// convert it into [1,2,4][1,2,5][1,3,4][1,3,5] -// all combination of left and right side. -func buildRowColValues(left [][]sqltypes.Value, right []sqltypes.Value) [][]sqltypes.Value { - var allCombinations [][]sqltypes.Value - for _, firstPart := range left { - for _, secondPart := range right { - allCombinations = append(allCombinations, append(firstPart, secondPart)) - } - } - return allCombinations -} - func (route *Route) sort(in *sqltypes.Result) (*sqltypes.Result, error) { var err error // Since Result is immutable, we make a copy. @@ -399,52 +345,6 @@ func (route *Route) sort(in *sqltypes.Result) (*sqltypes.Result, error) { return out, err } -func resolveSingleShard(vcursor VCursor, vindex vindexes.SingleColumn, keyspace *vindexes.Keyspace, vindexKey sqltypes.Value) (*srvtopo.ResolvedShard, []byte, error) { - destinations, err := vindex.Map(vcursor, []sqltypes.Value{vindexKey}) - if err != nil { - return nil, nil, err - } - var ksid []byte - switch d := destinations[0].(type) { - case key.DestinationKeyspaceID: - ksid = d - case key.DestinationNone: - return nil, nil, nil - default: - return nil, nil, fmt.Errorf("cannot map vindex to unique keyspace id: %v", destinations[0]) - } - rss, _, err := vcursor.ResolveDestinations(keyspace.Name, nil, destinations) - if err != nil { - return nil, nil, err - } - if len(rss) != 1 { - return nil, nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) - } - return rss[0], ksid, nil -} - -func execShard(vcursor VCursor, query string, bindVars map[string]*querypb.BindVariable, rs *srvtopo.ResolvedShard, rollbackOnError, canAutocommit bool) (*sqltypes.Result, error) { - autocommit := canAutocommit && vcursor.AutocommitApproval() - result, errs := vcursor.ExecuteMultiShard([]*srvtopo.ResolvedShard{rs}, []*querypb.BoundQuery{ - { - Sql: query, - BindVariables: bindVars, - }, - }, rollbackOnError, autocommit) - return result, vterrors.Aggregate(errs) -} - -func getQueries(query string, bvs []map[string]*querypb.BindVariable) []*querypb.BoundQuery { - queries := make([]*querypb.BoundQuery, len(bvs)) - for i, bv := range bvs { - queries[i] = &querypb.BoundQuery{ - Sql: query, - BindVariables: bv, - } - } - return queries -} - func (route *Route) description() PrimitiveDescription { other := map[string]interface{}{ "Query": route.Query, @@ -502,6 +402,28 @@ func (route *Route) description() PrimitiveDescription { } } +func execShard(vcursor VCursor, query string, bindVars map[string]*querypb.BindVariable, rs *srvtopo.ResolvedShard, rollbackOnError, canAutocommit bool) (*sqltypes.Result, error) { + autocommit := canAutocommit && vcursor.AutocommitApproval() + result, errs := vcursor.ExecuteMultiShard([]*srvtopo.ResolvedShard{rs}, []*querypb.BoundQuery{ + { + Sql: query, + BindVariables: bindVars, + }, + }, rollbackOnError, autocommit) + return result, vterrors.Aggregate(errs) +} + +func getQueries(query string, bvs []map[string]*querypb.BindVariable) []*querypb.BoundQuery { + queries := make([]*querypb.BoundQuery, len(bvs)) + for i, bv := range bvs { + queries[i] = &querypb.BoundQuery{ + Sql: query, + BindVariables: bv, + } + } + return queries +} + func orderByToString(in interface{}) string { return in.(OrderByParams).String() } diff --git a/go/vt/vtgate/engine/routing.go b/go/vt/vtgate/engine/routing.go index cc082628dd8..fa236abf1bc 100644 --- a/go/vt/vtgate/engine/routing.go +++ b/go/vt/vtgate/engine/routing.go @@ -301,7 +301,7 @@ func (rp *RoutingParameters) unsharded(vcursor VCursor, bindVars map[string]*que return nil, nil, err } if len(rss) != 1 { - return nil, nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot send query to multiple shards for un-sharded database: %v", rss) + return nil, nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "Keyspace '%s' does not have exactly one shard: %v", rp.Keyspace.Name, rss) } multiBindVars := make([]map[string]*querypb.BindVariable, len(rss)) for i := range multiBindVars { @@ -548,3 +548,57 @@ func shardVarsMultiCol(bv map[string]*querypb.BindVariable, mapVals [][][]*query } return shardVars } + +func generateRowColValues(bindVars map[string]*querypb.BindVariable, values []evalengine.Expr) ([][]sqltypes.Value, map[int]interface{}, error) { + // gather values from all the column in the vindex + var multiColValues [][]sqltypes.Value + var lv []sqltypes.Value + isSingleVal := map[int]interface{}{} + env := evalengine.EnvWithBindVars(bindVars) + for colIdx, rvalue := range values { + result, err := env.Evaluate(rvalue) + if err != nil { + return nil, nil, err + } + lv = result.TupleValues() + if lv == nil { + v, err := env.Evaluate(rvalue) + if err != nil { + return nil, nil, err + } + isSingleVal[colIdx] = nil + lv = []sqltypes.Value{v.Value()} + } + multiColValues = append(multiColValues, lv) + } + + /* + need to convert them into vindex keys + from: cola (1,2) colb (3,4,5) + to: keys (1,3) (1,4) (1,5) (2,3) (2,4) (2,5) + + so that the vindex can map them into correct destination. + */ + + var rowColValues [][]sqltypes.Value + for _, firstCol := range multiColValues[0] { + rowColValues = append(rowColValues, []sqltypes.Value{firstCol}) + } + for idx := 1; idx < len(multiColValues); idx++ { + rowColValues = buildRowColValues(rowColValues, multiColValues[idx]) + } + return rowColValues, isSingleVal, nil +} + +// buildRowColValues will take [1,2][1,3] as left input and [4,5] as right input +// convert it into [1,2,4][1,2,5][1,3,4][1,3,5] +// all combination of left and right side. +func buildRowColValues(left [][]sqltypes.Value, right []sqltypes.Value) [][]sqltypes.Value { + var allCombinations [][]sqltypes.Value + for _, firstPart := range left { + for _, secondPart := range right { + allCombinations = append(allCombinations, append(firstPart, secondPart)) + } + } + return allCombinations +} diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index b6936ba43a7..fbe40219481 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -26,7 +26,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" @@ -79,25 +78,34 @@ func (upd *Update) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind defer cancel() } + rss, _, err := upd.findRoute(vcursor, bindVars) + if err != nil { + return nil, err + } + err = allowOnlyPrimary(rss...) + if err != nil { + return nil, err + } + switch upd.Opcode { case Unsharded: - return upd.execUpdateUnsharded(vcursor, bindVars) + return upd.execUpdateUnsharded(vcursor, bindVars, rss) case Equal: switch upd.Vindex.(type) { case vindexes.MultiColumn: - return upd.execUpdateEqualMultiCol(vcursor, bindVars) + return upd.execUpdateEqualMultiCol(vcursor, bindVars, rss) default: - return upd.execUpdateEqual(vcursor, bindVars) + return upd.execUpdateEqual(vcursor, bindVars, rss) } case IN: - return upd.execUpdateIn(vcursor, bindVars) + return upd.execUpdateIn(vcursor, bindVars, rss) case Scatter: - return upd.execUpdateByDestination(vcursor, bindVars, key.DestinationAllShards{}) + return upd.execUpdateByDestination(vcursor, bindVars, rss) case ByDestination: - return upd.execUpdateByDestination(vcursor, bindVars, upd.TargetDestination) + return upd.execUpdateByDestination(vcursor, bindVars, rss) default: // Unreachable. - return nil, fmt.Errorf("unsupported opcode: %v", upd) + return nil, fmt.Errorf("unsupported opcode: %v", upd.Opcode) } } @@ -116,73 +124,43 @@ func (upd *Update) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindV return nil, fmt.Errorf("BUG: unreachable code for %q", upd.Query) } -func (upd *Update) execUpdateUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, _, err := vcursor.ResolveDestinations(upd.Keyspace.Name, nil, []key.Destination{key.DestinationAllShards{}}) - if err != nil { - return nil, err - } - if len(rss) != 1 { - return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "Keyspace does not have exactly one shard: %v", rss) - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err - } +func (upd *Update) execUpdateUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { return execShard(vcursor, upd.Query, bindVars, rss[0], true, true /* canAutocommit */) } -func (upd *Update) execUpdateEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - env := evalengine.EnvWithBindVars(bindVars) - key, err := env.Evaluate(upd.Values[0]) - if err != nil { - return nil, err - } - rs, ksid, err := resolveSingleShard(vcursor, upd.Vindex.(vindexes.SingleColumn), upd.Keyspace, key.Value()) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rs) - if err != nil { - return nil, err - } - if len(ksid) == 0 { +func (upd *Update) execUpdateEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + if len(rss) == 0 { return &sqltypes.Result{}, nil } + if len(rss) != 1 { + return nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) + } if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, []*srvtopo.ResolvedShard{rs}); err != nil { + if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { return nil, err } } - return execShard(vcursor, upd.Query, bindVars, rs, true /* rollbackOnError */, true /* canAutocommit */) + return execShard(vcursor, upd.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) } -func (upd *Update) execUpdateIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - rss, queries, err := resolveMultiValueShards(vcursor, upd.Keyspace, upd.Query, bindVars, upd.Values, upd.Vindex) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err +func (upd *Update) execUpdateEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + if len(rss) != 1 { + return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "vindex mapped id to multi shards: %d", len(rss)) } if len(upd.ChangedVindexValues) != 0 { if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { return nil, err } } - return execMultiShard(vcursor, rss, queries, upd.MultiShardAutocommit) + return execShard(vcursor, upd.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) } -func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, dest key.Destination) (*sqltypes.Result, error) { - rss, _, err := vcursor.ResolveDestinations(upd.Keyspace.Name, nil, []key.Destination{dest}) - if err != nil { - return nil, err - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err +func (upd *Update) execUpdateIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + if len(upd.ChangedVindexValues) != 0 { + if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { + return nil, err + } } - queries := make([]*querypb.BoundQuery, len(rss)) for i := range rss { queries[i] = &querypb.BoundQuery{ @@ -190,43 +168,25 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] BindVariables: bindVars, } } - - // update any owned vindexes - if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } return execMultiShard(vcursor, rss, queries, upd.MultiShardAutocommit) } -func (upd *Update) execUpdateEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { - env := evalengine.EnvWithBindVars(bindVars) - var rowValue []sqltypes.Value - for _, rvalue := range upd.Values { - v, err := env.Evaluate(rvalue) - if err != nil { - return nil, err +func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + queries := make([]*querypb.BoundQuery, len(rss)) + for i := range rss { + queries[i] = &querypb.BoundQuery{ + Sql: upd.Query, + BindVariables: bindVars, } - rowValue = append(rowValue, v.Value()) - } - rss, _, err := resolveShardsMultiCol(vcursor, upd.Vindex.(vindexes.MultiColumn), upd.Keyspace, [][]sqltypes.Value{rowValue}, false /* shardIdsNeeded */) - if err != nil { - return nil, err - } - if len(rss) != 1 { - return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "vindex mapped id to multi shards: %d", len(rss)) - } - err = allowOnlyPrimary(rss...) - if err != nil { - return nil, err } + + // update any owned vindexes if len(upd.ChangedVindexValues) != 0 { if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { return nil, err } } - return execShard(vcursor, upd.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) + return execMultiShard(vcursor, rss, queries, upd.MultiShardAutocommit) } // updateVindexEntries performs an update when a vindex is being modified diff --git a/go/vt/vtgate/engine/update_test.go b/go/vt/vtgate/engine/update_test.go index 815fdcca84d..9ba088d649a 100644 --- a/go/vt/vtgate/engine/update_test.go +++ b/go/vt/vtgate/engine/update_test.go @@ -64,7 +64,7 @@ func TestUpdateUnsharded(t *testing.T) { vc = &loggingVCursor{} _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) - require.EqualError(t, err, `Keyspace does not have exactly one shard: []`) + require.EqualError(t, err, `Keyspace 'ks' does not have exactly one shard: []`) } func TestUpdateEqual(t *testing.T) { @@ -88,7 +88,7 @@ func TestUpdateEqual(t *testing.T) { _, err := upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations ks [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations ks [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, `ExecuteMultiShard ks.-20: dummy_update {} true true`, }) @@ -204,10 +204,12 @@ func TestUpdateEqualNoRoute(t *testing.T) { vc.ExpectLog(t, []string{ // This lookup query will return no rows. So, the DML will not be sent anywhere. `Execute select from, toc from lkp where from in ::from from: type:TUPLE values:{type:INT64 value:"1"} false`, + `ResolveDestinations ks [type:INT64 value:"1"] Destinations:DestinationNone()`, }) } func TestUpdateEqualNoScatter(t *testing.T) { + t.Skip("planner does not produces this plan anymore") vindex, _ := vindexes.NewLookupUnique("", map[string]string{ "table": "lkp", "from": "from", @@ -280,7 +282,7 @@ func TestUpdateEqualChangedVindex(t *testing.T) { _, err := upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -301,7 +303,7 @@ func TestUpdateEqualChangedVindex(t *testing.T) { _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -324,7 +326,7 @@ func TestUpdateEqualChangedVindex(t *testing.T) { _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -360,7 +362,7 @@ func TestUpdateEqualChangedVindex(t *testing.T) { _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, + `ResolveDestinations sharded [type:INT64 value:"1"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -630,7 +632,7 @@ func TestUpdateIn(t *testing.T) { _, err := upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, + `ResolveDestinations sharded [type:INT64 value:"1" type:INT64 value:"2"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, // ResolveDestinations is hard-coded to return -20. `ExecuteMultiShard sharded.-20: dummy_update {} true true`, }) @@ -656,7 +658,7 @@ func TestUpdateInStreamExecute(t *testing.T) { }) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, + `ResolveDestinations sharded [type:INT64 value:"1" type:INT64 value:"2"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, // ResolveDestinations is hard-coded to return -20. `ExecuteMultiShard sharded.-20: dummy_update {} true true`, }) @@ -737,7 +739,7 @@ func TestUpdateInChangedVindex(t *testing.T) { _, err := upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, + `ResolveDestinations sharded [type:INT64 value:"1" type:INT64 value:"2"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -764,7 +766,7 @@ func TestUpdateInChangedVindex(t *testing.T) { _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, + `ResolveDestinations sharded [type:INT64 value:"1" type:INT64 value:"2"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, @@ -788,7 +790,7 @@ func TestUpdateInChangedVindex(t *testing.T) { _, err = upd.TryExecute(vc, map[string]*querypb.BindVariable{}, false) require.NoError(t, err) vc.ExpectLog(t, []string{ - `ResolveDestinations sharded [] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, + `ResolveDestinations sharded [type:INT64 value:"1" type:INT64 value:"2"] Destinations:DestinationKeyspaceID(166b40b44aba4bd6),DestinationKeyspaceID(06e7ea22ce92708f)`, // ResolveDestinations is hard-coded to return -20. // It gets used to perform the subquery to fetch the changing column values. `ExecuteMultiShard sharded.-20: dummy_subquery {} false false`, From d52155ea7ae87fb847bfe749851492396f2909be Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 21 Jan 2022 21:18:30 +0530 Subject: [PATCH 12/12] refactor: pulled update and delete exec logic into common dml Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/cached_size.go | 91 ++++++++++++++---------------- go/vt/vtgate/engine/delete.go | 88 +++-------------------------- go/vt/vtgate/engine/dml.go | 40 ++++++++++++- go/vt/vtgate/engine/update.go | 87 +++------------------------- 4 files changed, 94 insertions(+), 212 deletions(-) diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 3c1bc48b83d..e7dc63331b2 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -118,29 +118,10 @@ func (cached *DML) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(160) - } - // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace - size += cached.Keyspace.CachedSize(true) - // field TargetDestination vitess.io/vitess/go/vt/key.Destination - if cc, ok := cached.TargetDestination.(cachedObject); ok { - size += cc.CachedSize(true) + size += int64(96) } // field Query string size += hack.RuntimeAllocSize(int64(len(cached.Query))) - // field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.Vindex - if cc, ok := cached.Vindex.(cachedObject); ok { - size += cc.CachedSize(true) - } - // field Values []vitess.io/vitess/go/vt/vtgate/evalengine.Expr - { - size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(16)) - for _, elem := range cached.Values { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } // field KsidVindex vitess.io/vitess/go/vt/vtgate/vindexes.Vindex if cc, ok := cached.KsidVindex.(cachedObject); ok { size += cc.CachedSize(true) @@ -149,6 +130,8 @@ func (cached *DML) CachedSize(alloc bool) int64 { size += cached.Table.CachedSize(true) // field OwnedVindexQuery string size += hack.RuntimeAllocSize(int64(len(cached.OwnedVindexQuery))) + // field RoutingParameters *vitess.io/vitess/go/vt/vtgate/engine.RoutingParameters + size += cached.RoutingParameters.CachedSize(true) return size } func (cached *Delete) CachedSize(alloc bool) int64 { @@ -157,10 +140,10 @@ func (cached *Delete) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(160) + size += int64(8) } - // field DML vitess.io/vitess/go/vt/vtgate/engine.DML - size += cached.DML.CachedSize(false) + // field DML *vitess.io/vitess/go/vt/vtgate/engine.DML + size += cached.DML.CachedSize(true) return size } func (cached *Distinct) CachedSize(alloc bool) int64 { @@ -665,21 +648,13 @@ func (cached *RevertMigration) CachedSize(alloc bool) int64 { } return size } - -//go:nocheckptr func (cached *Route) CachedSize(alloc bool) int64 { if cached == nil { return int64(0) } size := int64(0) if alloc { - size += int64(208) - } - // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace - size += cached.Keyspace.CachedSize(true) - // field TargetDestination vitess.io/vitess/go/vt/key.Destination - if cc, ok := cached.TargetDestination.(cachedObject); ok { - size += cc.CachedSize(true) + size += int64(112) } // field Query string size += hack.RuntimeAllocSize(int64(len(cached.Query))) @@ -687,23 +662,26 @@ func (cached *Route) CachedSize(alloc bool) int64 { size += hack.RuntimeAllocSize(int64(len(cached.TableName))) // field FieldQuery string size += hack.RuntimeAllocSize(int64(len(cached.FieldQuery))) - // field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.Vindex - if cc, ok := cached.Vindex.(cachedObject); ok { - size += cc.CachedSize(true) - } - // field Values []vitess.io/vitess/go/vt/vtgate/evalengine.Expr - { - size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(16)) - for _, elem := range cached.Values { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } // field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams { size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(36)) } + // field RoutingParameters *vitess.io/vitess/go/vt/vtgate/engine.RoutingParameters + size += cached.RoutingParameters.CachedSize(true) + return size +} + +//go:nocheckptr +func (cached *RoutingParameters) CachedSize(alloc bool) int64 { + if cached == nil { + return int64(0) + } + size := int64(0) + if alloc { + size += int64(112) + } + // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace + size += cached.Keyspace.CachedSize(true) // field SysTableTableSchema []vitess.io/vitess/go/vt/vtgate/evalengine.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.SysTableTableSchema)) * int64(16)) @@ -730,6 +708,23 @@ func (cached *Route) CachedSize(alloc bool) int64 { } } } + // field TargetDestination vitess.io/vitess/go/vt/key.Destination + if cc, ok := cached.TargetDestination.(cachedObject); ok { + size += cc.CachedSize(true) + } + // field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.Vindex + if cc, ok := cached.Vindex.(cachedObject); ok { + size += cc.CachedSize(true) + } + // field Values []vitess.io/vitess/go/vt/vtgate/evalengine.Expr + { + size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(16)) + for _, elem := range cached.Values { + if cc, ok := elem.(cachedObject); ok { + size += cc.CachedSize(true) + } + } + } return size } func (cached *Rows) CachedSize(alloc bool) int64 { @@ -966,10 +961,10 @@ func (cached *Update) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(160) + size += int64(16) } - // field DML vitess.io/vitess/go/vt/vtgate/engine.DML - size += cached.DML.CachedSize(false) + // field DML *vitess.io/vitess/go/vt/vtgate/engine.DML + size += cached.DML.CachedSize(true) // field ChangedVindexValues map[string]*vitess.io/vitess/go/vt/vtgate/engine.VindexValues if cached.ChangedVindexValues != nil { size += int64(48) diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index 2848173e2c7..fb395788aa0 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -26,11 +26,9 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/srvtopo" - "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" querypb "vitess.io/vitess/go/vt/proto/query" - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" ) var _ Primitive = (*Delete)(nil) @@ -79,20 +77,11 @@ func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind switch del.Opcode { case Unsharded: - return del.execDeleteUnsharded(vcursor, bindVars, rss) + return del.execUnsharded(vcursor, bindVars, rss) case Equal: - switch del.Vindex.(type) { - case vindexes.MultiColumn: - return del.execDeleteEqualMultiCol(vcursor, bindVars, rss) - default: - return del.execDeleteEqual(vcursor, bindVars, rss) - } - case IN: - return del.execDeleteIn(vcursor, bindVars, rss) - case Scatter: - return del.execDeleteByDestination(vcursor, bindVars, rss) - case ByDestination: - return del.execDeleteByDestination(vcursor, bindVars, rss) + return del.execEqual(vcursor, bindVars, rss, del.deleteVindexEntries) + case IN, Scatter, ByDestination: + return del.execMultiDestination(vcursor, bindVars, rss, del.deleteVindexEntries) default: // Unreachable. return nil, fmt.Errorf("unsupported opcode: %v", del.Opcode) @@ -113,76 +102,13 @@ func (del *Delete) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltyp return nil, fmt.Errorf("BUG: unreachable code for %q", del.Query) } -func (del *Delete) execDeleteUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - return execShard(vcursor, del.Query, bindVars, rss[0], true, true /* canAutocommit */) -} - -func (del *Delete) execDeleteEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if len(rss) == 0 { - return &sqltypes.Result{}, nil - } - if len(rss) != 1 { - return nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) - } - if del.OwnedVindexQuery != "" { - err := del.deleteVindexEntries(vcursor, bindVars, rss) - if err != nil { - return nil, err - } - } - return execShard(vcursor, del.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) -} - -func (del *Delete) execDeleteEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if len(rss) != 1 { - return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "vindex mapped id to multi shards: %d", len(rss)) - } - if del.OwnedVindexQuery != "" { - err := del.deleteVindexEntries(vcursor, bindVars, rss) - if err != nil { - return nil, err - } - } - return execShard(vcursor, del.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) -} - -func (del *Delete) execDeleteIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if del.OwnedVindexQuery != "" { - if err := del.deleteVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } - queries := make([]*querypb.BoundQuery, len(rss)) - for i := range rss { - queries[i] = &querypb.BoundQuery{ - Sql: del.Query, - BindVariables: bindVars, - } - } - return execMultiShard(vcursor, rss, queries, del.MultiShardAutocommit) -} - -func (del *Delete) execDeleteByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - queries := make([]*querypb.BoundQuery, len(rss)) - for i := range rss { - queries[i] = &querypb.BoundQuery{ - Sql: del.Query, - BindVariables: bindVars, - } - } - if len(del.Table.Owned) > 0 { - err := del.deleteVindexEntries(vcursor, bindVars, rss) - if err != nil { - return nil, err - } - } - return execMultiShard(vcursor, rss, queries, del.MultiShardAutocommit) -} - // deleteVindexEntries performs an delete if table owns vindex. // Note: the commit order may be different from the DML order because it's possible // for DMLs to reuse existing transactions. func (del *Delete) deleteVindexEntries(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) error { + if del.OwnedVindexQuery == "" { + return nil + } queries := make([]*querypb.BoundQuery, len(rss)) for i := range rss { queries[i] = &querypb.BoundQuery{Sql: del.OwnedVindexQuery, BindVariables: bindVars} diff --git a/go/vt/vtgate/engine/dml.go b/go/vt/vtgate/engine/dml.go index 7187dc4b6c5..fe353ccdc47 100644 --- a/go/vt/vtgate/engine/dml.go +++ b/go/vt/vtgate/engine/dml.go @@ -21,13 +21,14 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/key" - querypb "vitess.io/vitess/go/vt/proto/query" - topodatapb "vitess.io/vitess/go/vt/proto/topodata" - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" + + querypb "vitess.io/vitess/go/vt/proto/query" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" ) // DML contains the common elements between Update and Delete plans @@ -65,6 +66,39 @@ func NewDML() *DML { return &DML{RoutingParameters: &RoutingParameters{}} } +func (dml *DML) execUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { + return execShard(vcursor, dml.Query, bindVars, rss[0], true, true /* canAutocommit */) +} + +func (dml *DML) execEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard, dmlSpecialFunc func(VCursor, map[string]*querypb.BindVariable, []*srvtopo.ResolvedShard) error) (*sqltypes.Result, error) { + if len(rss) == 0 { + return &sqltypes.Result{}, nil + } + if len(rss) != 1 { + return nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) + } + err := dmlSpecialFunc(vcursor, bindVars, rss) + if err != nil { + return nil, err + } + return execShard(vcursor, dml.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) +} + +func (dml *DML) execMultiDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard, dmlSpecialFunc func(VCursor, map[string]*querypb.BindVariable, []*srvtopo.ResolvedShard) error) (*sqltypes.Result, error) { + err := dmlSpecialFunc(vcursor, bindVars, rss) + if err != nil { + return nil, err + } + queries := make([]*querypb.BoundQuery, len(rss)) + for i := range rss { + queries[i] = &querypb.BoundQuery{ + Sql: dml.Query, + BindVariables: bindVars, + } + } + return execMultiShard(vcursor, rss, queries, dml.MultiShardAutocommit) +} + func allowOnlyPrimary(rss ...*srvtopo.ResolvedShard) error { for _, rs := range rss { if rs != nil && rs.Target.TabletType != topodatapb.TabletType_PRIMARY { diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index fbe40219481..dbb7a1829b9 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -27,11 +27,9 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/srvtopo" - "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" querypb "vitess.io/vitess/go/vt/proto/query" - vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" ) var _ Primitive = (*Update)(nil) @@ -89,20 +87,11 @@ func (upd *Update) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind switch upd.Opcode { case Unsharded: - return upd.execUpdateUnsharded(vcursor, bindVars, rss) + return upd.execUnsharded(vcursor, bindVars, rss) case Equal: - switch upd.Vindex.(type) { - case vindexes.MultiColumn: - return upd.execUpdateEqualMultiCol(vcursor, bindVars, rss) - default: - return upd.execUpdateEqual(vcursor, bindVars, rss) - } - case IN: - return upd.execUpdateIn(vcursor, bindVars, rss) - case Scatter: - return upd.execUpdateByDestination(vcursor, bindVars, rss) - case ByDestination: - return upd.execUpdateByDestination(vcursor, bindVars, rss) + return upd.execEqual(vcursor, bindVars, rss, upd.updateVindexEntries) + case IN, Scatter, ByDestination: + return upd.execMultiDestination(vcursor, bindVars, rss, upd.updateVindexEntries) default: // Unreachable. return nil, fmt.Errorf("unsupported opcode: %v", upd.Opcode) @@ -124,71 +113,6 @@ func (upd *Update) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindV return nil, fmt.Errorf("BUG: unreachable code for %q", upd.Query) } -func (upd *Update) execUpdateUnsharded(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - return execShard(vcursor, upd.Query, bindVars, rss[0], true, true /* canAutocommit */) -} - -func (upd *Update) execUpdateEqual(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if len(rss) == 0 { - return &sqltypes.Result{}, nil - } - if len(rss) != 1 { - return nil, fmt.Errorf("ResolveDestinations maps to %v shards", len(rss)) - } - if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } - return execShard(vcursor, upd.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) -} - -func (upd *Update) execUpdateEqualMultiCol(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if len(rss) != 1 { - return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "vindex mapped id to multi shards: %d", len(rss)) - } - if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } - return execShard(vcursor, upd.Query, bindVars, rss[0], true /* rollbackOnError */, true /* canAutocommit */) -} - -func (upd *Update) execUpdateIn(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } - queries := make([]*querypb.BoundQuery, len(rss)) - for i := range rss { - queries[i] = &querypb.BoundQuery{ - Sql: upd.Query, - BindVariables: bindVars, - } - } - return execMultiShard(vcursor, rss, queries, upd.MultiShardAutocommit) -} - -func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) (*sqltypes.Result, error) { - queries := make([]*querypb.BoundQuery, len(rss)) - for i := range rss { - queries[i] = &querypb.BoundQuery{ - Sql: upd.Query, - BindVariables: bindVars, - } - } - - // update any owned vindexes - if len(upd.ChangedVindexValues) != 0 { - if err := upd.updateVindexEntries(vcursor, bindVars, rss); err != nil { - return nil, err - } - } - return execMultiShard(vcursor, rss, queries, upd.MultiShardAutocommit) -} - // updateVindexEntries performs an update when a vindex is being modified // by the statement. // Note: the commit order may be different from the DML order because it's possible @@ -196,6 +120,9 @@ func (upd *Update) execUpdateByDestination(vcursor VCursor, bindVars map[string] // Note 2: While changes are being committed, the changing row could be // unreachable by either the new or old column values. func (upd *Update) updateVindexEntries(vcursor VCursor, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard) error { + if len(upd.ChangedVindexValues) == 0 { + return nil + } queries := make([]*querypb.BoundQuery, len(rss)) for i := range rss { queries[i] = &querypb.BoundQuery{Sql: upd.OwnedVindexQuery, BindVariables: bindVars}