Skip to content

Commit

Permalink
proper affectedRows
Browse files Browse the repository at this point in the history
  • Loading branch information
julienschmidt committed Feb 25, 2013
1 parent 8416bd0 commit 9e96191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ func (mc *mysqlConn) exec(query string) (err error) {
return
}

mc.affectedRows, err = mc.readUntilEOF()
if err != nil {
if mc.affectedRows > 0 {
_, err = mc.readUntilEOF()
return
}

mc.affectedRows, err = mc.readUntilEOF()
return
}

return
Expand Down
11 changes: 4 additions & 7 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,24 +406,23 @@ func (mc *mysqlConn) handleOkPacket(data []byte) (err error) {
// Position
pos := 1

var n int

// Affected rows [Length Coded Binary]
affectedRows, n, err := bytesToLengthCodedBinary(data[pos:])
mc.affectedRows, n, err = bytesToLengthCodedBinary(data[pos:])
if err != nil {
return
}
pos += n

// Insert id [Length Coded Binary]
insertID, n, err := bytesToLengthCodedBinary(data[pos:])
mc.insertId, n, err = bytesToLengthCodedBinary(data[pos:])
if err != nil {
return
}

// Skip remaining data

mc.affectedRows = affectedRows
mc.insertId = insertID

return
}

Expand Down Expand Up @@ -602,7 +601,6 @@ func (mc *mysqlConn) readRow(columnsCount int) (*[]*[]byte, error) {
pos += n
}

mc.affectedRows++
return &row, nil
}

Expand Down Expand Up @@ -1035,6 +1033,5 @@ func (mc *mysqlConn) readBinaryRow(rc *mysqlRows) (*[]*[]byte, error) {
}
}

mc.affectedRows++
return &row, nil
}

0 comments on commit 9e96191

Please sign in to comment.