// ExecuteBatch sends a batch query to VTTablet. func (conn *gRPCQueryClient) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, asTransaction bool, transactionID int64) (*tproto.QueryResultList, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &pb.ExecuteBatchRequest{ Queries: make([]*pb.BoundQuery, len(queries)), AsTransaction: asTransaction, TransactionId: transactionID, SessionId: conn.sessionID, } for i, q := range queries { req.Queries[i] = tproto.BoundQueryToProto3(q.Sql, q.BindVariables) } ebr, err := conn.c.ExecuteBatch(ctx, req) if err != nil { return nil, tabletErrorFromGRPC(err) } if ebr.Error != nil { return nil, tabletErrorFromRPCError(ebr.Error) } return tproto.Proto3ToQueryResultList(ebr.Results), nil }
// ExecuteBatch sends a batch query to VTTablet. func (conn *gRPCQueryClient) ExecuteBatch(ctx context.Context, queries []tproto.BoundQuery, asTransaction bool, transactionID int64) (*tproto.QueryResultList, error) { conn.mu.RLock() defer conn.mu.RUnlock() if conn.cc == nil { return nil, tabletconn.ConnClosed } req := &pb.ExecuteBatchRequest{ Target: conn.target, EffectiveCallerId: callerid.EffectiveCallerIDFromContext(ctx), ImmediateCallerId: callerid.ImmediateCallerIDFromContext(ctx), Queries: make([]*pb.BoundQuery, len(queries)), AsTransaction: asTransaction, TransactionId: transactionID, SessionId: conn.sessionID, } for i, q := range queries { qq, err := tproto.BoundQueryToProto3(q.Sql, q.BindVariables) if err != nil { return nil, err } req.Queries[i] = qq } ebr, err := conn.c.ExecuteBatch(ctx, req) if err != nil { return nil, tabletconn.TabletErrorFromGRPC(err) } return tproto.Proto3ToQueryResultList(ebr.Results), nil }