Skip to content

Commit

Permalink
Merge pull request #5940 from planetscale/ss-deprecation
Browse files Browse the repository at this point in the history
tabletserver: SBR deprecation
  • Loading branch information
harshit-gangal authored Mar 20, 2020
2 parents 6a05183 + ac2567f commit 7a5af87
Show file tree
Hide file tree
Showing 57 changed files with 1,733 additions and 6,142 deletions.
25 changes: 2 additions & 23 deletions go/cmd/vtgateclienttest/goclienttest/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,10 @@ var (
callerID = callerid.NewEffectiveCallerID("test_principal", "test_component", "test_subcomponent")
callerIDEcho = "principal:\"test_principal\" component:\"test_component\" subcomponent:\"test_subcomponent\" "

eventToken = &querypb.EventToken{
Timestamp: 876543,
Shard: shards[0],
Position: "test_position",
}
eventTokenEcho = "timestamp:876543 shard:\"-80\" position:\"test_position\" "

options = &querypb.ExecuteOptions{
IncludedFields: querypb.ExecuteOptions_TYPE_ONLY,
IncludeEventToken: true,
CompareEventToken: eventToken,
IncludedFields: querypb.ExecuteOptions_TYPE_ONLY,
}
optionsEcho = "include_event_token:true compare_event_token:<" + eventTokenEcho + "> included_fields:TYPE_ONLY "
extrasEcho = "event_token:<" + eventTokenEcho + "> fresher:true "
optionsEcho = "included_fields:TYPE_ONLY "
)

// testEcho exercises the test cases provided by the "echo" service.
Expand Down Expand Up @@ -130,7 +120,6 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn, session *vtgatec
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"options": optionsEcho,
"extras": extrasEcho,
})

qr, err = conn.ExecuteKeyspaceIds(ctx, echoPrefix+query, keyspace, keyspaceIDs, bindVars, tabletType, options)
Expand All @@ -142,7 +131,6 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn, session *vtgatec
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"options": optionsEcho,
"extras": extrasEcho,
})

qr, err = conn.ExecuteKeyRanges(ctx, echoPrefix+query, keyspace, keyRanges, bindVars, tabletType, options)
Expand All @@ -154,7 +142,6 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn, session *vtgatec
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"options": optionsEcho,
"extras": extrasEcho,
})

qr, err = conn.ExecuteEntityIds(ctx, echoPrefix+query, keyspace, "column1", entityKeyspaceIDs, bindVars, tabletType, options)
Expand All @@ -167,7 +154,6 @@ func testEchoExecute(t *testing.T, conn *vtgateconn.VTGateConn, session *vtgatec
"bindVars": bindVarsEcho,
"tabletType": tabletTypeEcho,
"options": optionsEcho,
"extras": extrasEcho,
})

var qrs []sqltypes.Result
Expand Down Expand Up @@ -418,13 +404,6 @@ func checkEcho(t *testing.T, name string, qr *sqltypes.Result, err error, want m
}
got := getEcho(qr)
for k, v := range want {
if k == "extras" {
gotExtras := qr.Extras.String()
if gotExtras != v {
t.Errorf("%v: extras = \n%q, want \n%q", name, gotExtras, v)
}
continue
}
if got[k].ToString() != v {
t.Errorf("%v: %v = \n%q, want \n%q", name, k, got[k], v)
}
Expand Down
10 changes: 0 additions & 10 deletions go/cmd/vtgateclienttest/services/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ func echoQueryResult(vals map[string]interface{}) *sqltypes.Result {
}
qr.Rows = [][]sqltypes.Value{row}

if options, ok := vals["options"]; ok {
o := options.(*querypb.ExecuteOptions)
if o != nil && o.CompareEventToken != nil {
qr.Extras = &querypb.ResultExtras{
Fresher: true,
EventToken: o.CompareEventToken,
}
}
}

return qr
}

