Skip to content

Commit 7af5412

Browse files
committed
Add Query-Fastpath
Reference-Implementation for proposed Queryer-Interface (like Execer)
1 parent 0702154 commit 7af5412

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

connection.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,37 @@ func (mc *mysqlConn) exec(query string) (e error) {
238238
return
239239
}
240240

241+
func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, error) {
242+
if len(args) > 0 {
243+
return nil, driver.ErrSkip
244+
}
245+
246+
// Send command
247+
e := mc.writeCommandPacket(COM_QUERY, query)
248+
if e != nil {
249+
return nil, e
250+
}
251+
252+
// Read Result
253+
var resLen int
254+
resLen, e = mc.readResultSetHeaderPacket()
255+
if e != nil {
256+
return nil, e
257+
}
258+
259+
rows := mysqlRows{&rowsContent{mc, false, resLen, nil}}
260+
261+
if resLen > 0 {
262+
// Columns
263+
rows.content.columns, e = mc.readColumns(resLen)
264+
if e != nil {
265+
return nil, e
266+
}
267+
}
268+
269+
return rows, e
270+
}
271+
241272
// Gets the value of the given MySQL System Variable
242273
func (mc *mysqlConn) getSystemVar(name string) (val string, e error) {
243274
// Send command

0 commit comments

Comments
 (0)