From dbd657f83d9959ad68ef4c2839a4885dc06de0be Mon Sep 17 00:00:00 2001 From: chenyuan Date: Wed, 27 May 2020 18:49:47 +0800 Subject: [PATCH] =?UTF-8?q?update=E5=90=8E=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E7=BC=BA=E5=B0=91Rows=20matched:=201=20Changed:=201=20Warnings?= =?UTF-8?q?:=200=E4=BF=A1=E6=81=AF=EF=BC=8C=20=E5=AF=BC=E8=87=B4django=20o?= =?UTF-8?q?rm=E6=A1=86=E6=9E=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit django.db.utils.DatabaseError: Save with update_fields did not affect any rows. --- backend/backend_conn.go | 10 ++++++++-- mysql/const.go | 3 +++ mysql/resultset.go | 2 ++ proxy/server/conn.go | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/backend_conn.go b/backend/backend_conn.go index fd86e198..f1693cb5 100644 --- a/backend/backend_conn.go +++ b/backend/backend_conn.go @@ -649,14 +649,20 @@ func (c *Conn) handleOKPacket(data []byte) (*mysql.Result, error) { //todo:strict_mode, check warnings as error //Warnings := binary.LittleEndian.Uint16(data[pos:]) - //pos += 2 + pos += 2 } else if c.capability&mysql.CLIENT_TRANSACTIONS > 0 { r.Status = binary.LittleEndian.Uint16(data[pos:]) c.status = r.Status pos += 2 } - //info + //info https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html + if c.capability&mysql.CLIENT_SESSION_TRACK > 0 { + r.Info, _, n, _ = mysql.LengthEnodedString(data[pos:]) + } else { + r.Info = data[pos:] + } + return r, nil } diff --git a/mysql/const.go b/mysql/const.go index 61399716..05cfe740 100644 --- a/mysql/const.go +++ b/mysql/const.go @@ -101,6 +101,9 @@ const ( CLIENT_PLUGIN_AUTH CLIENT_CONNECT_ATTRS CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA + CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS + CLIENT_SESSION_TRACK + CLIENT_DEPRECATE_EOF ) //https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType diff --git a/mysql/resultset.go b/mysql/resultset.go index 9b8fbe27..c364da6e 100644 --- a/mysql/resultset.go +++ b/mysql/resultset.go @@ -268,6 +268,8 @@ type Result struct { AffectedRows uint64 *Resultset + + Info []byte } type Resultset struct { diff --git a/proxy/server/conn.go b/proxy/server/conn.go index 44a70396..ef071b32 100644 --- a/proxy/server/conn.go +++ b/proxy/server/conn.go @@ -375,6 +375,7 @@ func (c *ClientConn) writeOK(r *mysql.Result) error { if c.capability&mysql.CLIENT_PROTOCOL_41 > 0 { data = append(data, byte(r.Status), byte(r.Status>>8)) data = append(data, 0, 0) + data = append(data, r.Info...) } return c.writePacket(data)