Skip to content

Commit

Permalink
server: fix COM_FIELD_LIST response bug that make mariadb-client cras…
Browse files Browse the repository at this point in the history
…h during `use db` (pingcap#6918) (pingcap#6929)
  • Loading branch information
lysu authored and coocood committed Jun 28, 2018
1 parent 68c6968 commit 56135f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,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

0 comments on commit 56135f4

Please sign in to comment.