From 6295c96872288ff3560a521bc6fd01393af7d886 Mon Sep 17 00:00:00 2001 From: zhangxiaoxiao <43167585+chicliz@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:58:29 +0800 Subject: [PATCH] catch errors from mysql (#113) --- backend/direct_connection.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/direct_connection.go b/backend/direct_connection.go index 09df8b1b..8dadfa7c 100644 --- a/backend/direct_connection.go +++ b/backend/direct_connection.go @@ -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 } @@ -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 @@ -643,7 +651,6 @@ func (dc *DirectConnection) readResultRows(result *mysql.Result, isBinary bool) for { data, err = dc.readPacket() - if err != nil { return } @@ -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) }