Re: [go-nuts] Data race in sql package

2022-07-26 Thread Daniel Theophanes
It should be safe to use RawBytes from *Conn or *Tx, the transaction won't be re-used. We will look into it further. On Friday, July 22, 2022 at 4:40:16 AM UTC-5 Michal Hruby wrote: > That's right, atm there's no safe way to use sql.RawBytes, it should > either be documented that you need to

Re: [go-nuts] Data race in sql package

2022-07-22 Thread Michal Hruby
That's right, atm there's no safe way to use sql.RawBytes, it should either be documented that you need to manually control the context, or the standard library shouldn't be closing the driver.Rows unless the user calls Scan or Close. On Fri, 22 Jul 2022, 00:45 Steven Hartland, wrote: > I'm

Re: [go-nuts] Data race in sql package

2022-07-21 Thread Steven Hartland
I'm guessing that Michal is flagging is there no way to write safe code if your using stmt.QueryContext(ctx) and rows.Scan into a sql.RawBytes as QueryContext kicks off a go routine that monitors the ctx, closing rows if cancelled and that ctx can be cancelled at any time. The only thing that

Re: [go-nuts] Data race in sql package

2022-07-21 Thread Ian Lance Taylor
On Thu, Jul 21, 2022 at 11:02 AM Michal Hruby wrote: > > Hello, I have a code snippet equivalent to this one: > > rows, err := stmt.QueryContext(ctx) > if err != nil { > return info, nil, err > } > defer rows.Close() > > var data sql.RawBytes > for rows.Next() { > err = rows.Scan() >

[go-nuts] Data race in sql package

2022-07-21 Thread Michal Hruby
Hello, I have a code snippet equivalent to this one: rows, err := stmt.QueryContext(ctx) if err != nil { return info, nil, err } defer rows.Close() var data sql.RawBytes for rows.Next() { err = rows.Scan() if err != nil { return nil, err } // if ctx is canceled around