Skip to content

Commit

Permalink
fix writeFieldList cause broken pipe (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
igoso authored Jun 21, 2021
1 parent 3673706 commit 9857c7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions proxy/server/client_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ func (cc *ClientConn) writeColumnDefinition(field *mysql.Field) error {
2 + // flags
1 + // decimals
2 // filler
if field.DefaultValue != nil {
length += 8 + len(field.DefaultValue)
}

data := cc.StartEphemeralPacket(length)
pos := 0
Expand Down Expand Up @@ -362,6 +365,11 @@ func (cc *ClientConn) writeColumnDefinition(field *mysql.Field) error {
pos = mysql.WriteByte(data, pos, byte(field.Decimal))
pos = mysql.WriteUint16(data, pos, uint16(0x0000))

if field.DefaultValue != nil {
pos = mysql.WriteUint64(data, pos, field.DefaultValueLength)
copy(data[pos:], field.DefaultValue)
pos += len(field.DefaultValue)
}
if pos != len(data) {
return fmt.Errorf("internal error: packing of column definition used %v bytes instead of %v", pos, len(data))
}
Expand Down

0 comments on commit 9857c7c

Please sign in to comment.