[bugfix] defer rows.Close() when using QueryContext

This commit is contained in:
tobi 2024-04-04 17:25:43 +02:00
parent 65b5366031
commit 2bb3eb9608

View file

@ -218,6 +218,7 @@ func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, erro
func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error) {
err = retryOnBusy(ctx, func() error {
rows, err = c.conn.QueryContext(ctx, query, args)
defer rows.Close()
err = processSQLiteError(err)
return err
})
@ -276,6 +277,7 @@ func (stmt *SQLiteStmt) Query(args []driver.Value) (driver.Rows, error) {
func (stmt *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, err error) {
err = retryOnBusy(ctx, func() error {
rows, err = stmt.stmt.QueryContext(ctx, args)
defer rows.Close()
err = processSQLiteError(err)
return err
})