vitess.io/vitess@v0.16.2/go/vt/vtgate/engine/singlerow.go (about) 1 /* 2 Copyright 2020 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 engine 18 19 import ( 20 "context" 21 22 "vitess.io/vitess/go/sqltypes" 23 querypb "vitess.io/vitess/go/vt/proto/query" 24 ) 25 26 var _ Primitive = (*SingleRow)(nil) 27 28 // SingleRow defines an empty result 29 type SingleRow struct { 30 noInputs 31 noTxNeeded 32 } 33 34 // RouteType returns a description of the query routing type used by the primitive 35 func (s *SingleRow) RouteType() string { 36 return "" 37 } 38 39 // GetKeyspaceName specifies the Keyspace that this primitive routes to. 40 func (s *SingleRow) GetKeyspaceName() string { 41 return "" 42 } 43 44 // GetTableName specifies the table that this primitive routes to. 45 func (s *SingleRow) GetTableName() string { 46 return "" 47 } 48 49 // TryExecute performs a non-streaming exec. 50 func (s *SingleRow) TryExecute(context.Context, VCursor, map[string]*querypb.BindVariable, bool) (*sqltypes.Result, error) { 51 result := sqltypes.Result{ 52 Rows: [][]sqltypes.Value{ 53 {}, 54 }, 55 } 56 return &result, nil 57 } 58 59 // TryStreamExecute performs a streaming exec. 60 func (s *SingleRow) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { 61 res, err := s.TryExecute(ctx, vcursor, bindVars, wantfields) 62 if err != nil { 63 return err 64 } 65 return callback(res) 66 } 67 68 // GetFields fetches the field info. 69 func (s *SingleRow) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { 70 return &sqltypes.Result{}, nil 71 } 72 73 func (s *SingleRow) description() PrimitiveDescription { 74 return PrimitiveDescription{ 75 OperatorType: "SingleRow", 76 } 77 }