Skip to content

Commit

Permalink
fix: cloning of vindexpredicates
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Jun 7, 2023
1 parent c5333af commit 10591b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 0 additions & 4 deletions go/test/endtoend/vtgate/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/utils"
"vitess.io/vitess/go/vt/log"
)

func TestUnownedLookupInsertNull(t *testing.T) {
Expand Down Expand Up @@ -585,8 +584,5 @@ func TestJoinWithPredicateAndJoinOnDifferentVindex(t *testing.T) {
conn, closer := start(t)
defer closer()

qr := utils.Exec(t, conn, "vexplain select /*vt+ planner=gen4 */ t4.id1 from t4, t3 where t4.id2 = 'foo' and t4.id1 = t3.id6")
log.Errorf("plan: \n%s\n", qr.Rows[0][0].ToString())

utils.Exec(t, conn, "select t4.id1 from t4, t3 where t4.id2 = 'foo' and t4.id1 = t3.id6")
}
7 changes: 6 additions & 1 deletion go/vt/vtgate/planbuilder/operators/sharded_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"golang.org/x/exp/slices"

"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/slices2"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtgate/engine"
Expand Down Expand Up @@ -150,7 +151,11 @@ func (tr *ShardedRouting) Clone() Routing {
selected = &t
}
return &ShardedRouting{
VindexPreds: slices.Clone(tr.VindexPreds),
VindexPreds: slices2.Map(tr.VindexPreds, func(from *VindexPlusPredicates) *VindexPlusPredicates {
// we do this to create a copy of the struct
p := *from
return &p
}),
Selected: selected,
keyspace: tr.keyspace,
RouteOpCode: tr.RouteOpCode,
Expand Down

0 comments on commit 10591b9

Please sign in to comment.