diff --git a/go/sqltypes/value.go b/go/sqltypes/value.go index 51b9e41e1db..8b8bf84ad5c 100644 --- a/go/sqltypes/value.go +++ b/go/sqltypes/value.go @@ -404,8 +404,12 @@ func encodeBytesSQL(val []byte, b BinWriter) { func BufEncodeStringSQL(buf *strings.Builder, val string) { buf.WriteByte('\'') for _, ch := range val { + if ch > 255 { + buf.WriteRune(ch) + continue + } if encodedChar := SQLEncodeMap[ch]; encodedChar == DontEscape { - buf.WriteByte(byte(ch)) + buf.WriteRune(ch) } else { buf.WriteByte('\\') buf.WriteByte(encodedChar) diff --git a/go/vt/sqlparser/parse_test.go b/go/vt/sqlparser/parse_test.go index a7adc76887b..e4862c8b666 100644 --- a/go/vt/sqlparser/parse_test.go +++ b/go/vt/sqlparser/parse_test.go @@ -1162,6 +1162,9 @@ var ( // The last value specified is used. input: "create table foo (f timestamp null not null , g timestamp not null null)", output: "create table foo (\n\tf timestamp not null,\n\tg timestamp null\n)", + }, { + // Tests unicode character § + input: "create table invalid_enum_value_name (\n\there_be_enum enum('$§!') default null\n)", }, { input: "alter vschema create vindex hash_vdx using hash", }, {