Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions go/vt/vtgate/engine/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ func (s *Send) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.BindV

// GetFields implements Primitive interface
func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
// We don't need to worry about GetFields being needed for joins since the Send primitive currently doesn't
// get nested with other types of primitives.
// However, GetFields is used for prepared statements. Because of that, prepared statements are not yet
// compatible with the Send primitive.
//
// TODO: implement this
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable")
qr, err := s.Execute(vcursor, bindVars, false)
if err != nil {
return nil, vterrors.Wrap(err, "sendGetFields")
}
qr.Rows = nil
return qr, nil
}

func (s *Send) description() PrimitiveDescription {
Expand Down
33 changes: 33 additions & 0 deletions go/vt/vtgate/engine/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"errors"
"testing"

"vitess.io/vitess/go/sqltypes"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/vt/key"
Expand Down Expand Up @@ -264,3 +266,34 @@ func TestSendTable_StreamExecute(t *testing.T) {
})
}
}

func TestSendGetFields(t *testing.T) {
results := []*sqltypes.Result{sqltypes.MakeTestResult(
sqltypes.MakeTestFields(
"id|c1|c2|c3",
"int64|int64|int64|int64",
),
"1|4|5|6",
"2|7|8|9",
)}

send := &Send{
Keyspace: &vindexes.Keyspace{
Name: "ks",
Sharded: true,
},
Query: "dummy_query",
TargetDestination: key.DestinationAllShards{},
IsDML: true,
SingleShardOnly: false,
}
vc := &loggingVCursor{shards: []string{"-20", "20-"}, results: results}
qr, err := send.GetFields(vc, map[string]*querypb.BindVariable{})
require.NoError(t, err)
vc.ExpectLog(t, []string{
`ResolveDestinations ks [] Destinations:DestinationAllShards()`,
`ExecuteMultiShard ks.-20: dummy_query {} ks.20-: dummy_query {} true false`,
})
require.Nil(t, qr.Rows)
require.Equal(t, 4, len(qr.Fields))
}