Esempio n. 1
0
// 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
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
// 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
}
Esempio n. 4
0
// 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
}
Esempio n. 5
0
// 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
}
Esempio n. 6
0
// 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)
}
Esempio n. 7
0
// Begin is exposing tabletserver.SqlQuery.Begin
func (sq *SqlQuery) Begin(ctx context.Context, session *proto.Session, txInfo *proto.TransactionInfo) (err error) {
	defer sq.server.HandlePanic(&err)
	tErr := sq.server.Begin(callinfo.RPCWrapCallInfo(ctx), nil, session, txInfo)
	tabletserver.AddTabletError(tErr, &txInfo.Err)
	return nil
}
Esempio n. 8
0
// GetSessionId2 should not be used by anything other than tests.
// It will eventually replace GetSessionId, but it breaks compatibility with older clients.
// Once all clients are upgraded, it can be replaced.
func (sq *SqlQuery) GetSessionId2(sessionIdReq *proto.GetSessionIdRequest, sessionInfo *proto.SessionInfo) (err error) {
	defer sq.server.HandlePanic(&err)
	tErr := sq.server.GetSessionId(&sessionIdReq.Params, sessionInfo)
	tabletserver.AddTabletError(tErr, &sessionInfo.Err)
	return nil
}
Esempio n. 9
0
// ExecuteBatch is exposing tabletserver.SqlQuery.ExecuteBatch
func (sq *SqlQuery) ExecuteBatch(ctx context.Context, queryList *proto.QueryList, reply *proto.QueryResultList) (err error) {
	defer sq.server.HandlePanic(&err)
	tErr := sq.server.ExecuteBatch(callinfo.RPCWrapCallInfo(ctx), nil, queryList, reply)
	tabletserver.AddTabletError(tErr, &reply.Err)
	return nil
}