Skip to content

Commit

Permalink
Add Query-Fastpath
Browse files Browse the repository at this point in the history
Reference-Implementation for proposed Queryer-Interface (like Execer)
  • Loading branch information
julienschmidt committed Jan 24, 2013
1 parent 0702154 commit 7af5412
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,37 @@ func (mc *mysqlConn) exec(query string) (e error) {
return
}

func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, error) {
if len(args) > 0 {
return nil, driver.ErrSkip
}

// Send command
e := mc.writeCommandPacket(COM_QUERY, query)
if e != nil {
return nil, e
}

// Read Result
var resLen int
resLen, e = mc.readResultSetHeaderPacket()
if e != nil {
return nil, e
}

rows := mysqlRows{&rowsContent{mc, false, resLen, nil}}

if resLen > 0 {
// Columns
rows.content.columns, e = mc.readColumns(resLen)
if e != nil {
return nil, e
}
}

return rows, e
}

// Gets the value of the given MySQL System Variable
func (mc *mysqlConn) getSystemVar(name string) (val string, e error) {
// Send command
Expand Down

0 comments on commit 7af5412

Please sign in to comment.