Skip to content

Commit

Permalink
ability to send multiple resultsets from handleQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
GoWebProd committed Nov 10, 2020
1 parent 0c5789d commit b29ed61
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions mysql/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ func (r *Result) Close() {
r.Resultset = nil
}
}

func (r *Result) ChainResultSet(rs *Resultset) {
if r.Resultset == nil {
r.Resultset = rs
return
}

var lastRS *Resultset

for lastRS = r.Resultset; lastRS.Next != nil; lastRS = lastRS.Next {}

lastRS.Next = rs
}
2 changes: 2 additions & 0 deletions mysql/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Resultset struct {
RawPkg []byte

RowDatas []RowData

Next *Resultset
}

var (
Expand Down
15 changes: 14 additions & 1 deletion server/resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,20 @@ func (c *Conn) writeValue(value interface{}) error {
return c.writeOK(nil)
case *Result:
if v != nil && v.Resultset != nil {
return c.writeResultset(v.Resultset)
for rs := v.Resultset; rs != nil; rs = rs.Next {
if rs.Next != nil {
c.status |= SERVER_MORE_RESULTS_EXISTS
}

err := c.writeResultset(rs)
c.status &= ^SERVER_MORE_RESULTS_EXISTS

if err != nil {
return err
}
}

return nil
} else {
return c.writeOK(v)
}
Expand Down

0 comments on commit b29ed61

Please sign in to comment.