Skip to content

Commit

Permalink
improve connection.go
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed May 18, 2024
1 parent 9c487b7 commit f554b55
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,33 +368,37 @@ func (mc *mysqlConn) query(query string, args []driver.Value) (*textRows, error)
}
query = prepared
}

// Send command
err := mc.writeCommandPacketStr(comQuery, query)
if err == nil {
// Read Result
var resLen int
resLen, err = handleOk.readResultSetHeaderPacket()
if err == nil {
rows := new(textRows)
rows.mc = mc
if err != nil {
return nil, err
}

if resLen == 0 {
rows.rs.done = true
// Read Result
var resLen int
resLen, err = handleOk.readResultSetHeaderPacket()
if err != nil {
return nil, err
}

switch err := rows.NextResultSet(); err {
case nil, io.EOF:
return rows, nil
default:
return nil, err
}
}
rows := new(textRows)
rows.mc = mc

// Columns
rows.rs.columns, err = mc.readColumns(resLen)
return rows, err
if resLen == 0 {
rows.rs.done = true

switch err := rows.NextResultSet(); err {
case nil, io.EOF:
return rows, nil
default:
return nil, err
}
}
return nil, err

// Columns
rows.rs.columns, err = mc.readColumns(resLen)
return rows, err
}

// Gets the value of the given MySQL System Variable
Expand Down

0 comments on commit f554b55

Please sign in to comment.