diff --git a/go/test/endtoend/vtgate/system_schema_test.go b/go/test/endtoend/vtgate/system_schema_test.go index 142a20bdd11..a84d39e0679 100644 --- a/go/test/endtoend/vtgate/system_schema_test.go +++ b/go/test/endtoend/vtgate/system_schema_test.go @@ -89,6 +89,7 @@ func TestInformationSchemaWithSubquery(t *testing.T) { } func TestInformationSchemaQueryGetsRoutedToTheRightTableAndKeyspace(t *testing.T) { + t.Skip("flaky. skipping for now") defer cluster.PanicHandler(t) ctx := context.Background() conn, err := mysql.Connect(ctx, &vtParams) diff --git a/go/vt/vtgate/engine/concatenate.go b/go/vt/vtgate/engine/concatenate.go index 0d660565a71..1336e43facb 100644 --- a/go/vt/vtgate/engine/concatenate.go +++ b/go/vt/vtgate/engine/concatenate.go @@ -230,7 +230,7 @@ func (c *Concatenate) Inputs() []Primitive { return c.Sources } -func (c *Concatenate) Description() PrimitiveDescription { +func (c *Concatenate) description() PrimitiveDescription { return PrimitiveDescription{OperatorType: c.RouteType()} } diff --git a/go/vt/vtgate/engine/dbddl.go b/go/vt/vtgate/engine/dbddl.go index e69c2f01c4c..013e40f567f 100644 --- a/go/vt/vtgate/engine/dbddl.go +++ b/go/vt/vtgate/engine/dbddl.go @@ -94,7 +94,7 @@ func (c *DBDDL) GetTableName() string { return "" } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (c *DBDDL) TryExecute(vcursor VCursor, _ map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { name := vcursor.GetDBDDLPluginName() plugin, ok := databaseCreatorPlugins[name] @@ -180,7 +180,7 @@ func (c *DBDDL) dropDatabase(vcursor VCursor, plugin DBDDLPlugin) (*sqltypes.Res return &sqltypes.Result{StatusFlags: sqltypes.ServerStatusDbDropped}, nil } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (c *DBDDL) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { res, err := c.TryExecute(vcursor, bindVars, wantfields) if err != nil { @@ -194,8 +194,8 @@ func (c *DBDDL) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes. return &sqltypes.Result{}, nil } -// Description implements the Primitive interface -func (c *DBDDL) Description() PrimitiveDescription { +// description implements the Primitive interface +func (c *DBDDL) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: strings.ToUpper(c.RouteType()), Keyspace: &vindexes.Keyspace{Name: c.name}, diff --git a/go/vt/vtgate/engine/ddl.go b/go/vt/vtgate/engine/ddl.go index b02acc695a3..13ca94d8860 100644 --- a/go/vt/vtgate/engine/ddl.go +++ b/go/vt/vtgate/engine/ddl.go @@ -47,7 +47,7 @@ type DDL struct { noInputs } -func (ddl *DDL) Description() PrimitiveDescription { +func (ddl *DDL) description() PrimitiveDescription { other := map[string]interface{}{ "Query": ddl.SQL, } @@ -85,7 +85,7 @@ func (ddl *DDL) isOnlineSchemaDDL() bool { return false } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (ddl *DDL) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (result *sqltypes.Result, err error) { if ddl.CreateTempTable { vcursor.Session().HasCreatedTempTable() @@ -113,7 +113,7 @@ func (ddl *DDL) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVaria } } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (ddl *DDL) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { results, err := ddl.TryExecute(vcursor, bindVars, wantfields) if err != nil { diff --git a/go/vt/vtgate/engine/delete.go b/go/vt/vtgate/engine/delete.go index c89027afb3c..2eadd0c5249 100644 --- a/go/vt/vtgate/engine/delete.go +++ b/go/vt/vtgate/engine/delete.go @@ -68,7 +68,7 @@ func (del *Delete) GetTableName() string { return "" } -// Execute performs a non-streaming exec. +// TryExecute performs a non-streaming exec. func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { if del.QueryTimeout != 0 { cancel := vcursor.SetContextTimeout(time.Duration(del.QueryTimeout) * time.Millisecond) @@ -92,7 +92,7 @@ func (del *Delete) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind } } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (del *Delete) TryStreamExecute(VCursor, map[string]*querypb.BindVariable, bool, func(*sqltypes.Result) error) error { return fmt.Errorf("query %q cannot be used for streaming", del.Query) } @@ -229,7 +229,7 @@ func (del *Delete) deleteVindexEntries(vcursor VCursor, bindVars map[string]*que return nil } -func (del *Delete) Description() PrimitiveDescription { +func (del *Delete) description() PrimitiveDescription { other := map[string]interface{}{ "Query": del.Query, "Table": del.GetTableName(), diff --git a/go/vt/vtgate/engine/distinct.go b/go/vt/vtgate/engine/distinct.go index 462da477316..fe28e6fe34a 100644 --- a/go/vt/vtgate/engine/distinct.go +++ b/go/vt/vtgate/engine/distinct.go @@ -88,7 +88,7 @@ func newProbeTable() *probeTable { return &probeTable{m: map[int64][]row{}} } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (d *Distinct) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { input, err := vcursor.ExecutePrimitive(d.Source, bindVars, wantfields) if err != nil { @@ -115,7 +115,7 @@ func (d *Distinct) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind return result, err } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (d *Distinct) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { pt := newProbeTable() @@ -169,7 +169,7 @@ func (d *Distinct) Inputs() []Primitive { return []Primitive{d.Source} } -func (d *Distinct) Description() PrimitiveDescription { +func (d *Distinct) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "Distinct", } diff --git a/go/vt/vtgate/engine/fake_primitive_test.go b/go/vt/vtgate/engine/fake_primitive_test.go index 0ea9ec00c31..172c6af7863 100644 --- a/go/vt/vtgate/engine/fake_primitive_test.go +++ b/go/vt/vtgate/engine/fake_primitive_test.go @@ -139,6 +139,6 @@ func wrapStreamExecute(prim Primitive, vcursor VCursor, bindVars map[string]*que return result, err } -func (f *fakePrimitive) Description() PrimitiveDescription { +func (f *fakePrimitive) description() PrimitiveDescription { return PrimitiveDescription{OperatorType: "fake"} } diff --git a/go/vt/vtgate/engine/gen4_compare_v3.go b/go/vt/vtgate/engine/gen4_compare_v3.go index edcc8caa288..1a68b51b46c 100644 --- a/go/vt/vtgate/engine/gen4_compare_v3.go +++ b/go/vt/vtgate/engine/gen4_compare_v3.go @@ -158,15 +158,16 @@ func (gc *Gen4CompareV3) printMismatch(v3Result *sqltypes.Result, gen4Result *sq // Inputs implements the Primitive interface func (gc *Gen4CompareV3) Inputs() []Primitive { - return gc.Gen4.Inputs() + return []Primitive{gc.Gen4, gc.V3} } -// Description implements the Primitive interface -func (gc *Gen4CompareV3) Description() PrimitiveDescription { - return gc.Gen4.Description() +// description implements the Primitive interface +func (gc *Gen4CompareV3) description() PrimitiveDescription { + return PrimitiveDescription{OperatorType: "Gen4CompareV3"} } -func CompareV3AndGen4Errors(v3Err error, gen4Err error) error { +// CompareV3AndGen4Errors compares the two errors, and if they don't match, produces an error +func CompareV3AndGen4Errors(v3Err, gen4Err error) error { if v3Err != nil && gen4Err != nil { if v3Err.Error() == gen4Err.Error() { return gen4Err diff --git a/go/vt/vtgate/engine/insert.go b/go/vt/vtgate/engine/insert.go index 6a5bde145d9..09581a2cb89 100644 --- a/go/vt/vtgate/engine/insert.go +++ b/go/vt/vtgate/engine/insert.go @@ -187,8 +187,8 @@ func (ins *Insert) GetTableName() string { return "" } -// Execute performs a non-streaming exec. -func (ins *Insert) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { +// TryExecute performs a non-streaming exec. +func (ins *Insert) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { if ins.QueryTimeout != 0 { cancel := vcursor.SetContextTimeout(time.Duration(ins.QueryTimeout) * time.Millisecond) defer cancel() @@ -205,13 +205,13 @@ func (ins *Insert) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind } } -// StreamExecute performs a streaming exec. -func (ins *Insert) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { +// TryStreamExecute performs a streaming exec. +func (ins *Insert) TryStreamExecute(VCursor, map[string]*querypb.BindVariable, bool, func(*sqltypes.Result) error) error { return fmt.Errorf("query %q cannot be used for streaming", ins.Query) } // GetFields fetches the field info. -func (ins *Insert) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { +func (ins *Insert) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error) { return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] unreachable code for %q", ins.Query) } @@ -615,7 +615,7 @@ func InsertVarName(col sqlparser.ColIdent, rowNum int) string { return fmt.Sprintf("_%s_%d", col.CompliantName(), rowNum) } -func (ins *Insert) Description() PrimitiveDescription { +func (ins *Insert) description() PrimitiveDescription { other := map[string]interface{}{ "Query": ins.Query, "TableName": ins.GetTableName(), diff --git a/go/vt/vtgate/engine/join.go b/go/vt/vtgate/engine/join.go index 0daadd8f3fa..55d0742fef4 100644 --- a/go/vt/vtgate/engine/join.go +++ b/go/vt/vtgate/engine/join.go @@ -48,7 +48,7 @@ type Join struct { Vars map[string]int `json:",omitempty"` } -// Execute performs a non-streaming exec. +// TryExecute performs a non-streaming exec. func (jn *Join) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { joinVars := make(map[string]*querypb.BindVariable) lresult, err := vcursor.ExecutePrimitive(jn.Left, bindVars, wantfields) @@ -92,7 +92,7 @@ func (jn *Join) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVar return result, nil } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (jn *Join) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { joinVars := make(map[string]*querypb.BindVariable) err := vcursor.StreamExecutePrimitive(jn.Left, bindVars, wantfields, func(lresult *sqltypes.Result) error { @@ -257,7 +257,7 @@ func combineVars(bv1, bv2 map[string]*querypb.BindVariable) map[string]*querypb. return out } -func (jn *Join) Description() PrimitiveDescription { +func (jn *Join) description() PrimitiveDescription { other := map[string]interface{}{ "TableName": jn.GetTableName(), "JoinColumnIndexes": strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jn.Cols)), ","), "[]"), diff --git a/go/vt/vtgate/engine/limit.go b/go/vt/vtgate/engine/limit.go index 7f96a80d389..622c1742c83 100644 --- a/go/vt/vtgate/engine/limit.go +++ b/go/vt/vtgate/engine/limit.go @@ -51,7 +51,7 @@ func (l *Limit) GetTableName() string { return l.Input.GetTableName() } -// Execute satisfies the Primtive interface. +// TryExecute satisfies the Primitive interface. func (l *Limit) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { count, err := l.fetchCount(bindVars) if err != nil { @@ -85,7 +85,7 @@ func (l *Limit) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVar return result, nil } -// StreamExecute satisfies the Primtive interface. +// TryStreamExecute satisfies the Primitive interface. func (l *Limit) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { count, err := l.fetchCount(bindVars) if err != nil { @@ -206,7 +206,7 @@ func (l *Limit) fetchOffset(bindVars map[string]*querypb.BindVariable) (int, err return offset, nil } -func (l *Limit) Description() PrimitiveDescription { +func (l *Limit) description() PrimitiveDescription { other := map[string]interface{}{} if !l.Count.IsNull() { diff --git a/go/vt/vtgate/engine/lock.go b/go/vt/vtgate/engine/lock.go index 829e20d3034..dccd6354af9 100644 --- a/go/vt/vtgate/engine/lock.go +++ b/go/vt/vtgate/engine/lock.go @@ -58,7 +58,7 @@ func (l *Lock) GetTableName() string { return "dual" } -// Execute is part of the Primitive interface +// TryExecute is part of the Primitive interface func (l *Lock) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { rss, _, err := vcursor.ResolveDestinations(l.Keyspace.Name, nil, []key.Destination{l.TargetDestination}) if err != nil { @@ -75,7 +75,7 @@ func (l *Lock) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVari return vcursor.ExecuteLock(rss[0], query) } -// StreamExecute is part of the Primitive interface +// TryStreamExecute is part of the Primitive interface func (l *Lock) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { qr, err := l.TryExecute(vcursor, bindVars, wantfields) if err != nil { @@ -89,7 +89,7 @@ func (l *Lock) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVaria return nil, vterrors.New(vtrpc.Code_UNIMPLEMENTED, "not implements in lock primitive") } -func (l *Lock) Description() PrimitiveDescription { +func (l *Lock) description() PrimitiveDescription { other := map[string]interface{}{ "Query": l.Query, } diff --git a/go/vt/vtgate/engine/memory_sort.go b/go/vt/vtgate/engine/memory_sort.go index 5b5161de631..406b48e7bf4 100644 --- a/go/vt/vtgate/engine/memory_sort.go +++ b/go/vt/vtgate/engine/memory_sort.go @@ -64,7 +64,7 @@ func (ms *MemorySort) SetTruncateColumnCount(count int) { ms.TruncateColumnCount = count } -// Execute satisfies the Primitive interface. +// TryExecute satisfies the Primitive interface. func (ms *MemorySort) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { count, err := ms.fetchCount(bindVars) if err != nil { @@ -90,7 +90,7 @@ func (ms *MemorySort) TryExecute(vcursor VCursor, bindVars map[string]*querypb.B return result.Truncate(ms.TruncateColumnCount), nil } -// StreamExecute satisfies the Primitive interface. +// TryStreamExecute satisfies the Primitive interface. func (ms *MemorySort) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { count, err := ms.fetchCount(bindVars) if err != nil { @@ -176,7 +176,7 @@ func (ms *MemorySort) fetchCount(bindVars map[string]*querypb.BindVariable) (int return count, nil } -func (ms *MemorySort) Description() PrimitiveDescription { +func (ms *MemorySort) description() PrimitiveDescription { orderByIndexes := GenericJoin(ms.OrderBy, orderByParamsToString) value := ms.UpperLimit.Value other := map[string]interface{}{"OrderBy": orderByIndexes} diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go index c01961bb101..9d59a505962 100644 --- a/go/vt/vtgate/engine/merge_sort.go +++ b/go/vt/vtgate/engine/merge_sort.go @@ -64,7 +64,7 @@ func (ms *MergeSort) GetKeyspaceName() string { return "" } // GetTableName satisfies Primitive. func (ms *MergeSort) GetTableName() string { return "" } -// Execute is not supported. +// TryExecute is not supported. func (ms *MergeSort) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] Execute is not reachable") } @@ -74,7 +74,7 @@ func (ms *MergeSort) GetFields(vcursor VCursor, bindVars map[string]*querypb.Bin return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] GetFields is not reachable") } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (ms *MergeSort) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { ctx, cancel := context.WithCancel(vcursor.Context()) defer cancel() @@ -208,7 +208,7 @@ func (ms *MergeSort) getStreamingFields(handles []*streamHandle, callback func(* return nil } -func (ms *MergeSort) Description() PrimitiveDescription { +func (ms *MergeSort) description() PrimitiveDescription { other := map[string]interface{}{ "OrderBy": ms.OrderBy, } diff --git a/go/vt/vtgate/engine/mstream.go b/go/vt/vtgate/engine/mstream.go index 34590abbf40..6c8ea21b9fc 100644 --- a/go/vt/vtgate/engine/mstream.go +++ b/go/vt/vtgate/engine/mstream.go @@ -58,12 +58,12 @@ func (m *MStream) GetTableName() string { return m.TableName } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (m *MStream) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "[BUG] 'Execute' called for Stream") } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (m *MStream) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { rss, _, err := vcursor.ResolveDestinations(m.Keyspace.Name, nil, []key.Destination{m.TargetDestination}) if err != nil { @@ -77,7 +77,7 @@ func (m *MStream) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVa return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "[BUG] 'GetFields' called for Stream") } -func (m *MStream) Description() PrimitiveDescription { +func (m *MStream) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "MStream", Keyspace: m.Keyspace, diff --git a/go/vt/vtgate/engine/online_ddl.go b/go/vt/vtgate/engine/online_ddl.go index e3c33ddf12e..c7efa6792dc 100644 --- a/go/vt/vtgate/engine/online_ddl.go +++ b/go/vt/vtgate/engine/online_ddl.go @@ -46,7 +46,7 @@ type OnlineDDL struct { noInputs } -func (v *OnlineDDL) Description() PrimitiveDescription { +func (v *OnlineDDL) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "OnlineDDL", Keyspace: v.Keyspace, @@ -71,7 +71,7 @@ func (v *OnlineDDL) GetTableName() string { return v.DDL.GetTable().Name.String() } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (v *OnlineDDL) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (result *sqltypes.Result, err error) { result = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -114,7 +114,7 @@ func (v *OnlineDDL) TryExecute(vcursor VCursor, bindVars map[string]*query.BindV return result, err } -//StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (v *OnlineDDL) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { results, err := v.TryExecute(vcursor, bindVars, wantfields) if err != nil { diff --git a/go/vt/vtgate/engine/ordered_aggregate.go b/go/vt/vtgate/engine/ordered_aggregate.go index 9ba6f6c74f7..08d9c4d9ad4 100644 --- a/go/vt/vtgate/engine/ordered_aggregate.go +++ b/go/vt/vtgate/engine/ordered_aggregate.go @@ -251,7 +251,7 @@ func (oa *OrderedAggregate) execute(vcursor VCursor, bindVars map[string]*queryp return out, nil } -// StreamExecute is a Primitive function. +// TryStreamExecute is a Primitive function. func (oa *OrderedAggregate) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { var current []sqltypes.Value var curDistincts []sqltypes.Value @@ -505,7 +505,7 @@ func groupByParamsToString(i interface{}) string { return i.(*GroupByParams).String() } -func (oa *OrderedAggregate) Description() PrimitiveDescription { +func (oa *OrderedAggregate) description() PrimitiveDescription { aggregates := GenericJoin(oa.Aggregates, aggregateParamsToString) groupBy := GenericJoin(oa.GroupByKeys, groupByParamsToString) other := map[string]interface{}{ diff --git a/go/vt/vtgate/engine/plan_description.go b/go/vt/vtgate/engine/plan_description.go index 86cb993f2a9..f3a0b214944 100644 --- a/go/vt/vtgate/engine/plan_description.go +++ b/go/vt/vtgate/engine/plan_description.go @@ -121,7 +121,7 @@ func marshalAdd(prepend string, buf *bytes.Buffer, name string, obj interface{}) // PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree func PrimitiveToPlanDescription(in Primitive) PrimitiveDescription { - this := in.Description() + this := in.description() for _, input := range in.Inputs() { this.Inputs = append(this.Inputs, PrimitiveToPlanDescription(input)) diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go index db4a5ee0a38..829ed10fde8 100644 --- a/go/vt/vtgate/engine/primitive.go +++ b/go/vt/vtgate/engine/primitive.go @@ -199,9 +199,9 @@ type ( // Inputs is a slice containing the inputs to this Primitive Inputs() []Primitive - // Description is the description, sans the inputs, of this Primitive. + // description is the description, sans the inputs, of this Primitive. // to get the plan description with all children, use PrimitiveToPlanDescription() - Description() PrimitiveDescription + description() PrimitiveDescription } // noInputs default implementation for Primitives that are leaves diff --git a/go/vt/vtgate/engine/projection.go b/go/vt/vtgate/engine/projection.go index 3eaa8f6e20d..d749e31139c 100644 --- a/go/vt/vtgate/engine/projection.go +++ b/go/vt/vtgate/engine/projection.go @@ -31,7 +31,7 @@ func (p *Projection) GetTableName() string { return p.Input.GetTableName() } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (p *Projection) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { result, err := vcursor.ExecutePrimitive(p.Input, bindVars, wantfields) if err != nil { @@ -64,7 +64,7 @@ func (p *Projection) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bi return result, nil } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (p *Projection) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { result, err := vcursor.ExecutePrimitive(p.Input, bindVars, wantields) if err != nil { @@ -130,8 +130,8 @@ func (p *Projection) Inputs() []Primitive { return []Primitive{p.Input} } -// Description implements the Primitive interface -func (p *Projection) Description() PrimitiveDescription { +// description implements the Primitive interface +func (p *Projection) description() PrimitiveDescription { var exprs []string for _, e := range p.Exprs { exprs = append(exprs, e.String()) diff --git a/go/vt/vtgate/engine/pullout_subquery.go b/go/vt/vtgate/engine/pullout_subquery.go index 371c6d1b823..2378ea50a6d 100644 --- a/go/vt/vtgate/engine/pullout_subquery.go +++ b/go/vt/vtgate/engine/pullout_subquery.go @@ -61,7 +61,7 @@ func (ps *PulloutSubquery) GetTableName() string { return ps.Underlying.GetTableName() } -// Execute satisfies the Primitive interface. +// TryExecute satisfies the Primitive interface. func (ps *PulloutSubquery) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { combinedVars, err := ps.execSubquery(vcursor, bindVars) if err != nil { @@ -70,7 +70,7 @@ func (ps *PulloutSubquery) TryExecute(vcursor VCursor, bindVars map[string]*quer return vcursor.ExecutePrimitive(ps.Underlying, combinedVars, wantfields) } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (ps *PulloutSubquery) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { combinedVars, err := ps.execSubquery(vcursor, bindVars) if err != nil { @@ -170,7 +170,7 @@ func (ps *PulloutSubquery) execSubquery(vcursor VCursor, bindVars map[string]*qu return combinedVars, nil } -func (ps *PulloutSubquery) Description() PrimitiveDescription { +func (ps *PulloutSubquery) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "Subquery", Variant: ps.Opcode.String(), diff --git a/go/vt/vtgate/engine/rename_fields.go b/go/vt/vtgate/engine/rename_fields.go index 61a1c8988c8..4bc8c676fd2 100644 --- a/go/vt/vtgate/engine/rename_fields.go +++ b/go/vt/vtgate/engine/rename_fields.go @@ -60,7 +60,7 @@ func (r *RenameFields) GetTableName() string { return r.Input.GetTableName() } -// Execute implements the primitive interface +// TryExecute implements the Primitive interface func (r *RenameFields) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { qr, err := vcursor.ExecutePrimitive(r.Input, bindVars, wantfields) if err != nil { @@ -82,7 +82,7 @@ func (r *RenameFields) renameFields(qr *sqltypes.Result) { } } -// StreamExecute implements the primitive interface +// TryStreamExecute implements the Primitive interface func (r *RenameFields) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { if wantfields { innerCallback := callback @@ -113,8 +113,8 @@ func (r *RenameFields) Inputs() []Primitive { return []Primitive{r.Input} } -// Description implements the primitive interface -func (r *RenameFields) Description() PrimitiveDescription { +// description implements the primitive interface +func (r *RenameFields) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "RenameFields", Other: map[string]interface{}{ diff --git a/go/vt/vtgate/engine/replace_variables.go b/go/vt/vtgate/engine/replace_variables.go index a9708f572a1..15fc609ffd3 100644 --- a/go/vt/vtgate/engine/replace_variables.go +++ b/go/vt/vtgate/engine/replace_variables.go @@ -49,7 +49,7 @@ func (r *ReplaceVariables) GetTableName() string { return r.Input.GetTableName() } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (r *ReplaceVariables) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { qr, err := vcursor.ExecutePrimitive(r.Input, bindVars, wantfields) if err != nil { @@ -59,7 +59,7 @@ func (r *ReplaceVariables) TryExecute(vcursor VCursor, bindVars map[string]*quer return qr, nil } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (r *ReplaceVariables) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { innerCallback := callback callback = func(result *sqltypes.Result) error { @@ -79,8 +79,8 @@ func (r *ReplaceVariables) Inputs() []Primitive { return []Primitive{r.Input} } -// Description implements the Primitive interface -func (r *ReplaceVariables) Description() PrimitiveDescription { +// description implements the Primitive interface +func (r *ReplaceVariables) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "ReplaceVariables", } diff --git a/go/vt/vtgate/engine/revert_migration.go b/go/vt/vtgate/engine/revert_migration.go index 71b6a4c72c6..6408a8e0aa2 100644 --- a/go/vt/vtgate/engine/revert_migration.go +++ b/go/vt/vtgate/engine/revert_migration.go @@ -44,7 +44,7 @@ type RevertMigration struct { noInputs } -func (v *RevertMigration) Description() PrimitiveDescription { +func (v *RevertMigration) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "RevertMigration", Keyspace: v.Keyspace, @@ -69,7 +69,7 @@ func (v *RevertMigration) GetTableName() string { return "" } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (v *RevertMigration) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (result *sqltypes.Result, err error) { result = &sqltypes.Result{ Fields: []*querypb.Field{ @@ -116,7 +116,7 @@ func (v *RevertMigration) TryExecute(vcursor VCursor, bindVars map[string]*query return result, err } -//StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (v *RevertMigration) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { results, err := v.TryExecute(vcursor, bindVars, wantfields) if err != nil { diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go index 280a22f4618..5879252b6dc 100644 --- a/go/vt/vtgate/engine/route.go +++ b/go/vt/vtgate/engine/route.go @@ -242,7 +242,7 @@ func (route *Route) SetTruncateColumnCount(count int) { route.TruncateColumnCount = count } -// Execute performs a non-streaming exec. +// 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 { cancel := vcursor.SetContextTimeout(time.Duration(route.QueryTimeout) * time.Millisecond) @@ -324,7 +324,7 @@ func filterOutNilErrors(errs []error) []error { return errors } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (route *Route) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { var rss []*srvtopo.ResolvedShard var bvs []map[string]*querypb.BindVariable @@ -779,7 +779,7 @@ func allowOnlyPrimary(rss ...*srvtopo.ResolvedShard) error { return nil } -func (route *Route) Description() PrimitiveDescription { +func (route *Route) description() PrimitiveDescription { other := map[string]interface{}{ "Query": route.Query, "Table": route.TableName, diff --git a/go/vt/vtgate/engine/rows.go b/go/vt/vtgate/engine/rows.go index 6d223a7f938..f047af75707 100644 --- a/go/vt/vtgate/engine/rows.go +++ b/go/vt/vtgate/engine/rows.go @@ -23,7 +23,7 @@ import ( var _ Primitive = (*Rows)(nil) -//Rows simply returns a number or rows +// Rows simply returns a number or rows type Rows struct { rows [][]sqltypes.Value fields []*querypb.Field @@ -32,27 +32,27 @@ type Rows struct { noTxNeeded } -//NewRowsPrimitive returns a new Rows primitie +// NewRowsPrimitive returns a new Rows primitie func NewRowsPrimitive(rows [][]sqltypes.Value, fields []*querypb.Field) *Rows { return &Rows{rows: rows, fields: fields} } -//RouteType implements the Primitive interface +// RouteType implements the Primitive interface func (r *Rows) RouteType() string { return "Rows" } -//GetKeyspaceName implements the Primitive interface +// GetKeyspaceName implements the Primitive interface func (r *Rows) GetKeyspaceName() string { return "" } -//GetTableName implements the Primitive interface +// GetTableName implements the Primitive interface func (r *Rows) GetTableName() string { return "" } -//Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (r *Rows) TryExecute(VCursor, map[string]*querypb.BindVariable, bool) (*sqltypes.Result, error) { return &sqltypes.Result{ Fields: r.fields, @@ -61,7 +61,7 @@ func (r *Rows) TryExecute(VCursor, map[string]*querypb.BindVariable, bool) (*sql }, nil } -//StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (r *Rows) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { result, err := r.TryExecute(vcursor, bindVars, wantields) if err != nil { @@ -70,7 +70,7 @@ func (r *Rows) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.Bi return callback(result) } -//GetFields implements the Primitive interface +// GetFields implements the Primitive interface func (r *Rows) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error) { return &sqltypes.Result{ Fields: r.fields, @@ -79,6 +79,6 @@ func (r *Rows) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.R }, nil } -func (r *Rows) Description() PrimitiveDescription { +func (r *Rows) description() PrimitiveDescription { return PrimitiveDescription{OperatorType: "Rows"} } diff --git a/go/vt/vtgate/engine/send.go b/go/vt/vtgate/engine/send.go index b8a048f729f..762764cc61e 100644 --- a/go/vt/vtgate/engine/send.go +++ b/go/vt/vtgate/engine/send.go @@ -81,7 +81,7 @@ func (s *Send) GetTableName() string { return "" } -// Execute implements Primitive interface +// TryExecute implements Primitive interface func (s *Send) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { rss, _, err := vcursor.ResolveDestinations(s.Keyspace.Name, nil, []key.Destination{s.TargetDestination}) if err != nil { @@ -131,7 +131,7 @@ func copyBindVars(in map[string]*querypb.BindVariable) map[string]*querypb.BindV return out } -// StreamExecute implements Primitive interface +// TryStreamExecute implements Primitive interface func (s *Send) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { rss, _, err := vcursor.ResolveDestinations(s.Keyspace.Name, nil, []key.Destination{s.TargetDestination}) if err != nil { @@ -169,7 +169,7 @@ func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVaria return qr, nil } -func (s *Send) Description() PrimitiveDescription { +func (s *Send) description() PrimitiveDescription { other := map[string]interface{}{ "Query": s.Query, "Table": s.GetTableName(), diff --git a/go/vt/vtgate/engine/session_primitive.go b/go/vt/vtgate/engine/session_primitive.go index c29485292f3..bb2733456b9 100644 --- a/go/vt/vtgate/engine/session_primitive.go +++ b/go/vt/vtgate/engine/session_primitive.go @@ -58,12 +58,12 @@ func (s *SessionPrimitive) GetTableName() string { return "" } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (s *SessionPrimitive) TryExecute(vcursor VCursor, _ map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { return s.action(vcursor.Session()) } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (s *SessionPrimitive) TryStreamExecute(vcursor VCursor, _ map[string]*querypb.BindVariable, _ bool, callback func(*sqltypes.Result) error) error { qr, err := s.action(vcursor.Session()) if err != nil { @@ -77,8 +77,8 @@ func (s *SessionPrimitive) GetFields(_ VCursor, _ map[string]*querypb.BindVariab return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "not supported for this primitive") } -// Description implements the Primitive interface -func (s *SessionPrimitive) Description() PrimitiveDescription { +// description implements the Primitive interface +func (s *SessionPrimitive) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: s.name, } diff --git a/go/vt/vtgate/engine/set.go b/go/vt/vtgate/engine/set.go index e5bd220816e..53d8fe024de 100644 --- a/go/vt/vtgate/engine/set.go +++ b/go/vt/vtgate/engine/set.go @@ -94,22 +94,22 @@ type ( var _ Primitive = (*Set)(nil) -//RouteType implements the Primitive interface method. +// RouteType implements the Primitive interface method. func (s *Set) RouteType() string { return "Set" } -//GetKeyspaceName implements the Primitive interface method. +// GetKeyspaceName implements the Primitive interface method. func (s *Set) GetKeyspaceName() string { return "" } -//GetTableName implements the Primitive interface method. +// GetTableName implements the Primitive interface method. func (s *Set) GetTableName() string { return "" } -//Execute implements the Primitive interface method. +// TryExecute implements the Primitive interface method. func (s *Set) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, _ bool) (*sqltypes.Result, error) { input, err := vcursor.ExecutePrimitive(s.Input, bindVars, false) if err != nil { @@ -131,7 +131,7 @@ func (s *Set) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVaria return &sqltypes.Result{}, nil } -//StreamExecute implements the Primitive interface method. +// TryStreamExecute implements the Primitive interface method. func (s *Set) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { result, err := s.TryExecute(vcursor, bindVars, wantields) if err != nil { @@ -140,17 +140,17 @@ func (s *Set) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.Bin return callback(result) } -//GetFields implements the Primitive interface method. +// GetFields implements the Primitive interface method. func (s *Set) GetFields(VCursor, map[string]*querypb.BindVariable) (*sqltypes.Result, error) { return &sqltypes.Result{}, nil } -//Inputs implements the Primitive interface +// Inputs implements the Primitive interface func (s *Set) Inputs() []Primitive { return []Primitive{s.Input} } -func (s *Set) Description() PrimitiveDescription { +func (s *Set) description() PrimitiveDescription { other := map[string]interface{}{ "Ops": s.Ops, } @@ -162,7 +162,7 @@ func (s *Set) Description() PrimitiveDescription { var _ SetOp = (*UserDefinedVariable)(nil) -//MarshalJSON provides the type to SetOp for plan json +// MarshalJSON provides the type to SetOp for plan json func (u *UserDefinedVariable) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type string @@ -176,12 +176,12 @@ func (u *UserDefinedVariable) MarshalJSON() ([]byte, error) { } -//VariableName implements the SetOp interface method. +// VariableName implements the SetOp interface method. func (u *UserDefinedVariable) VariableName() string { return u.Name } -//Execute implements the SetOp interface method. +// Execute implements the SetOp interface method. func (u *UserDefinedVariable) Execute(vcursor VCursor, env evalengine.ExpressionEnv) error { value, err := u.Expr.Evaluate(env) if err != nil { @@ -192,7 +192,7 @@ func (u *UserDefinedVariable) Execute(vcursor VCursor, env evalengine.Expression var _ SetOp = (*SysVarIgnore)(nil) -//MarshalJSON provides the type to SetOp for plan json +// MarshalJSON provides the type to SetOp for plan json func (svi *SysVarIgnore) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type string @@ -204,12 +204,12 @@ func (svi *SysVarIgnore) MarshalJSON() ([]byte, error) { } -//VariableName implements the SetOp interface method. +// VariableName implements the SetOp interface method. func (svi *SysVarIgnore) VariableName() string { return svi.Name } -//Execute implements the SetOp interface method. +// Execute implements the SetOp interface method. func (svi *SysVarIgnore) Execute(VCursor, evalengine.ExpressionEnv) error { log.Infof("Ignored inapplicable SET %v = %v", svi.Name, svi.Expr) return nil @@ -217,7 +217,7 @@ func (svi *SysVarIgnore) Execute(VCursor, evalengine.ExpressionEnv) error { var _ SetOp = (*SysVarCheckAndIgnore)(nil) -//MarshalJSON provides the type to SetOp for plan json +// MarshalJSON provides the type to SetOp for plan json func (svci *SysVarCheckAndIgnore) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type string @@ -229,12 +229,12 @@ func (svci *SysVarCheckAndIgnore) MarshalJSON() ([]byte, error) { } -//VariableName implements the SetOp interface method +// VariableName implements the SetOp interface method func (svci *SysVarCheckAndIgnore) VariableName() string { return svci.Name } -//Execute implements the SetOp interface method +// Execute implements the SetOp interface method func (svci *SysVarCheckAndIgnore) Execute(vcursor VCursor, env evalengine.ExpressionEnv) error { rss, _, err := vcursor.ResolveDestinations(svci.Keyspace.Name, nil, []key.Destination{svci.TargetDestination}) if err != nil { @@ -261,7 +261,7 @@ func (svci *SysVarCheckAndIgnore) Execute(vcursor VCursor, env evalengine.Expres var _ SetOp = (*SysVarReservedConn)(nil) -//MarshalJSON provides the type to SetOp for plan json +// MarshalJSON provides the type to SetOp for plan json func (svs *SysVarReservedConn) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type string @@ -273,12 +273,12 @@ func (svs *SysVarReservedConn) MarshalJSON() ([]byte, error) { } -//VariableName implements the SetOp interface method +// VariableName implements the SetOp interface method func (svs *SysVarReservedConn) VariableName() string { return svs.Name } -//Execute implements the SetOp interface method +// Execute implements the SetOp interface method func (svs *SysVarReservedConn) Execute(vcursor VCursor, env evalengine.ExpressionEnv) error { // For those running on advanced vitess settings. if svs.TargetDestination != nil { @@ -349,7 +349,7 @@ func (svs *SysVarReservedConn) checkAndUpdateSysVar(vcursor VCursor, res evaleng var _ SetOp = (*SysVarSetAware)(nil) -//MarshalJSON marshals all the json +// MarshalJSON marshals all the json func (svss *SysVarSetAware) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Type string @@ -362,7 +362,7 @@ func (svss *SysVarSetAware) MarshalJSON() ([]byte, error) { }) } -//Execute implements the SetOp interface method +// Execute implements the SetOp interface method func (svss *SysVarSetAware) Execute(vcursor VCursor, env evalengine.ExpressionEnv) error { var err error switch svss.Name { @@ -514,7 +514,7 @@ func (svss *SysVarSetAware) setBoolSysVar(env evalengine.ExpressionEnv, setter f return setter(boolValue) } -//VariableName implements the SetOp interface method +// VariableName implements the SetOp interface method func (svss *SysVarSetAware) VariableName() string { return svss.Name } diff --git a/go/vt/vtgate/engine/simple_projection.go b/go/vt/vtgate/engine/simple_projection.go index b0c93e5d742..46355cefe00 100644 --- a/go/vt/vtgate/engine/simple_projection.go +++ b/go/vt/vtgate/engine/simple_projection.go @@ -51,7 +51,7 @@ func (sc *SimpleProjection) GetTableName() string { return sc.Input.GetTableName() } -// Execute performs a non-streaming exec. +// TryExecute performs a non-streaming exec. func (sc *SimpleProjection) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { inner, err := vcursor.ExecutePrimitive(sc.Input, bindVars, wantfields) if err != nil { @@ -60,7 +60,7 @@ func (sc *SimpleProjection) TryExecute(vcursor VCursor, bindVars map[string]*que return sc.buildResult(inner), nil } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (sc *SimpleProjection) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { return vcursor.StreamExecutePrimitive(sc.Input, bindVars, wantfields, func(inner *sqltypes.Result) error { return callback(sc.buildResult(inner)) @@ -108,7 +108,7 @@ func (sc *SimpleProjection) buildFields(inner *sqltypes.Result) []*querypb.Field return fields } -func (sc *SimpleProjection) Description() PrimitiveDescription { +func (sc *SimpleProjection) description() PrimitiveDescription { other := map[string]interface{}{ "Columns": sc.Cols, } diff --git a/go/vt/vtgate/engine/singlerow.go b/go/vt/vtgate/engine/singlerow.go index cbc0d275e31..622246d36cc 100644 --- a/go/vt/vtgate/engine/singlerow.go +++ b/go/vt/vtgate/engine/singlerow.go @@ -44,8 +44,8 @@ func (s *SingleRow) GetTableName() string { return "" } -// Execute performs a non-streaming exec. -func (s *SingleRow) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error) { +// TryExecute performs a non-streaming exec. +func (s *SingleRow) TryExecute(VCursor, map[string]*query.BindVariable, bool) (*sqltypes.Result, error) { result := sqltypes.Result{ Rows: [][]sqltypes.Value{ {}, @@ -54,8 +54,8 @@ func (s *SingleRow) TryExecute(vcursor VCursor, bindVars map[string]*query.BindV return &result, nil } -// StreamExecute performs a streaming exec. -func (s *SingleRow) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { +// TryStreamExecute performs a streaming exec. +func (s *SingleRow) TryStreamExecute(_ VCursor, _ map[string]*query.BindVariable, _ bool, callback func(*sqltypes.Result) error) error { result := sqltypes.Result{ Rows: [][]sqltypes.Value{ {}, @@ -65,11 +65,11 @@ func (s *SingleRow) TryStreamExecute(vcursor VCursor, bindVars map[string]*query } // GetFields fetches the field info. -func (s *SingleRow) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error) { +func (s *SingleRow) GetFields(_ VCursor, _ map[string]*query.BindVariable) (*sqltypes.Result, error) { return &sqltypes.Result{}, nil } -func (s *SingleRow) Description() PrimitiveDescription { +func (s *SingleRow) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "SingleRow", } diff --git a/go/vt/vtgate/engine/sql_calc_found_rows.go b/go/vt/vtgate/engine/sql_calc_found_rows.go index 5475c027778..f6ccdc2c40e 100644 --- a/go/vt/vtgate/engine/sql_calc_found_rows.go +++ b/go/vt/vtgate/engine/sql_calc_found_rows.go @@ -26,28 +26,28 @@ import ( var _ Primitive = (*SQLCalcFoundRows)(nil) -//SQLCalcFoundRows is a primitive to execute limit and count query as per their individual plan. +// SQLCalcFoundRows is a primitive to execute limit and count query as per their individual plan. type SQLCalcFoundRows struct { LimitPrimitive Primitive CountPrimitive Primitive } -//RouteType implements the Primitive interface +// RouteType implements the Primitive interface func (s SQLCalcFoundRows) RouteType() string { return "SQLCalcFoundRows" } -//GetKeyspaceName implements the Primitive interface +// GetKeyspaceName implements the Primitive interface func (s SQLCalcFoundRows) GetKeyspaceName() string { return s.LimitPrimitive.GetKeyspaceName() } -//GetTableName implements the Primitive interface +// GetTableName implements the Primitive interface func (s SQLCalcFoundRows) GetTableName() string { return s.LimitPrimitive.GetTableName() } -//Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (s SQLCalcFoundRows) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { limitQr, err := vcursor.ExecutePrimitive(s.LimitPrimitive, bindVars, wantfields) if err != nil { @@ -68,7 +68,7 @@ func (s SQLCalcFoundRows) TryExecute(vcursor VCursor, bindVars map[string]*query return limitQr, nil } -//StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (s SQLCalcFoundRows) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { err := vcursor.StreamExecutePrimitive(s.LimitPrimitive, bindVars, wantfields, callback) if err != nil { @@ -102,22 +102,22 @@ func (s SQLCalcFoundRows) TryStreamExecute(vcursor VCursor, bindVars map[string] return nil } -//GetFields implements the Primitive interface +// GetFields implements the Primitive interface func (s SQLCalcFoundRows) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { return s.LimitPrimitive.GetFields(vcursor, bindVars) } -//NeedsTransaction implements the Primitive interface +// NeedsTransaction implements the Primitive interface func (s SQLCalcFoundRows) NeedsTransaction() bool { return s.LimitPrimitive.NeedsTransaction() } -//Inputs implements the Primitive interface +// Inputs implements the Primitive interface func (s SQLCalcFoundRows) Inputs() []Primitive { return []Primitive{s.LimitPrimitive, s.CountPrimitive} } -func (s SQLCalcFoundRows) Description() PrimitiveDescription { +func (s SQLCalcFoundRows) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "SQL_CALC_FOUND_ROWS", } diff --git a/go/vt/vtgate/engine/update.go b/go/vt/vtgate/engine/update.go index cf79a952068..9bb52b37197 100644 --- a/go/vt/vtgate/engine/update.go +++ b/go/vt/vtgate/engine/update.go @@ -80,7 +80,7 @@ func (upd *Update) GetTableName() string { return "" } -// Execute performs a non-streaming exec. +// TryExecute performs a non-streaming exec. func (upd *Update) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { if upd.QueryTimeout != 0 { cancel := vcursor.SetContextTimeout(time.Duration(upd.QueryTimeout) * time.Millisecond) @@ -104,7 +104,7 @@ func (upd *Update) TryExecute(vcursor VCursor, bindVars map[string]*querypb.Bind } } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (upd *Update) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { return fmt.Errorf("query %q cannot be used for streaming", upd.Query) } @@ -269,7 +269,7 @@ func (upd *Update) updateVindexEntries(vcursor VCursor, bindVars map[string]*que return nil } -func (upd *Update) Description() PrimitiveDescription { +func (upd *Update) description() PrimitiveDescription { other := map[string]interface{}{ "Query": upd.Query, "Table": upd.GetTableName(), diff --git a/go/vt/vtgate/engine/update_target.go b/go/vt/vtgate/engine/update_target.go index e9f75e2acb1..3ade69ebd50 100644 --- a/go/vt/vtgate/engine/update_target.go +++ b/go/vt/vtgate/engine/update_target.go @@ -36,7 +36,7 @@ type UpdateTarget struct { noTxNeeded } -func (updTarget *UpdateTarget) Description() PrimitiveDescription { +func (updTarget *UpdateTarget) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "UpdateTarget", Other: map[string]interface{}{"target": updTarget.Target}, @@ -58,7 +58,7 @@ func (updTarget *UpdateTarget) GetTableName() string { return "" } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (updTarget *UpdateTarget) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error) { err := vcursor.Session().SetTarget(updTarget.Target) if err != nil { @@ -67,7 +67,7 @@ func (updTarget *UpdateTarget) TryExecute(vcursor VCursor, bindVars map[string]* return &sqltypes.Result{}, nil } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (updTarget *UpdateTarget) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { result, err := updTarget.TryExecute(vcursor, bindVars, wantfields) if err != nil { diff --git a/go/vt/vtgate/engine/vindex_func.go b/go/vt/vtgate/engine/vindex_func.go index 9d54c1a59a3..fd102f38be7 100644 --- a/go/vt/vtgate/engine/vindex_func.go +++ b/go/vt/vtgate/engine/vindex_func.go @@ -85,12 +85,12 @@ func (vf *VindexFunc) GetTableName() string { return "" } -// Execute performs a non-streaming exec. +// TryExecute performs a non-streaming exec. func (vf *VindexFunc) TryExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { return vf.mapVindex(vcursor, bindVars) } -// StreamExecute performs a streaming exec. +// TryStreamExecute performs a streaming exec. func (vf *VindexFunc) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { r, err := vf.mapVindex(vcursor, bindVars) if err != nil { @@ -204,7 +204,7 @@ func (vf *VindexFunc) buildRow(id sqltypes.Value, ksid []byte, kr *topodatapb.Ke return row } -func (vf *VindexFunc) Description() PrimitiveDescription { +func (vf *VindexFunc) description() PrimitiveDescription { fields := map[string]string{} for _, field := range vf.Fields { fields[field.Name] = field.Type.String() diff --git a/go/vt/vtgate/engine/vschema_ddl.go b/go/vt/vtgate/engine/vschema_ddl.go index 87e6a69831b..42737550237 100644 --- a/go/vt/vtgate/engine/vschema_ddl.go +++ b/go/vt/vtgate/engine/vschema_ddl.go @@ -38,7 +38,7 @@ type AlterVSchema struct { noInputs } -func (v *AlterVSchema) Description() PrimitiveDescription { +func (v *AlterVSchema) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "AlterVSchema", Keyspace: v.Keyspace, @@ -48,22 +48,22 @@ func (v *AlterVSchema) Description() PrimitiveDescription { } } -//RouteType implements the Primitive interface +// RouteType implements the Primitive interface func (v *AlterVSchema) RouteType() string { return "AlterVSchema" } -//GetKeyspaceName implements the Primitive interface +// GetKeyspaceName implements the Primitive interface func (v *AlterVSchema) GetKeyspaceName() string { return v.Keyspace.Name } -//GetTableName implements the Primitive interface +// GetTableName implements the Primitive interface func (v *AlterVSchema) GetTableName() string { return v.AlterVschemaDDL.Table.Name.String() } -//Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (v *AlterVSchema) TryExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error) { err := vcursor.ExecuteVSchema(v.Keyspace.Name, v.AlterVschemaDDL) if err != nil { @@ -72,12 +72,12 @@ func (v *AlterVSchema) TryExecute(vcursor VCursor, bindVars map[string]*query.Bi return &sqltypes.Result{}, nil } -//StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (v *AlterVSchema) TryStreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error { return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "Alter vschema not supported in streaming") } -//GetFields implements the Primitive interface +// GetFields implements the Primitive interface func (v *AlterVSchema) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error) { return nil, vterrors.NewErrorf(vtrpcpb.Code_UNIMPLEMENTED, vterrors.UnsupportedPS, "This command is not supported in the prepared statement protocol yet") } diff --git a/go/vt/vtgate/engine/vstream.go b/go/vt/vtgate/engine/vstream.go index de14ffedab8..3d7223eba68 100644 --- a/go/vt/vtgate/engine/vstream.go +++ b/go/vt/vtgate/engine/vstream.go @@ -60,12 +60,12 @@ func (v *VStream) GetTableName() string { return v.TableName } -// Execute implements the Primitive interface +// TryExecute implements the Primitive interface func (v *VStream) TryExecute(_ VCursor, _ map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "[BUG] 'Execute' called for VStream") } -// StreamExecute implements the Primitive interface +// TryStreamExecute implements the Primitive interface func (v *VStream) TryStreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { rss, _, err := vcursor.ResolveDestinations(v.Keyspace.Name, nil, []key.Destination{v.TargetDestination}) if err != nil { @@ -145,7 +145,7 @@ func (v *VStream) GetFields(_ VCursor, _ map[string]*querypb.BindVariable) (*sql return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "[BUG] 'GetFields' called for VStream") } -func (v *VStream) Description() PrimitiveDescription { +func (v *VStream) description() PrimitiveDescription { other := map[string]interface{}{ "Table": v.TableName, "Limit": v.Limit, diff --git a/go/vt/vtgate/schema/uptate_controller.go b/go/vt/vtgate/schema/uptate_controller.go index 18472a20163..36bd7d5332c 100644 --- a/go/vt/vtgate/schema/uptate_controller.go +++ b/go/vt/vtgate/schema/uptate_controller.go @@ -99,6 +99,9 @@ func (u *updateController) add(th *discovery.TabletHealth) { return } + u.mu.Lock() + defer u.mu.Unlock() + // Received a health check from primary tablet that is not reachable from VTGate. // The connection will get reset and the tracker needs to reload the schema for the keyspace. if !th.Serving { @@ -106,9 +109,6 @@ func (u *updateController) add(th *discovery.TabletHealth) { return } - u.mu.Lock() - defer u.mu.Unlock() - // If the keyspace schema is loaded and there is no schema change detected. Then there is nothing to process. if len(th.Stats.TableSchemaChanged) == 0 && u.loaded { return