when use QueryContext,data trace appear,but I think there is no problem on 
[go-sql-driver/go]。because QueryContext call initContextClose, 
call awaitDone asynchronous. 

when context timeout,awaitDone channel trigger。  will  release buffer's 
data when Next/Scan。

I think Rows.close(err) should add the judgment:

if err != nil && err != io.EOF {
     rs.lasterr = err
     return nil
}

or

if context.DeadlineExceeded == err {
     rs.lasterr = err
     return nil
}

then code below:

func (rs *Rows) close(err error) error {
        rs.closemu.Lock()
        defer rs.closemu.Unlock()
        
        if err != nil && err != io.EOF {//throws context.DeadlineExceeded when 
QueryContext's context timeout
                rs.lasterr = err
                return nil
        }

        if rs.closed {
                return nil
        }
        rs.closed = true

        if rs.lasterr == nil {
                rs.lasterr = err
        }

        withLock(rs.dc, func() {
                err = rs.rowsi.Close()
        })
        if fn := rowsCloseHook(); fn != nil {
                fn(rs, &err)
        }
        if rs.cancel != nil {
                rs.cancel()
        }

        if rs.closeStmt != nil {
                rs.closeStmt.Close()
        }
        rs.releaseConn(err)
        return err
}

because buffers provided to Rows.Next should not be modified by Rows.Close 
<https://github.com/golang/go/commit/651ddbdb5056ded455f47f9c494c67b389622a47>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to