Repository: vitessio/vitess
Pull request #6572 (2020-08-14 20:58:06)

Forward Port 6554 to 7.0 from 6.0
Forward port from 6.0: #6554 


Patch:
diff --git a/go/vt/vtgate/planbuilder/builder.go b/go/vt/vtgate/planbuilder/builder.go
index e9d547613c..6b73b22be8 100644
--- a/go/vt/vtgate/planbuilder/builder.go
+++ b/go/vt/vtgate/planbuilder/builder.go
@@ -132,7 +132,6 @@ type ContextVSchema interface {
 	TargetDestination(qualifier string) (key.Destination, *vindexes.Keyspace, topodatapb.TabletType, error)
 	AnyKeyspace() (*vindexes.Keyspace, error)
 	FirstSortedKeyspace() (*vindexes.Keyspace, error)
-	SysVarSetEnabled() bool
 }
 
 //-------------------------------------------------------------------------
diff --git a/go/vt/vtgate/planbuilder/dml.go b/go/vt/vtgate/planbuilder/dml.go
index 67da3070e3..7fcd57983e 100644
--- a/go/vt/vtgate/planbuilder/dml.go
+++ b/go/vt/vtgate/planbuilder/dml.go
@@ -146,19 +146,20 @@ func buildDMLPlan(vschema ContextVSchema, dmlType string, stmt sqlparser.Stateme
 		return nil, nil, "", vterrors.New(vtrpcpb.Code_INTERNAL, "internal error: table.vindexTable is mysteriously nil")
 	}
 
+	routingType, ksidVindex, ksidCol, vindex, values, err := getDMLRouting(where, eupd.Table)
+	if err != nil {
+		return nil, nil, "", err
+	}
+
 	if ro.eroute.TargetDestination != nil {
 		if ro.eroute.TargetTabletType != topodatapb.TabletType_MASTER {
 			return nil, nil, "", vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "unsupported: %s statement with a replica target", dmlType)
 		}
 		eupd.Opcode = engine.ByDestination
 		eupd.TargetDestination = ro.eroute.TargetDestination
-		return eupd, nil, "", nil
+		return eupd, ksidVindex, ksidCol, nil
 	}
 
