// StreamExecute2 should not be used by anything other than tests. // It will eventually replace Rollback, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) StreamExecute2(ctx context.Context, req *proto.StreamExecuteRequest, sendReply func(reply interface{}) error) (err error) { defer sq.server.HandlePanic(&err) if req == nil || req.Query == nil { return nil } ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID), callerid.GoRPCImmediateCallerID(req.ImmediateCallerID), ) tErr := sq.server.StreamExecute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req.Query, func(reply *mproto.QueryResult) error { return sendReply(reply) }) if tErr == nil { return nil } if *tabletserver.RPCErrorOnlyInReply { // If there was an app error, send a QueryResult back with it. qr := new(mproto.QueryResult) tabletserver.AddTabletErrorToQueryResult(tErr, qr) // Sending back errors this way is not backwards compatible. If a (new) server sends an additional // QueryResult with an error, and the (old) client doesn't know how to read it, it will cause // problems where the client will get out of sync with the number of QueryResults sent. // That's why this the error is only sent this way when the --rpc_errors_only_in_reply flag is set // (signalling that all clients are able to handle new-style errors). return sendReply(qr) } return tErr }
// SplitQuery is exposing tabletserver.SqlQuery.SplitQuery func (sq *SqlQuery) SplitQuery(ctx context.Context, req *proto.SplitQueryRequest, reply *proto.SplitQueryResult) (err error) { defer sq.server.HandlePanic(&err) ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID), callerid.GoRPCImmediateCallerID(req.ImmediateCallerID), ) tErr := sq.server.SplitQuery(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req, reply) tabletserver.AddTabletError(tErr, &reply.Err) return nil }
// Execute2 should not be used by anything other than tests // It will eventually replace Execute, but it breaks compatibility with older clients // Once all clients are upgraded, it can be replaced func (sq *SqlQuery) Execute2(ctx context.Context, executeRequest *proto.ExecuteRequest, reply *mproto.QueryResult) (err error) { defer sq.server.HandlePanic(&err) ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(executeRequest.EffectiveCallerID), callerid.GoRPCImmediateCallerID(executeRequest.ImmediateCallerID), ) tErr := sq.server.Execute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(executeRequest.Target), &executeRequest.QueryRequest, reply) tabletserver.AddTabletError(tErr, &reply.Err) return nil }
// ExecuteBatch2 should not be used by anything other than tests // It will eventually replace ExecuteBatch, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) ExecuteBatch2(ctx context.Context, req *proto.ExecuteBatchRequest, reply *proto.QueryResultList) (err error) { defer sq.server.HandlePanic(&err) if req == nil { return nil } ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID), callerid.GoRPCImmediateCallerID(req.ImmediateCallerID), ) tErr := sq.server.ExecuteBatch(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), &req.QueryBatch, reply) tabletserver.AddTabletError(tErr, &reply.Err) return nil }
// Commit2 should not be used by anything other than tests. // It will eventually replace Commit, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) Commit2(ctx context.Context, commitRequest *proto.CommitRequest, commitResponse *proto.CommitResponse) (err error) { defer sq.server.HandlePanic(&err) session := &proto.Session{ SessionId: commitRequest.SessionId, TransactionId: commitRequest.TransactionId, } ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(commitRequest.EffectiveCallerID), callerid.GoRPCImmediateCallerID(commitRequest.ImmediateCallerID), ) tErr := sq.server.Commit(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(commitRequest.Target), session) tabletserver.AddTabletError(tErr, &commitResponse.Err) return nil }
// Begin2 should not be used by anything other than tests. // It will eventually replace Begin, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) Begin2(ctx context.Context, beginRequest *proto.BeginRequest, beginResponse *proto.BeginResponse) (err error) { defer sq.server.HandlePanic(&err) session := &proto.Session{ SessionId: beginRequest.SessionId, } txInfo := new(proto.TransactionInfo) ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(beginRequest.EffectiveCallerID), callerid.GoRPCImmediateCallerID(beginRequest.ImmediateCallerID), ) tErr := sq.server.Begin(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(beginRequest.Target), session, txInfo) // Convert from TxInfo => beginResponse for the output beginResponse.TransactionId = txInfo.TransactionId tabletserver.AddTabletError(tErr, &beginResponse.Err) return nil }
// Rollback2 should not be used by anything other than tests. // It will eventually replace Rollback, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) Rollback2(ctx context.Context, rollbackRequest *proto.RollbackRequest, rollbackResponse *proto.RollbackResponse) (err error) { defer sq.server.HandlePanic(&err) session := &proto.Session{ SessionId: rollbackRequest.SessionId, TransactionId: rollbackRequest.TransactionId, } ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(rollbackRequest.EffectiveCallerID), callerid.GoRPCImmediateCallerID(rollbackRequest.ImmediateCallerID), ) tErr := sq.server.Rollback(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(rollbackRequest.Target), session) tabletserver.AddTabletErrorToRollbackResponse(tErr, rollbackResponse) if *tabletserver.RPCErrorOnlyInReply { return nil } return tErr }
// StreamExecute2 should not be used by anything other than tests. // It will eventually replace Rollback, but it breaks compatibility with older clients. // Once all clients are upgraded, it can be replaced. func (sq *SqlQuery) StreamExecute2(ctx context.Context, req *proto.StreamExecuteRequest, sendReply func(reply interface{}) error) (err error) { defer sq.server.HandlePanic(&err) if req == nil || req.Query == nil { return nil } ctx = callerid.NewContext(ctx, callerid.GoRPCEffectiveCallerID(req.EffectiveCallerID), callerid.GoRPCImmediateCallerID(req.ImmediateCallerID), ) tErr := sq.server.StreamExecute(callinfo.RPCWrapCallInfo(ctx), proto.TargetToProto3(req.Target), req.Query, func(reply *mproto.QueryResult) error { return sendReply(reply) }) if tErr == nil { return nil } // If there was an app error, send a QueryResult back with it. qr := new(mproto.QueryResult) tabletserver.AddTabletError(tErr, &qr.Err) return sendReply(qr) }