Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser, ddl: support decoding binary literal in set/enum #35822

Merged
merged 9 commits into from
Jun 30, 2022
Prev Previous commit
Next Next commit
update jsonFieldType
  • Loading branch information
tangenta committed Jun 30, 2022
commit 01ab3b8cb0c95538eb1afea219b967718a0db193
18 changes: 11 additions & 7 deletions parser/types/field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type FieldType struct {
// elems is the element list for enum and set type.
elems []string
elemsIsBinaryLit []bool
// Please keep in mind that jsonFieldType should be updated if you add a new field here.
}

// NewFieldType returns a FieldType,
Expand Down Expand Up @@ -531,13 +532,14 @@ func HasCharset(ft *FieldType) bool {

// for json
type jsonFieldType struct {
Tp byte
Flag uint
Flen int
Decimal int
Charset string
Collate string
Elems []string
Tp byte
Flag uint
Flen int
Decimal int
Charset string
Collate string
Elems []string
ElemsIsBinaryLit []bool
}

func (ft *FieldType) UnmarshalJSON(data []byte) error {
Expand All @@ -551,6 +553,7 @@ func (ft *FieldType) UnmarshalJSON(data []byte) error {
ft.charset = r.Charset
ft.collate = r.Collate
ft.elems = r.Elems
ft.elemsIsBinaryLit = r.ElemsIsBinaryLit
}
return err
}
Expand All @@ -564,5 +567,6 @@ func (ft *FieldType) MarshalJSON() ([]byte, error) {
r.Charset = ft.charset
r.Collate = ft.collate
r.Elems = ft.elems
r.ElemsIsBinaryLit = ft.elemsIsBinaryLit
return json.Marshal(r)
}