-	routingType, ksidVindex, ksidCol, vindex, values, err := getDMLRouting(where, eupd.Table)
-	if err != nil {
-		return nil, nil, "", err
-	}
 	eupd.Opcode = routingType
 	if routingType == engine.Scatter {
 		if limit != nil {
diff --git a/go/vt/vtgate/planbuilder/set.go b/go/vt/vtgate/planbuilder/set.go
index fc98c55189..8800df0078 100644
--- a/go/vt/vtgate/planbuilder/set.go
+++ b/go/vt/vtgate/planbuilder/set.go
@@ -351,9 +351,6 @@ func expressionOkToDelegateToTablet(e sqlparser.Expr) bool {
 }
 
 func buildSetOpVarSet(expr *sqlparser.SetExpr, vschema ContextVSchema) (engine.SetOp, error) {
-	if !vschema.SysVarSetEnabled() {
-		return buildSetOpCheckAndIgnore(expr, vschema)
-	}
 	ks, err := vschema.AnyKeyspace()
 	if err != nil {
 		return nil, err
diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go
index 05b155f0cc..c90b3b913d 100644
--- a/go/vt/vtgate/vcursor_impl.go
+++ b/go/vt/vtgate/vcursor_impl.go
@@ -467,10 +467,6 @@ func (vc *vcursorImpl) TargetDestination(qualifier string) (key.Destination, *vi
 	return vc.destination, keyspace.Keyspace, vc.tabletType, nil
 }
 
-func (vc *vcursorImpl) SysVarSetEnabled() bool {
-	return *sysVarSetEnabled
-}
-
 // ParseDestinationTarget parses destination target string and sets default keyspace if possible.
 func parseDestinationTarget(targetString string, vschema *vindexes.VSchema) (string, topodatapb.TabletType, key.Destination, error) {
 	destKeyspace, destTabletType, dest, err := topoprotopb.ParseDestination(targetString, defaultTabletType)
diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go
index 088245588a..33c0e0a1e6 100644
--- a/go/vt/vtgate/vtgate.go
+++ b/go/vt/vtgate/vtgate.go
@@ -69,9 +69,6 @@ var (
 	HealthCheckTimeout = flag.Duration("healthcheck_timeout", time.Minute, "the health check timeout period")
 	maxPayloadSize     = flag.Int("max_payload_size", 0, "The threshold for query payloads in bytes. A payload greater than this threshold will result in a failure to handle the query.")
 	warnPayloadSize    = flag.Int("warn_payload_size", 0, "The warning threshold for query payloads in bytes. A payload greater than this threshold will cause the VtGateWarnings.WarnPayloadSizeExceeded counter to be incremented.")
-
-	// Put set-passthrough under a flag.
-	sysVarSetEnabled = flag.Bool("enable_system_settings", false, "This will enable the system settings to be changed per session at the database connection level")
 )
 
 func getTxMode() vtgatepb.TransactionMode {


Test patch:
diff --git a/go/test/endtoend/cluster/vtgate_process.go b/go/test/endtoend/cluster/vtgate_process.go
index ed2c287304..f01d38fb89 100644
--- a/go/test/endtoend/cluster/vtgate_process.go
+++ b/go/test/endtoend/cluster/vtgate_process.go
@@ -53,7 +53,6 @@ type VtgateProcess struct {
 	MySQLAuthServerImpl   string
 	Directory             string
 	VerifyURL             string
-	SysVarSetEnabled      bool
 	//Extra Args to be set before starting the vtgate process
 	ExtraArgs []string
 
@@ -64,7 +63,8 @@ type VtgateProcess struct {
 // Setup starts Vtgate process with required arguements
 func (vtgate *VtgateProcess) Setup() (err error) {
 
-	args := []string{
+	vtgate.proc = exec.Command(
+		vtgate.Binary,
 		"-topo_implementation", vtgate.CommonArg.TopoImplementation,
 		"-topo_global_server_address", vtgate.CommonArg.TopoGlobalAddress,
 		"-topo_global_root", vtgate.CommonArg.TopoGlobalRoot,
@@ -80,13 +80,6 @@ func (vtgate *VtgateProcess) Setup() (err error) {
 		"-gateway_implementation", vtgate.GatewayImplementation,
 		"-service_map", vtgate.ServiceMap,
 		"-mysql_auth_server_impl", vtgate.MySQLAuthServerImpl,
-	}
-	if vtgate.SysVarSetEnabled {
-		args = append(args, "-enable_system_settings")
-	}
-	vtgate.proc = exec.Command(
-		vtgate.Binary,
-		args...,
 	)
 	if *isCoverage {
 		vtgate.proc.Args = append(vtgate.proc.Args, "-test.coverprofile="+getCoveragePath("vtgate.out"))
diff --git a/go/test/endtoend/vtgate/lookup_test.go b/go/test/endtoend/vtgate/lookup_test.go
index 90ac5e2a1f..29829410d3 100644
--- a/go/test/endtoend/vtgate/lookup_test.go
+++ b/go/test/endtoend/vtgate/lookup_test.go
@@ -164,6 +164,186 @@ func TestConsistentLookup(t *testing.T) {
 	exec(t, conn, "delete from t1 where id1=1")
 }
 
+func TestDMLScatter(t *testing.T) {
+	ctx := context.Background()
+	conn, err := mysql.Connect(ctx, &vtParams)
+	require.NoError(t, err)
+	defer conn.Close()
+
+	/* Simple insert. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	1 2 3
+	2 2 3
+	3 4 3
+	4 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 2
+	3 2
+	3 4
+	4 5
+	*/
+	exec(t, conn, "begin")
+	exec(t, conn, "insert into t3(id5, id6, id7) values(1, 2, 3), (2, 2, 3), (3, 4, 3), (4, 5, 4)")
+	exec(t, conn, "commit")
+	qr := exec(t, conn, "select id5, id6, id7 from t3 order by id5")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* Updating a non lookup column. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	42 2 3
+	2 2 3
+	3 4 3
+	4 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 2
+	3 2
+	3 4
+	4 5
+	*/
+	exec(t, conn, "update `ks[-]`.t3 set id5 = 42 where id5 = 1")
+	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)] [INT64(42) INT64(2) INT64(3)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* Updating a lookup column. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	42 2 42
+	2 2 42
+	3 4 3
+	4 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	42 2
+	42 2
+	3 4
+	4 5
+	*/
+	exec(t, conn, "begin")
+	exec(t, conn, "update t3 set id7 = 42 where id6 = 2")
+	exec(t, conn, "commit")
+	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(2) INT64(2) INT64(42)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)] [INT64(42) INT64(2) INT64(42)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* delete one specific keyspace id. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	3 4 3
+	4 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 4
+	4 5
+	*/
+	exec(t, conn, "delete from t3 where id6 = 2")
+	qr = exec(t, conn, "select * from t3 where id6 = 2")
+	require.Empty(t, qr.Rows)
+	qr = exec(t, conn, "select * from t3_id7_idx where id6 = 2")
+	require.Empty(t, qr.Rows)
+
+	// delete all the rows.
+	exec(t, conn, "delete from `ks[-]`.t3")
+	qr = exec(t, conn, "select * from t3")
+	require.Empty(t, qr.Rows)
+	qr = exec(t, conn, "select * from t3_id7_idx")
+	require.Empty(t, qr.Rows)
+}
+
+func TestDMLIn(t *testing.T) {
+	ctx := context.Background()
+	conn, err := mysql.Connect(ctx, &vtParams)
+	require.NoError(t, err)
+	defer conn.Close()
+
+	/* Simple insert. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	1 2 3
+	2 2 3
+	3 4 3
+	4 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 2
+	3 2
+	3 4
+	4 5
+	*/
+	exec(t, conn, "begin")
+	exec(t, conn, "insert into t3(id5, id6, id7) values(1, 2, 3), (2, 2, 3), (3, 4, 3), (4, 5, 4)")
+	exec(t, conn, "commit")
+	qr := exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* Updating a non lookup column. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	1 2 3
+	2 2 3
+	42 4 3
+	42 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 2
+	3 2
+	3 4
+	4 5
+	*/
+	exec(t, conn, "update t3 set id5 = 42 where id6 in (4, 5)")
+	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(42) INT64(4) INT64(3)] [INT64(42) INT64(5) INT64(4)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* Updating a non lookup column. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	1 2 42
+	2 2 42
+	42 4 3
+	42 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	42 2
+	42 2
+	3 4
+	42 5
+	*/
+	exec(t, conn, "begin")
+	exec(t, conn, "update t3 set id7 = 42 where id6 in (2, 5)")
+	exec(t, conn, "commit")
+	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
+	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(42)] [INT64(2) INT64(2) INT64(42)] [INT64(42) INT64(4) INT64(3)] [INT64(42) INT64(5) INT64(42)]]"; got != want {
+		t.Errorf("select:\n%v want\n%v", got, want)
+	}
+
+	/* Updating a non lookup column. after this dml, the tables will contain the following:
+	t3 (id5, id6, id7):
+	42 4 3
+	42 5 4
+
+	t3_id7_idx (id7, keyspace_id:id6):
+	3 4
+	42 5
+	*/
+	exec(t, conn, "delete from t3 where id6 in (2)")
+	qr = exec(t, conn, "select * from t3 where id6 = 2")
+	require.Empty(t, qr.Rows)
+	qr = exec(t, conn, "select * from t3_id7_idx where id6 = 2")
+	require.Empty(t, qr.Rows)
+
+	// delete all the rows.
+	exec(t, conn, "delete from t3 where id6 in (4, 5)")
+	qr = exec(t, conn, "select * from t3")
+	require.Empty(t, qr.Rows)
+	qr = exec(t, conn, "select * from t3_id7_idx")
+	require.Empty(t, qr.Rows)
+}
+
 func TestConsistentLookupMultiInsert(t *testing.T) {
 	defer cluster.PanicHandler(t)
 	ctx := context.Background()
diff --git a/go/test/endtoend/vtgate/misc_test.go b/go/test/endtoend/vtgate/misc_test.go
index aec30cd7b6..81faeb428c 100644
--- a/go/test/endtoend/vtgate/misc_test.go
+++ b/go/test/endtoend/vtgate/misc_test.go
@@ -34,186 +34,6 @@ import (
 	"vitess.io/vitess/go/test/endtoend/cluster"
 )
 
-func TestDMLScatter(t *testing.T) {
-	ctx := context.Background()
-	conn, err := mysql.Connect(ctx, &vtParams)
-	require.NoError(t, err)
-	defer conn.Close()
-
-	/* Simple insert. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	1 2 3
-	2 2 3
-	3 4 3
-	4 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 2
-	3 2
-	3 4
-	4 5
-	*/
-	exec(t, conn, "begin")
-	exec(t, conn, "insert into t3(id5, id6, id7) values(1, 2, 3), (2, 2, 3), (3, 4, 3), (4, 5, 4)")
-	exec(t, conn, "commit")
-	qr := exec(t, conn, "select id5, id6, id7 from t3 order by id5")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* Updating a non lookup column. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	42 2 3
-	2 2 3
-	3 4 3
-	4 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 2
-	3 2
-	3 4
-	4 5
-	*/
-	exec(t, conn, "update t3 set id5 = 42 where id5 = 1")
-	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)] [INT64(42) INT64(2) INT64(3)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* Updating a lookup column. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	42 2 42
-	2 2 42
-	3 4 3
-	4 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	42 2
-	42 2
-	3 4
-	4 5
-	*/
-	exec(t, conn, "begin")
-	exec(t, conn, "update t3 set id7 = 42 where id6 = 2")
-	exec(t, conn, "commit")
-	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(2) INT64(2) INT64(42)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)] [INT64(42) INT64(2) INT64(42)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* delete one specific keyspace id. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	3 4 3
-	4 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 4
-	4 5
-	*/
-	exec(t, conn, "delete from t3 where id6 = 2")
-	qr = exec(t, conn, "select * from t3 where id6 = 2")
-	require.Empty(t, qr.Rows)
-	qr = exec(t, conn, "select * from t3_id7_idx where id6 = 2")
-	require.Empty(t, qr.Rows)
-
-	// delete all the rows.
-	exec(t, conn, "delete from t3")
-	qr = exec(t, conn, "select * from t3")
-	require.Empty(t, qr.Rows)
-	qr = exec(t, conn, "select * from t3_id7_idx")
-	require.Empty(t, qr.Rows)
-}
-
-func TestDMLIn(t *testing.T) {
-	ctx := context.Background()
-	conn, err := mysql.Connect(ctx, &vtParams)
-	require.NoError(t, err)
-	defer conn.Close()
-
-	/* Simple insert. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	1 2 3
-	2 2 3
-	3 4 3
-	4 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 2
-	3 2
-	3 4
-	4 5
-	*/
-	exec(t, conn, "begin")
-	exec(t, conn, "insert into t3(id5, id6, id7) values(1, 2, 3), (2, 2, 3), (3, 4, 3), (4, 5, 4)")
-	exec(t, conn, "commit")
-	qr := exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(3) INT64(4) INT64(3)] [INT64(4) INT64(5) INT64(4)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* Updating a non lookup column. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	1 2 3
-	2 2 3
-	42 4 3
-	42 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 2
-	3 2
-	3 4
-	4 5
-	*/
-	exec(t, conn, "update t3 set id5 = 42 where id6 in (4, 5)")
-	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(3)] [INT64(2) INT64(2) INT64(3)] [INT64(42) INT64(4) INT64(3)] [INT64(42) INT64(5) INT64(4)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* Updating a non lookup column. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	1 2 42
-	2 2 42
-	42 4 3
-	42 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	42 2
-	42 2
-	3 4
-	42 5
-	*/
-	exec(t, conn, "begin")
-	exec(t, conn, "update t3 set id7 = 42 where id6 in (2, 5)")
-	exec(t, conn, "commit")
-	qr = exec(t, conn, "select id5, id6, id7 from t3 order by id5, id6")
-	if got, want := fmt.Sprintf("%v", qr.Rows), "[[INT64(1) INT64(2) INT64(42)] [INT64(2) INT64(2) INT64(42)] [INT64(42) INT64(4) INT64(3)] [INT64(42) INT64(5) INT64(42)]]"; got != want {
-		t.Errorf("select:\n%v want\n%v", got, want)
-	}
-
-	/* Updating a non lookup column. after this dml, the tables will contain the following:
-	t3 (id5, id6, id7):
-	42 4 3
-	42 5 4
-
-	t3_id7_idx (id7, keyspace_id:id6):
-	3 4
-	42 5
-	*/
-	exec(t, conn, "delete from t3 where id6 in (2)")
-	qr = exec(t, conn, "select * from t3 where id6 = 2")
-	require.Empty(t, qr.Rows)
-	qr = exec(t, conn, "select * from t3_id7_idx where id6 = 2")
-	require.Empty(t, qr.Rows)
-
-	// delete all the rows.
-	exec(t, conn, "delete from t3 where id6 in (4, 5)")
-	qr = exec(t, conn, "select * from t3")
-	require.Empty(t, qr.Rows)
-	qr = exec(t, conn, "select * from t3_id7_idx")
-	require.Empty(t, qr.Rows)
-}
-
 func TestSelectNull(t *testing.T) {
 	ctx := context.Background()
 	conn, err := mysql.Connect(ctx, &vtParams)
diff --git a/go/test/endtoend/vtgate/setstatement/main_test.go b/go/test/endtoend/vtgate/setstatement/main_test.go
index 0cfe9c0281..8cf8d798ab 100644
--- a/go/test/endtoend/vtgate/setstatement/main_test.go
+++ b/go/test/endtoend/vtgate/setstatement/main_test.go
@@ -120,9 +120,7 @@ func TestMain(m *testing.M) {
 		}
 
 		// Start vtgate
-		vtgateProcess := clusterInstance.NewVtgateInstance()
-		vtgateProcess.SysVarSetEnabled = true
-		if err := vtgateProcess.Setup(); err != nil {
+		if err := clusterInstance.StartVtgate(); err != nil {
 			return 1
 		}
 
diff --git a/go/vt/vtgate/executor_set_test.go b/go/vt/vtgate/executor_set_test.go
index f45f23dd28..42cd9c5876 100644
--- a/go/vt/vtgate/executor_set_test.go
+++ b/go/vt/vtgate/executor_set_test.go
@@ -268,7 +268,6 @@ func TestExecutorSet(t *testing.T) {
 
 func TestExecutorSetOp(t *testing.T) {
 	executor, _, _, sbclookup := createLegacyExecutorEnv()
-	*sysVarSetEnabled = true
 
 	sbclookup.SetResults([]*sqltypes.Result{
 		sqltypes.MakeTestResult(sqltypes.MakeTestFields("sql_mode", "varchar"), "STRICT_ALL_TABLES,NO_AUTO_UPDATES"),
diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go
index 4afb969fca..b307f4c4d3 100644
--- a/go/vt/vtgate/planbuilder/plan_test.go
+++ b/go/vt/vtgate/planbuilder/plan_test.go
@@ -147,8 +147,7 @@ func init() {
 
 func TestPlan(t *testing.T) {
 	vschemaWrapper := &vschemaWrapper{
-		v:             loadSchema(t, "schema_test.json"),
-		sysVarEnabled: true,
+		v: loadSchema(t, "schema_test.json"),
 	}
 
 	testOutputTempDir, err := ioutil.TempDir("", "plan_test")
@@ -179,18 +178,6 @@ func TestPlan(t *testing.T) {
 	testFile(t, "lock_cases.txt", testOutputTempDir, vschemaWrapper)
 }
 
-func TestSysVarSetDisabled(t *testing.T) {
-	vschemaWrapper := &vschemaWrapper{
-		v:             loadSchema(t, "schema_test.json"),
-		sysVarEnabled: false,
-	}
-
-	testOutputTempDir, err := ioutil.TempDir("", "plan_test")
-	require.NoError(t, err)
-	defer os.RemoveAll(testOutputTempDir)
-	testFile(t, "set_sysvar_disabled_cases.txt", testOutputTempDir, vschemaWrapper)
-}
-
 func TestOne(t *testing.T) {
 	vschema := &vschemaWrapper{
 		v: loadSchema(t, "schema_test.json"),
@@ -271,15 +258,10 @@ func loadSchema(t *testing.T, filename string) *vindexes.VSchema {
 var _ ContextVSchema = (*vschemaWrapper)(nil)
 
 type vschemaWrapper struct {
-	v             *vindexes.VSchema
-	keyspace      *vindexes.Keyspace
-	tabletType    topodatapb.TabletType
-	dest          key.Destination
-	sysVarEnabled bool
-}
-
-func (vw *vschemaWrapper) SysVarSetEnabled() bool {
-	return vw.sysVarEnabled
+	v          *vindexes.VSchema
+	keyspace   *vindexes.Keyspace
+	tabletType topodatapb.TabletType
+	dest       key.Destination
 }
 
 func (vw *vschemaWrapper) TargetDestination(qualifier string) (key.Destination, *vindexes.Keyspace, topodatapb.TabletType, error) {
diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt
index d2b6d94659..6dfb273ed3 100644
--- a/go/vt/vtgate/planbuilder/testdata/dml_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.txt
@@ -2150,3 +2150,67 @@
     "Table": "user"
   }
 }
+
+# delete with shard targeting
+"delete from `user[-]`.user"
+{
+  "QueryType": "DELETE",
+  "Original": "delete from `user[-]`.user",
+  "Instructions": {
+    "OperatorType": "Delete",
+    "Variant": "ByDestination",
+    "Keyspace": {
+      "Name": "user",
+      "Sharded": true
+    },
+    "TargetTabletType": "MASTER",
+    "KsidVindex": "user_index",
+    "MultiShardAutocommit": false,
+    "OwnedVindexQuery": "select Id, Name, Costly from user for update",
+    "Query": "delete from user",
+    "Table": "user"
+  }
+}
+
+# update with shard targeting
+"update `user[-]`.user set name = 'myname'"
+{
+  "QueryType": "UPDATE",
+  "Original": "update `user[-]`.user set name = 'myname'",
+  "Instructions": {
+    "OperatorType": "Update",
+    "Variant": "ByDestination",
+    "Keyspace": {
+      "Name": "user",
+      "Sharded": true
+    },
+    "TargetTabletType": "MASTER",
+    "ChangedVindexValues": [
+      "name_user_map"
+    ],
+    "KsidVindex": "user_index",
+    "MultiShardAutocommit": false,
+    "OwnedVindexQuery": "select Id, Name, Costly from user for update",
+    "Query": "update user set name = 'myname'",
+    "Table": "user"
+  }
+}
+
+# update with shard targeting without vindex
+"update `user[-]`.user_extra set val = 1"
+{
+  "QueryType": "UPDATE",
+  "Original": "update `user[-]`.user_extra set val = 1",
+  "Instructions": {
+    "OperatorType": "Update",
+    "Variant": "ByDestination",
+    "Keyspace": {
+      "Name": "user",
+      "Sharded": true
+    },
+    "TargetTabletType": "MASTER",
+    "MultiShardAutocommit": false,
+    "Query": "update user_extra set val = 1",
+    "Table": "user_extra"
+  }
+}
diff --git a/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.txt b/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.txt
deleted file mode 100644
index f213ba1a96..0000000000
--- a/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# set passthrough disabled - check and ignore plan
-"set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER'), @@sql_safe_updates = 1"
-{
-  "QueryType": "SET",
-  "Original": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER'), @@sql_safe_updates = 1",
-  "Instructions": {
-    "OperatorType": "Set",
-    "Ops": [
-      {
-        "Type": "SysVarCheckAndIgnore",
-        "Name": "sql_mode",
-        "Keyspace": {
-          "Name": "main",
-          "Sharded": false
-        },
-        "TargetDestination": {},
-        "Expr": "concat(@@sql_mode, ',NO_AUTO_CREATE_USER')"
-      },
-      {
-        "Type": "SysVarCheckAndIgnore",
-        "Name": "sql_safe_updates",
-        "Keyspace": {
-          "Name": "main",
-          "Sharded": false
-        },
-        "TargetDestination": {},
-        "Expr": "1"
-      }
-    ],
-    "Inputs": [
-      {
-        "OperatorType": "SingleRow"
-      }
-    ]
-  }
-}