vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletmanager/rpc_vexec.go (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package tabletmanager 18 19 import ( 20 "fmt" 21 22 querypb "vitess.io/vitess/go/vt/proto/query" 23 "vitess.io/vitess/go/vt/schema" 24 "vitess.io/vitess/go/vt/vttablet/vexec" 25 26 "context" 27 ) 28 29 // VExec executes a generic VExec command. 30 func (tm *TabletManager) VExec(ctx context.Context, query, workflow, keyspace string) (*querypb.QueryResult, error) { 31 vx := vexec.NewTabletVExec(workflow, keyspace) 32 if err := vx.AnalyzeQuery(ctx, query); err != nil { 33 return nil, err 34 } 35 switch vx.TableName { 36 case fmt.Sprintf("%s.%s", vexec.TableQualifier, schema.SchemaMigrationsTableName): 37 return tm.QueryServiceControl.OnlineDDLExecutor().VExec(ctx, vx) 38 default: 39 return nil, fmt.Errorf("table not supported by vexec: %v", vx.TableName) 40 } 41 }