From 5d7ded7d5e9668505d6b350e6bb3060b71b86f48 Mon Sep 17 00:00:00 2001 From: Alain Jobart Date: Tue, 17 Nov 2015 10:52:54 -0800 Subject: [PATCH] Retiring deprecated vtgate/proto.QueryResult.Error. I'm about to make more changes and this was in the way. --- go/cmd/vtgateclienttest/services/errors.go | 3 --- go/vt/client/fakeserver_test.go | 5 ----- go/vt/vtgate/proto/vtgate_proto.go | 10 ++-------- go/vt/vtgate/vtgate.go | 17 ++++++++--------- go/vt/vtgate/vtgateconntest/client.go | 10 ++-------- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/go/cmd/vtgateclienttest/services/errors.go b/go/cmd/vtgateclienttest/services/errors.go index 1d83efe097d..28395ac24bd 100644 --- a/go/cmd/vtgateclienttest/services/errors.go +++ b/go/cmd/vtgateclienttest/services/errors.go @@ -68,7 +68,6 @@ func requestToPartialError(request string, session *vtgatepb.Session, reply *pro parts := strings.Split(request, "/") rpcErr := vterrors.RPCErrFromVtError(trimmedRequestToError(parts[0])) reply.Err = rpcErr - reply.Error = rpcErr.Message reply.Session = session if len(parts) > 1 && parts[1] == "close transaction" { reply.Session.InTransaction = false @@ -175,7 +174,6 @@ func (c *errorClient) ExecuteBatchShards(ctx context.Context, queries []*vtgatep var partialReply proto.QueryResult if requestToPartialError(queries[0].Query.Sql, session, &partialReply) { reply.Err = partialReply.Err - reply.Error = partialReply.Error reply.Session = partialReply.Session return nil } @@ -191,7 +189,6 @@ func (c *errorClient) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vt var partialReply proto.QueryResult if requestToPartialError(queries[0].Query.Sql, session, &partialReply) { reply.Err = partialReply.Err - reply.Error = partialReply.Error reply.Session = partialReply.Session return nil } diff --git a/go/vt/client/fakeserver_test.go b/go/vt/client/fakeserver_test.go index 722de373551..e95a646b9e9 100644 --- a/go/vt/client/fakeserver_test.go +++ b/go/vt/client/fakeserver_test.go @@ -97,9 +97,6 @@ func (f *fakeVTGateService) StreamExecute(ctx context.Context, sql string, bindV } } } - if execCase.reply.Error != "" { - return errors.New(execCase.reply.Error) - } return nil } @@ -195,7 +192,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: &result1, Session: nil, - Error: "", }, }, "txRequest": { @@ -220,7 +216,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: &sqltypes.Result{}, Session: session2, - Error: "", }, }, } diff --git a/go/vt/vtgate/proto/vtgate_proto.go b/go/vt/vtgate/proto/vtgate_proto.go index 44de16fbea8..84bfc1a3c4d 100644 --- a/go/vt/vtgate/proto/vtgate_proto.go +++ b/go/vt/vtgate/proto/vtgate_proto.go @@ -85,10 +85,7 @@ type EntityIdsQuery struct { type QueryResult struct { Result *sqltypes.Result Session *pb.Session - // Error field is deprecated, as it only returns a string. New users should use the - // Err field below, which contains a string and an error code. - Error string - Err *mproto.RPCError + Err *mproto.RPCError } // BoundShardQuery represents a single query request for the @@ -133,10 +130,7 @@ type KeyspaceIdBatchQuery struct { type QueryResultList struct { List []sqltypes.Result Session *pb.Session - // Error field is deprecated, as it only returns a string. New users should use the - // Err field below, which contains a string and an error code. - Error string - Err *mproto.RPCError + Err *mproto.RPCError } // SplitQueryRequest is a request to split a query into multiple parts diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 028f25f8881..69989cd0df5 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -180,7 +180,7 @@ func (vtg *VTGate) Execute(ctx context.Context, sql string, bindVariables map[st "Session": session, "NotInTransaction": notInTransaction, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecute).Error() + handleExecuteError(err, statsKey, query, vtg.logExecute) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -226,7 +226,7 @@ func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables "Session": session, "NotInTransaction": notInTransaction, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteShards).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteShards) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -261,7 +261,7 @@ func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVaria "Session": session, "NotInTransaction": notInTransaction, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteKeyspaceIds).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteKeyspaceIds) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -296,7 +296,7 @@ func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariabl "Session": session, "NotInTransaction": notInTransaction, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteKeyRanges).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteKeyRanges) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -332,7 +332,7 @@ func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariabl "Session": session, "NotInTransaction": notInTransaction, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteEntityIds).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteEntityIds) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -375,7 +375,7 @@ func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.B "AsTransaction": asTransaction, "Session": session, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchShards).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteBatchShards) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -416,7 +416,7 @@ func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgat "AsTransaction": asTransaction, "Session": session, } - reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchKeyspaceIds).Error() + handleExecuteError(err, statsKey, query, vtg.logExecuteBatchKeyspaceIds) reply.Err = vterrors.RPCErrFromVtError(err) } reply.Session = session @@ -709,7 +709,7 @@ func isErrorCausedByVTGate(err error) bool { return false } -func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) error { +func handleExecuteError(err error, statsKey []string, query map[string]interface{}, logger *logutil.ThrottledLogger) { s := fmt.Sprintf(", vtgate: %v", servenv.ListeningURL.String()) newErr := vterrors.WithSuffix(err, s) errStr := newErr.Error() @@ -723,7 +723,6 @@ func handleExecuteError(err error, statsKey []string, query map[string]interface normalErrors.Add(statsKey, 1) logError(err, query, logger) } - return newErr } func formatError(err error) error { diff --git a/go/vt/vtgate/vtgateconntest/client.go b/go/vt/vtgate/vtgateconntest/client.go index eb53a987eb1..7326d9e4bd2 100644 --- a/go/vt/vtgate/vtgateconntest/client.go +++ b/go/vt/vtgate/vtgateconntest/client.go @@ -310,9 +310,8 @@ func (f *fakeVTGateService) ExecuteBatchShards(ctx context.Context, queries []*v f.t.Errorf("ExecuteBatchShards: %+v, want %+v", query, execCase.batchQueryShard) return nil } - reply.Error = execCase.reply.Error reply.Err = execCase.reply.Err - if reply.Error == "" && execCase.reply.Result != nil { + if execCase.reply.Result != nil { reply.List = []sqltypes.Result{*execCase.reply.Result} } reply.Session = execCase.reply.Session @@ -351,9 +350,8 @@ func (f *fakeVTGateService) ExecuteBatchKeyspaceIds(ctx context.Context, queries f.t.Errorf("ExecuteBatchKeyspaceIds: %+v, want %+v", query, execCase.keyspaceIDBatchQuery) return nil } - reply.Error = execCase.reply.Error reply.Err = execCase.reply.Err - if reply.Error == "" && execCase.reply.Result != nil { + if execCase.reply.Result != nil { reply.List = []sqltypes.Result{*execCase.reply.Result} } reply.Session = execCase.reply.Session @@ -2387,7 +2385,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: &result1, Session: nil, - Error: "", }, }, "errorRequst": { @@ -2498,7 +2495,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: nil, Session: nil, - Error: executePartialErrString, Err: &mproto.RPCError{ Code: int64(expectedCode), Message: executePartialErrString, @@ -2613,7 +2609,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: nil, Session: session2, - Error: "", }, }, "txRequestNIT": { @@ -2729,7 +2724,6 @@ var execMap = map[string]struct { reply: &proto.QueryResult{ Result: nil, Session: session1, - Error: "", }, }, }