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
13 changes: 6 additions & 7 deletions go/vt/vtgate/engine/plan_description.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type PrimitiveDescription struct {

// MarshalJSON serializes the PlanDescription into a JSON representation.
// We do this rather manual thing here so the `other` map looks like
//fields belonging to pd and not a map in a field.
// fields belonging to pd and not a map in a field.
func (pd PrimitiveDescription) MarshalJSON() ([]byte, error) {
buf := &bytes.Buffer{}
buf.WriteString("{")
Expand Down Expand Up @@ -111,12 +111,11 @@ func addMap(input map[string]any, buf *bytes.Buffer) error {

func marshalAdd(prepend string, buf *bytes.Buffer, name string, obj any) error {
buf.WriteString(prepend + `"` + name + `":`)
b, err := json.Marshal(obj)
if err != nil {
return err
}
buf.Write(b)
return nil

enc := json.NewEncoder(buf)
enc.SetEscapeHTML(false)

return enc.Encode(obj)
}

// PrimitiveToPlanDescription transforms a primitive tree into a corresponding PlanDescription tree
Expand Down
14 changes: 12 additions & 2 deletions go/vt/vtgate/engine/primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package engine

import (
"bytes"
"context"
"encoding/json"
"sync/atomic"
Expand Down Expand Up @@ -290,7 +291,7 @@ func Exists(m Match, p Primitive) bool {
return Find(m, p) != nil
}

//MarshalJSON serializes the plan into a JSON representation.
// MarshalJSON serializes the plan into a JSON representation.
func (p *Plan) MarshalJSON() ([]byte, error) {
var instructions *PrimitiveDescription
if p.Instructions != nil {
Expand Down Expand Up @@ -319,7 +320,16 @@ func (p *Plan) MarshalJSON() ([]byte, error) {
RowsReturned: atomic.LoadUint64(&p.RowsReturned),
Errors: atomic.LoadUint64(&p.Errors),
}
return json.Marshal(marshalPlan)

b := new(bytes.Buffer)
enc := json.NewEncoder(b)
enc.SetEscapeHTML(false)
err := enc.Encode(marshalPlan)
if err != nil {
return nil, err
}

return b.Bytes(), nil
}

// Inputs implements no inputs
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/collations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type collationTestCase struct {

func (tc *collationTestCase) run(t *testing.T) {
vschemaWrapper := &vschemaWrapper{
v: loadSchema(t, "schema_test.json", false),
v: loadSchema(t, "vschemas/schema.json", false),
sysVarEnabled: true,
version: Gen4,
}
Expand Down
Loading