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

mysql: improve fields type info text resultset. #291

Merged
merged 6 commits into from
Jul 9, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
mysql: reformat a block in BuildSimpleTextResultset.
  • Loading branch information
Aleksandr Demakin committed Jul 6, 2018
commit 0e92a7fae5ed8b4c978efe36c70ce328a6c41b73
14 changes: 5 additions & 9 deletions mysql/resultset_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,11 @@ func BuildSimpleTextResultset(names []string, values [][]interface{}) (*Resultse
// the case, when old value was null, and the new one isn't null, so we can update
// type info for fields.
oldIsNull, newIsNull := r.Fields[j].Type == MYSQL_TYPE_NULL, typ == MYSQL_TYPE_NULL
if oldIsNull {
if !newIsNull { // old is null, new isn't, update type info.
r.Fields[j].Type = typ
formatField(r.Fields[j], value)
} // otherwise both are null, ok.
} else {
if !newIsNull { // different non-null types, that's an error.
return nil, errors.Errorf("row types aren't consistent")
} // otherwise old wasn't null, but the new is, ok.
if oldIsNull && !newIsNull { // old is null, new isn't, update type info.
r.Fields[j].Type = typ
formatField(r.Fields[j], value)
} else if !oldIsNull && !newIsNull { // different non-null types, that's an error.
return nil, errors.Errorf("row types aren't consistent")
}
}
b, err = formatTextValue(value)
Expand Down