From 8fddb233bcd964756c85751ccc7c186010286c7e Mon Sep 17 00:00:00 2001 From: Austen Lacy Date: Tue, 9 Jan 2024 20:03:03 +0000 Subject: [PATCH] prototype Signed-off-by: Austen Lacy --- go/vt/vtgate/engine/vindex_lookup.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/go/vt/vtgate/engine/vindex_lookup.go b/go/vt/vtgate/engine/vindex_lookup.go index 816507ae086..7ed8b81254c 100644 --- a/go/vt/vtgate/engine/vindex_lookup.go +++ b/go/vt/vtgate/engine/vindex_lookup.go @@ -212,15 +212,19 @@ func (vr *VindexLookup) executeNonBatch(ctx context.Context, vcursor VCursor, id func (vr *VindexLookup) executeBatch(ctx context.Context, vcursor VCursor, ids []sqltypes.Value) ([]*sqltypes.Result, error) { results := make([]*sqltypes.Result, 0, len(ids)) // for integral types, batch query all ids and then map them back to the input order - vars, err := sqltypes.BuildBindVariable(ids) - if err != nil { - return nil, err + var idVars = make(map[string]*querypb.BindVariable, len(ids)) + for _, id := range ids { + idVars[id.ToString()] = sqltypes.ValueBindVariable(id) } - bindVars := map[string]*querypb.BindVariable{ - vr.Arguments[0]: vars, + + var bindVars = make(map[string]*querypb.BindVariable, len(vr.Arguments)) + + for _, arg := range vr.Arguments { + bindVars[arg] = idVars[arg] } var result *sqltypes.Result + var err error if vr.Vindex.AutoCommitEnabled() { result, err = vcursor.ExecutePrimitiveStandalone(ctx, vr.Lookup, bindVars, false) } else {