vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/call_proc.go (about) 1 /* 2 Copyright 2021 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 planbuilder 18 19 import ( 20 "vitess.io/vitess/go/vt/key" 21 "vitess.io/vitess/go/vt/sqlparser" 22 "vitess.io/vitess/go/vt/vtgate/engine" 23 "vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" 24 ) 25 26 func buildCallProcPlan(stmt *sqlparser.CallProc, vschema plancontext.VSchema) (*planResult, error) { 27 var ks string 28 if !stmt.Name.Qualifier.IsEmpty() { 29 ks = stmt.Name.Qualifier.String() 30 } 31 32 dest, keyspace, _, err := vschema.TargetDestination(ks) 33 if err != nil { 34 return nil, err 35 } 36 37 if dest == nil { 38 if err := vschema.ErrorIfShardedF(keyspace, "CALL", errNotAllowWhenSharded); err != nil { 39 return nil, err 40 } 41 dest = key.DestinationAnyShard{} 42 } 43 44 stmt.Name.Qualifier = sqlparser.NewIdentifierCS("") 45 46 return newPlanResult(&engine.Send{ 47 Keyspace: keyspace, 48 TargetDestination: dest, 49 Query: sqlparser.String(stmt), 50 }), nil 51 } 52 53 const errNotAllowWhenSharded = "CALL is not supported for sharded keyspace"