Repository: vitessio/vitess
Pull request #5993 (2020-03-31 05:47:34)

Minor fixes
These are the remaining review comment fixes from #5982 


Patch:
diff --git a/go/vt/vtgate/engine/send.go b/go/vt/vtgate/engine/send.go
index 7bd8bc9c77..8a8d0a880f 100644
--- a/go/vt/vtgate/engine/send.go
+++ b/go/vt/vtgate/engine/send.go
@@ -1,6 +1,8 @@
 package engine
 
 import (
+	"encoding/json"
+
 	"vitess.io/vitess/go/sqltypes"
 	"vitess.io/vitess/go/vt/key"
 	"vitess.io/vitess/go/vt/proto/query"
@@ -31,6 +33,26 @@ type Send struct {
 	noInputs
 }
 
+// MarshalJSON serializes the Send into a JSON representation.
+// It's used for testing and diagnostics.
+func (s *Send) MarshalJSON() ([]byte, error) {
+	marshalSend := struct {
+		Opcode            string
+		Keyspace          *vindexes.Keyspace
+		TargetDestination key.Destination
+		Query             string
+		NoAutoCommit      bool
+	}{
+		Opcode:            "Send",
+		Keyspace:          s.Keyspace,
+		TargetDestination: s.TargetDestination,
+		NoAutoCommit:      s.NoAutoCommit,
+		Query:             s.Query,
+	}
+
+	return json.Marshal(marshalSend)
+}
+
 // RouteType implements Primitive interface
 func (s *Send) RouteType() string {
 	if s.NoAutoCommit {
@@ -90,5 +112,5 @@ func (s *Send) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVar
 
 // GetFields implements Primitive interface
 func (s *Send) GetFields(vcursor VCursor, bindVars map[string]*query.BindVariable) (*sqltypes.Result, error) {
-	return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable") // TODO: systay - @sugu, is this correct?
+	return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "not reachable")
 }
diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go
index 9da0a08c41..3535022cd9 100644
--- a/go/vt/vtgate/executor.go
+++ b/go/vt/vtgate/executor.go
@@ -266,8 +266,6 @@ func (e *Executor) execute(ctx context.Context, safeSession *SafeSession, sql st
 }
 
 func (e *Executor) handleExec(ctx context.Context, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable, logStats *LogStats, stmtType sqlparser.StatementType) (*sqltypes.Result, error) {
-
-	// V3 mode.
 	query, comments := sqlparser.SplitMarginComments(sql)
 	vcursor, _ := newVCursorImpl(ctx, safeSession, comments, e, logStats, e.VSchema(), e.resolver.resolver)
 	plan, err := e.getPlan(


Test patch:
diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go
index 6c1a690d14..938f434084 100644
--- a/go/vt/vtgate/executor_test.go
+++ b/go/vt/vtgate/executor_test.go
@@ -194,7 +194,6 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) {
 	}
 }
 
-//TODO - what about these?
 func TestDirectTargetRewrites(t *testing.T) {
 	executor, _, _, sbclookup := createExecutorEnv()
 	executor.normalize = true
diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
index 672bbc87f1..e68e934d78 100644
--- a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
@@ -3,6 +3,7 @@
 {
   "Original": "select count(*), col from unsharded",
   "Instructions": {
+    "Opcode": "Send",
     "Keyspace": {
       "Name": "main",
       "Sharded": false
@@ -18,6 +19,7 @@
 {
   "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1",
   "Instructions": {
+    "Opcode": "Send",
     "Keyspace": {
       "Name": "main",
       "Sharded": false
@@ -33,6 +35,7 @@
 {
   "Original": "DELETE FROM USER WHERE ID = 42",
   "Instructions": {
+    "Opcode": "Send",
     "Keyspace": {
       "Name": "main",
       "Sharded": false
@@ -48,6 +51,7 @@
 {
   "Original": "INSERT INTO USER (ID, NAME) VALUES (42, 'ms X')",
   "Instructions": {
+    "Opcode": "Send",
     "Keyspace": {
       "Name": "main",
       "Sharded": false