@@ -306,7 +306,7 @@ func (c *Conn) Execute(command string, args ...interface{}) (*Result, error) {
306
306
// flag set to signal the server multiple queries are executed. Handling the responses
307
307
// is up to the implementation of perResultCallback.
308
308
func (c * Conn ) ExecuteMultiple (query string , perResultCallback ExecPerResultCallback ) (* Result , error ) {
309
- if err := c .writeCommandStr ( COM_QUERY , query ); err != nil {
309
+ if err := c .exec_send ( query ); err != nil {
310
310
return nil , errors .Trace (err )
311
311
}
312
312
@@ -359,7 +359,7 @@ func (c *Conn) ExecuteMultiple(query string, perResultCallback ExecPerResultCall
359
359
//
360
360
// ExecuteSelectStreaming should be used only for SELECT queries with a large response resultset for memory preserving.
361
361
func (c * Conn ) ExecuteSelectStreaming (command string , result * Result , perRowCallback SelectPerRowCallback , perResultCallback SelectPerResultCallback ) error {
362
- if err := c .writeCommandStr ( COM_QUERY , command ); err != nil {
362
+ if err := c .exec_send ( command ); err != nil {
363
363
return errors .Trace (err )
364
364
}
365
365
@@ -485,9 +485,18 @@ func (c *Conn) ReadOKPacket() (*Result, error) {
485
485
return c .readOK ()
486
486
}
487
487
488
+ // Send COM_QUERY and read the result
489
+ func (c * Conn ) exec (query string ) (* Result , error ) {
490
+ err := c .exec_send (query )
491
+ if err != nil {
492
+ return nil , err
493
+ }
494
+ return c .readResult (false )
495
+ }
496
+
488
497
// Sends COM_QUERY
489
498
// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query.html
490
- func (c * Conn ) exec (query string ) ( * Result , error ) {
499
+ func (c * Conn ) exec_send (query string ) error {
491
500
var buf bytes.Buffer
492
501
493
502
if c .includeLine {
@@ -524,15 +533,15 @@ func (c *Conn) exec(query string) (*Result, error) {
524
533
525
534
_ , err := buf .Write (utils .StringToByteSlice (query ))
526
535
if err != nil {
527
- return nil , err
536
+ return err
528
537
}
529
538
530
539
if err := c .writeCommandBuf (COM_QUERY , buf .Bytes ()); err != nil {
531
- return nil , errors .Trace (err )
540
+ return errors .Trace (err )
532
541
}
533
542
c .queryAttributes = nil
534
543
535
- return c . readResult ( false )
544
+ return nil
536
545
}
537
546
538
547
// CapabilityString is returning a string with the names of capability flags
0 commit comments