Skip to content

Commit

Permalink
catch errors from mysql (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
chicliz authored Oct 12, 2020
1 parent 6997a71 commit 6295c96
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/direct_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ func (dc *DirectConnection) FieldList(table string, wildcard string) ([]*mysql.F
return fs, nil
}

if data[0] == mysql.ErrHeader {
return nil, dc.handleErrorPacket(data)
}

if f, err = mysql.FieldData(data).Parse(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -626,6 +630,10 @@ func (dc *DirectConnection) readResultColumns(result *mysql.Result) (err error)
return
}

if data[0] == mysql.ErrHeader {
return dc.handleErrorPacket(data)
}

result.Fields[i], err = mysql.FieldData(data).Parse()
if err != nil {
return
Expand All @@ -643,7 +651,6 @@ func (dc *DirectConnection) readResultRows(result *mysql.Result, isBinary bool)

for {
data, err = dc.readPacket()

if err != nil {
return
}
Expand All @@ -660,6 +667,10 @@ func (dc *DirectConnection) readResultRows(result *mysql.Result, isBinary bool)
break
}

if data[0] == mysql.ErrHeader {
return dc.handleErrorPacket(data)
}

result.RowDatas = append(result.RowDatas, data)
}

Expand Down

0 comments on commit 6295c96

Please sign in to comment.