Expand Down
7 changes: 0 additions & 7 deletions go/mysql/fakesqldb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,6 @@ func (db *DB) NewConnection(c *mysql.Conn) {
db.mu.Lock()
defer db.mu.Unlock()

if db.t != nil {
db.t.Logf("NewConnection(%v): client %v", db.name, c.ConnectionID)
}

if db.isConnFail {
panic(fmt.Errorf("simulating a connection failure"))
}
Expand Down Expand Up @@ -336,9 +332,6 @@ func (db *DB) HandleQuery(c *mysql.Conn, query string, callback func(*sqltypes.R
return callback(&sqltypes.Result{})
}

if db.t != nil {
db.t.Logf("ComQuery(%v): client %v: %v", db.name, c.ConnectionID, query)
}
if db.orderMatters {
result, err := db.comQueryOrdered(query)
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions go/sqltypes/proto3.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func ResultToProto3(qr *Result) *querypb.QueryResult {
RowsAffected: qr.RowsAffected,
InsertId: qr.InsertID,
Rows: RowsToProto3(qr.Rows),
Extras: qr.Extras,
}
}

Expand All @@ -105,7 +104,6 @@ func Proto3ToResult(qr *querypb.QueryResult) *Result {
RowsAffected: qr.RowsAffected,
InsertID: qr.InsertId,
Rows: proto3ToRows(qr.Fields, qr.Rows),
Extras: qr.Extras,
}
}

Expand All @@ -121,7 +119,6 @@ func CustomProto3ToResult(fields []*querypb.Field, qr *querypb.QueryResult) *Res
RowsAffected: qr.RowsAffected,
InsertID: qr.InsertId,
Rows: proto3ToRows(fields, qr.Rows),
Extras: qr.Extras,
}
}

