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

server: fix COM_FIELD_LIST response bug that make mariadb-client crash during use db #6918

Merged
merged 6 commits into from
Jun 28, 2018
Merged
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
10 changes: 8 additions & 2 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,15 @@ func (cc *clientConn) handleFieldList(sql string) (err error) {
return errors.Trace(err)
}
data := make([]byte, 4, 1024)
for _, v := range columns {
for _, column := range columns {
// Current we doesn't output defaultValue but reserve defaultValue length byte to make mariadb client happy.
// https://dev.mysql.com/doc/internals/en/com-query-response.html#column-definition
// TODO: fill the right DefaultValues.
column.DefaultValueLength = 0
column.DefaultValue = []byte{}

data = data[0:4]
data = v.Dump(data)
data = column.Dump(data)
if err := cc.writePacket(data); err != nil {
return errors.Trace(err)
}
Expand Down