Skip to content

Commit

Permalink
Adds supports to target DestinationKeyspaceID to handle other
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Chacon <[email protected]>
  • Loading branch information
rafael committed Apr 9, 2020
1 parent 4cd578d commit f1c50b1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,15 @@ func (e *Executor) handleOther(ctx context.Context, safeSession *SafeSession, sq
}

switch dest.(type) {
case key.DestinationKeyspaceID:
rss, err := e.resolver.resolver.ResolveDestination(ctx, destKeyspace, destTabletType, dest)
if err != nil {
return nil, err
}
if len(rss) != 1 {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "Unexpected error, DestinationKeyspaceID mapping to multiple shards: %s, got: %v", sql, dest)
}
destKeyspace, dest = rss[0].Target.Keyspace, key.DestinationShard(rss[0].Target.Shard)
case key.DestinationShard:
// noop
default:
Expand Down
16 changes: 16 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,22 @@ func TestExecutorOther(t *testing.T) {
SbcLookupCnt: 0,
},
},
{
targetStr: "TestExecutor/-20",
wantCnts: cnts{
Sbc1Cnt: 1,
Sbc2Cnt: 0,
SbcLookupCnt: 0,
},
},
{
targetStr: "TestExecutor[00]",
wantCnts: cnts{
Sbc1Cnt: 1,
Sbc2Cnt: 0,
SbcLookupCnt: 0,
},
},
}

stmts := []string{
Expand Down

0 comments on commit f1c50b1

Please sign in to comment.