Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion go/vt/vtgate/engine/send.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
2 changes: 0 additions & 2 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func TestExecutorTransactionsNoAutoCommit(t *testing.T) {
}
}

//TODO - what about these?
func TestDirectTargetRewrites(t *testing.T) {
executor, _, _, sbclookup := createExecutorEnv()
executor.normalize = true
Expand Down
4 changes: 4 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"Original": "select count(*), col from unsharded",
"Instructions": {
"Opcode": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
Expand All @@ -18,6 +19,7 @@
{
"Original": "update user set val = 1 where id = 18446744073709551616 and id = 1",
"Instructions": {
"Opcode": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
Expand All @@ -33,6 +35,7 @@
{
"Original": "DELETE FROM USER WHERE ID = 42",
"Instructions": {
"Opcode": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
Expand All @@ -48,6 +51,7 @@
{
"Original": "INSERT INTO USER (ID, NAME) VALUES (42, 'ms X')",
"Instructions": {
"Opcode": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
Expand Down