diff --git a/sql/analyzer/costed_index_scan.go b/sql/analyzer/costed_index_scan.go index 62386ff036..b5fa511169 100644 --- a/sql/analyzer/costed_index_scan.go +++ b/sql/analyzer/costed_index_scan.go @@ -1086,7 +1086,7 @@ type iScanLeaf struct { func (l *iScanLeaf) normString() string { if l.underlying != "" { - return fmt.Sprintf("%s.%s", strings.ToLower(l.underlying), strings.ToLower(l.gf.Name())) + return strings.ToLower(l.underlying) + "." + strings.ToLower(l.gf.Name()) } return strings.ToLower(l.gf.String()) } diff --git a/sql/planbuilder/ddl.go b/sql/planbuilder/ddl.go index 5380548945..758b57410a 100644 --- a/sql/planbuilder/ddl.go +++ b/sql/planbuilder/ddl.go @@ -1726,11 +1726,12 @@ func (b *Builder) resolveColumnDefaultExpression(inScope *scope, columnDef *sql. // Empty string is a special case, it means the default value is the empty string // TODO: why isn't this serialized as '' - if def.String() == "" { + defStr := def.String() + if defStr == "" { return b.convertDefaultExpression(inScope, &ast.SQLVal{Val: []byte{}, Type: ast.StrVal}, columnDef.Type, columnDef.Nullable) } - parsed, err := b.parser.ParseSimple(fmt.Sprintf("SELECT %s", def)) + parsed, err := b.parser.ParseSimple("SELECT " + defStr) if err != nil { err := sql.ErrInvalidColumnDefaultValue.Wrap(err, def) b.handleErr(err) diff --git a/sql/types/decimal.go b/sql/types/decimal.go index ea51479d78..f430a0b159 100644 --- a/sql/types/decimal.go +++ b/sql/types/decimal.go @@ -27,6 +27,7 @@ import ( "gopkg.in/src-d/go-errors.v1" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/encodings" "github.com/dolthub/go-mysql-server/sql/values" ) @@ -342,7 +343,7 @@ func (t DecimalType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltype if err != nil { return sqltypes.Value{}, err } - val := AppendAndSliceString(dest, t.DecimalValueStringFixed(value.Decimal)) + val := encodings.StringToBytes(t.DecimalValueStringFixed(value.Decimal)) return sqltypes.MakeTrusted(sqltypes.Decimal, val), nil } @@ -351,7 +352,7 @@ func (t DecimalType_) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqlt return sqltypes.NULL, nil } d := values.ReadDecimal(v.Val) - return sqltypes.MakeTrusted(sqltypes.Decimal, []byte(t.DecimalValueStringFixed(d))), nil + return sqltypes.MakeTrusted(sqltypes.Decimal, encodings.StringToBytes(t.DecimalValueStringFixed(d))), nil } // String implements Type interface. diff --git a/sql/types/enum.go b/sql/types/enum.go index 5db9cfde81..df93751dcb 100644 --- a/sql/types/enum.go +++ b/sql/types/enum.go @@ -289,7 +289,7 @@ func (t EnumType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes } // TODO: write append style encoder - res, ok := charset.Encoder().Encode([]byte(value)) + res, ok := charset.Encoder().Encode(encodings.StringToBytes(value)) if !ok { if len(value) > 50 { value = value[:50] diff --git a/sql/types/json.go b/sql/types/json.go index 64ba15842c..474f91bcaa 100644 --- a/sql/types/json.go +++ b/sql/types/json.go @@ -24,6 +24,7 @@ import ( "github.com/shopspring/decimal" "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/go-mysql-server/sql/encodings" ) var ( @@ -166,7 +167,7 @@ func (t JsonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Va if err != nil { return sqltypes.NULL, err } - val = AppendAndSliceString(dest, str) + val = encodings.StringToBytes(str) } return sqltypes.MakeTrusted(sqltypes.TypeJSON, val), nil diff --git a/sql/types/set.go b/sql/types/set.go index 6bba11ac11..0914ce6970 100644 --- a/sql/types/set.go +++ b/sql/types/set.go @@ -285,7 +285,7 @@ func (t SetType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes. } // TODO: write append style encoder - res, ok := resultCharset.Encoder().Encode([]byte(value)) + res, ok := resultCharset.Encoder().Encode(encodings.StringToBytes(value)) if !ok { if len(value) > 50 { value = value[:50]