vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletmanager/vdiff/cursor.go (about)

     1  /*
     2  Copyright 2022 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 vdiff
    18  
    19  import (
    20  	"context"
    21  
    22  	"vitess.io/vitess/go/mysql/collations"
    23  	"vitess.io/vitess/go/sqltypes"
    24  	querypb "vitess.io/vitess/go/vt/proto/query"
    25  	"vitess.io/vitess/go/vt/vtgate/engine"
    26  )
    27  
    28  // contextVCursor satisfies VCursor, but only implements Context().
    29  // MergeSort only requires Context to be implemented.
    30  type contextVCursor struct {
    31  	engine.VCursor
    32  	ctx context.Context
    33  }
    34  
    35  func (vc *contextVCursor) ConnCollation() collations.ID {
    36  	return collations.CollationBinaryID
    37  }
    38  
    39  func (vc *contextVCursor) ExecutePrimitive(ctx context.Context, primitive engine.Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
    40  	return primitive.TryExecute(ctx, vc, bindVars, wantfields)
    41  }
    42  
    43  func (vc *contextVCursor) StreamExecutePrimitive(ctx context.Context, primitive engine.Primitive, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error {
    44  	return primitive.TryStreamExecute(ctx, vc, bindVars, wantfields, callback)
    45  }