Expand Down
70 changes: 0 additions & 70 deletions go/sqltypes/proto3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ func TestResult(t *testing.T) {
NULL,
NULL,
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
}
p3Result := &querypb.QueryResult{
Fields: fields,
Expand All @@ -68,13 +61,6 @@ func TestResult(t *testing.T) {
Lengths: []int64{2, -1, -1},
Values: []byte("bb"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
}
p3converted := ResultToProto3(sqlResult)
if !proto.Equal(p3converted, p3Result) {
Expand Down Expand Up @@ -125,13 +111,6 @@ func TestResults(t *testing.T) {
TestValue(Int64, "1"),
TestValue(Float64, "2"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
}, {
Fields: fields2,
InsertID: 3,
Expand All @@ -141,13 +120,6 @@ func TestResults(t *testing.T) {
TestValue(Int64, "3"),
TestValue(Float64, "4"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard1",
Position: "position1",
},
},
}}
p3Results := []*querypb.QueryResult{{
Fields: fields1,
Expand All @@ -157,13 +129,6 @@ func TestResults(t *testing.T) {
Lengths: []int64{2, 1, 1},
Values: []byte("aa12"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
}, {
Fields: fields2,
InsertId: 3,
Expand All @@ -172,13 +137,6 @@ func TestResults(t *testing.T) {
Lengths: []int64{2, 1, 1},
Values: []byte("bb34"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard1",
Position: "position1",
},
},
}}
p3converted := ResultsToProto3(sqlResults)
if !Proto3ResultsEqual(p3converted, p3Results) {
Expand Down Expand Up @@ -224,13 +182,6 @@ func TestQueryReponses(t *testing.T) {
TestValue(Int64, "1"),
TestValue(Float64, "2"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
},
QueryError: nil,
}, {
Expand All @@ -243,13 +194,6 @@ func TestQueryReponses(t *testing.T) {
TestValue(Int64, "3"),
TestValue(Float64, "4"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard1",
Position: "position1",
},
},
},
QueryError: nil,
}, {
Expand All @@ -269,13 +213,6 @@ func TestQueryReponses(t *testing.T) {
Lengths: []int64{2, 1, 1},
Values: []byte("aa12"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard0",
Position: "position0",
},
},
},
}, {
Error: nil,
Expand All @@ -287,13 +224,6 @@ func TestQueryReponses(t *testing.T) {
Lengths: []int64{2, 1, 1},
Values: []byte("bb34"),
}},
Extras: &querypb.ResultExtras{
EventToken: &querypb.EventToken{
Timestamp: 123,
Shard: "shard1",
Position: "position1",
},
},
},
}, {
Error: &vtrpcpb.RPCError{
Expand Down
63 changes: 6 additions & 57 deletions go/sqltypes/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import (

// Result represents a query result.
type Result struct {
Fields []*querypb.Field `json:"fields"`
RowsAffected uint64 `json:"rows_affected"`
InsertID uint64 `json:"insert_id"`
Rows [][]Value `json:"rows"`
Extras *querypb.ResultExtras `json:"extras"`
Fields []*querypb.Field `json:"fields"`
RowsAffected uint64 `json:"rows_affected"`
InsertID uint64 `json:"insert_id"`
Rows [][]Value `json:"rows"`
}

// ResultStream is an interface for receiving Result. It is used for
Expand Down Expand Up @@ -74,18 +73,6 @@ func (result *Result) Copy() *Result {
out.Rows = append(out.Rows, CopyRow(r))
}
}
if result.Extras != nil {
out.Extras = &querypb.ResultExtras{
Fresher: result.Extras.Fresher,
}
if result.Extras.EventToken != nil {
out.Extras.EventToken = &querypb.EventToken{
Timestamp: result.Extras.EventToken.Timestamp,
Shard: result.Extras.EventToken.Shard,
Position: result.Extras.EventToken.Position,
}
}
}
return out
}

Expand Down Expand Up @@ -118,18 +105,6 @@ func (result *Result) Truncate(l int) *Result {
out.Rows = append(out.Rows, r[:l])
}
}
if result.Extras != nil {
out.Extras = &querypb.ResultExtras{
Fresher: result.Extras.Fresher,
}
if result.Extras.EventToken != nil {
out.Extras.EventToken = &querypb.EventToken{
Timestamp: result.Extras.EventToken.Timestamp,
Shard: result.Extras.EventToken.Shard,
Position: result.Extras.EventToken.Position,
}
}
}
return out
}

Expand Down Expand Up @@ -158,12 +133,11 @@ func (result *Result) Equal(other *Result) bool {
return false
}

// Compare Fields, RowsAffected, InsertID, Rows, Extras.
// Compare Fields, RowsAffected, InsertID, Rows.
return FieldsEqual(result.Fields, other.Fields) &&
result.RowsAffected == other.RowsAffected &&
result.InsertID == other.InsertID &&
reflect.DeepEqual(result.Rows, other.Rows) &&
proto.Equal(result.Extras, other.Extras)
reflect.DeepEqual(result.Rows, other.Rows)
}

// ResultsEqual compares two arrays of Result.
Expand Down Expand Up @@ -242,30 +216,5 @@ func (result *Result) AppendResult(src *Result) {
if src.InsertID != 0 {
result.InsertID = src.InsertID
}
if len(result.Rows) == 0 {
// we haven't gotten any result yet, just save the new extras.
result.Extras = src.Extras
} else {
// Merge the EventTokens / Fresher flags within Extras.
if src.Extras == nil {
// We didn't get any from innerq. Have to clear any
// we'd have gotten already.
if result.Extras != nil {
result.Extras.EventToken = nil
result.Extras.Fresher = false
}
} else {
// We may have gotten an EventToken from
// innerqr. If we also got one earlier, merge
// it. If we didn't get one earlier, we
// discard the new one.
if result.Extras != nil {
// Note if any of the two is nil, we get nil.
result.Extras.EventToken = EventTokenMinimum(result.Extras.EventToken, src.Extras.EventToken)

result.Extras.Fresher = result.Extras.Fresher && src.Extras.Fresher
}
}
}
result.Rows = append(result.Rows, src.Rows...)
}
Loading

0 comments on commit 7a5af87

Please sign in to comment.