Skip to content

Commit

Permalink
mutex released when needed.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Oct 9, 2024
1 parent cb4ebee commit 8bb4d77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions database/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func (c *Conn) IsValid() (b bool) {

// QueryContext execute a query with context.
func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (r driver.Rows, err error) {
defer c.release()
if c.needsMutex(query) {
c.acquire()
defer c.release()
}
if p, cast := c.wrapped.(driver.QueryerContext); cast {
r, err = p.QueryContext(ctx, query, args)
Expand All @@ -104,9 +104,9 @@ func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.Nam

// ExecContext executes an SQL/DDL statement with context.
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (r driver.Result, err error) {
defer c.release()
if c.needsMutex(query) {
c.acquire()
defer c.release()
}
if p, cast := c.wrapped.(driver.ExecerContext); cast {
r, err = p.ExecContext(ctx, query, args)
Expand Down

0 comments on commit 8bb4d77

Please sign in to comment.