Skip to content

Commit

Permalink
wip - dirty implementation of findRoute for Values
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Jan 22, 2025
1 parent 491f190 commit b4f62e3
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 82 deletions.
36 changes: 18 additions & 18 deletions go/vt/vtgate/engine/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestDeleteUnsharded(t *testing.T) {
},
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestDeleteEqual(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestDeleteEqualMultiCol(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestDeleteEqualNoRoute(t *testing.T) {
},
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestDeleteEqualNoScatter(t *testing.T) {
},
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.EqualError(t, err, "cannot map vindex to unique keyspace id: DestinationKeyRange(-)")
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestDeleteOwnedVindex(t *testing.T) {
"1|4|5|6",
)}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.results = results

_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand All @@ -231,7 +231,7 @@ func TestDeleteOwnedVindex(t *testing.T) {
})

// No rows changing
vc = newDMLTestVCursor("-20", "20-")
vc = newTestVCursor("-20", "20-")
_, err = del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand All @@ -252,7 +252,7 @@ func TestDeleteOwnedVindex(t *testing.T) {
"1|4|5|6",
"1|7|8|9",
)}
vc = newDMLTestVCursor("-20", "20-")
vc = newTestVCursor("-20", "20-")
vc.results = results

_, err = del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestDeleteOwnedVindexMultiCol(t *testing.T) {
"1|2|4",
)}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.results = results

_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand Down Expand Up @@ -371,7 +371,7 @@ func TestDeleteSharded(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -399,7 +399,7 @@ func TestDeleteShardedStreaming(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
err := del.TryStreamExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false, func(result *sqltypes.Result) error {
return nil
})
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestDeleteScatterOwnedVindex(t *testing.T) {
"1|4|5|6",
)}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.results = results

_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand All @@ -453,7 +453,7 @@ func TestDeleteScatterOwnedVindex(t *testing.T) {
})

// No rows changing
vc = newDMLTestVCursor("-20", "20-")
vc = newTestVCursor("-20", "20-")

_, err = del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
Expand All @@ -475,7 +475,7 @@ func TestDeleteScatterOwnedVindex(t *testing.T) {
"1|4|5|6",
"1|7|8|9",
)}
vc = newDMLTestVCursor("-20", "20-")
vc = newTestVCursor("-20", "20-")
vc.results = results

_, err = del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand Down Expand Up @@ -528,7 +528,7 @@ func TestDeleteInChangedVindexMultiCol(t *testing.T) {
"1|3|6",
"2|3|7",
)}
vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.results = results

_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
Expand Down Expand Up @@ -565,7 +565,7 @@ func TestDeleteEqualSubshard(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.shardForKsid = []string{"-20", "20-"}
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
Expand Down Expand Up @@ -602,7 +602,7 @@ func TestDeleteMultiEqual(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.shardForKsid = []string{"-20", "20-"}
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
Expand Down Expand Up @@ -635,7 +635,7 @@ func TestDeleteInUnique(t *testing.T) {
Type: querypb.Type_TUPLE,
Values: append([]*querypb.Value{sqltypes.ValueToProto(sqltypes.NewInt64(1))}, sqltypes.ValueToProto(sqltypes.NewInt64(2)), sqltypes.ValueToProto(sqltypes.NewInt64(4))),
}
vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.shardForKsid = []string{"-20", "20-"}
_, err := upd.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{"__vals": tupleBV}, false)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vtgate/engine/dml_with_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestDeleteWithInputSingleOffset(t *testing.T) {
OutputCols: [][]int{{0}},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestDeleteWithInputMultiOffset(t *testing.T) {
OutputCols: [][]int{{1, 0}},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestDeleteWithMultiTarget(t *testing.T) {
OutputCols: [][]int{{0}, {1, 2}},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
_, err := del.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, false)
require.NoError(t, err)
vc.ExpectLog(t, []string{
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestUpdateWithInputNonLiteral(t *testing.T) {
},
}

vc := newDMLTestVCursor("-20", "20-")
vc := newTestVCursor("-20", "20-")
vc.results = []*sqltypes.Result{
{RowsAffected: 1}, {RowsAffected: 1}, {RowsAffected: 1},
}
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/engine/fk_cascade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestDeleteCascade(t *testing.T) {
Parent: parentP,
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.NoError(t, err)
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestUpdateCascade(t *testing.T) {
Parent: parentP,
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.NoError(t, err)
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestNonLiteralUpdateCascade(t *testing.T) {
Parent: parentP,
}

vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/engine/fk_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestFKVerifyUpdate(t *testing.T) {

t.Run("foreign key verification success", func(t *testing.T) {
fakeRes := sqltypes.MakeTestResult(sqltypes.MakeTestFields("1", "int64"))
vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.NoError(t, err)
Expand All @@ -83,7 +83,7 @@ func TestFKVerifyUpdate(t *testing.T) {
t.Run("parent foreign key verification failure", func(t *testing.T) {
// No results from select, should cause the foreign key verification to fail.
fakeRes := sqltypes.MakeTestResult(sqltypes.MakeTestFields("1", "int64"), "1", "1", "1")
vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.ErrorContains(t, err, "Cannot add or update a child row: a foreign key constraint fails")
Expand All @@ -105,7 +105,7 @@ func TestFKVerifyUpdate(t *testing.T) {
t.Run("child foreign key verification failure", func(t *testing.T) {
// No results from select, should cause the foreign key verification to fail.
fakeRes := sqltypes.MakeTestResult(sqltypes.MakeTestFields("1", "int64"), "1", "1", "1")
vc := newDMLTestVCursor("0")
vc := newTestVCursor("0")
vc.results = []*sqltypes.Result{fakeRes}
_, err := fkc.TryExecute(context.Background(), vc, map[string]*querypb.BindVariable{}, true)
require.ErrorContains(t, err, "Cannot delete or update a parent row: a foreign key constraint fails")
Expand Down
Loading

0 comments on commit b4f62e3

Please sign in to comment.