Skip to content

Commit

Permalink
rows: release conn
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Feb 2, 2022
1 parent 0b13bd0 commit 9c3199d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
20 changes: 10 additions & 10 deletions clickhouse_rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
)

type rows struct {
err error
row int
conn *connect
block *proto.Block
totals *proto.Block
errors chan error
stream chan *proto.Block
columns []string
err error
row int
block *proto.Block
totals *proto.Block
errors chan error
stream chan *proto.Block
columns []string
structMap structMap
}

func (r *rows) Next() (result bool) {
Expand Down Expand Up @@ -76,7 +76,7 @@ func (r *rows) Scan(dest ...interface{}) error {
}

func (r *rows) ScanStruct(dest interface{}) error {
values, err := r.conn.structMap.Map("ScanStruct", r.columns, dest, true)
values, err := r.structMap.Map("ScanStruct", r.columns, dest, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (r *row) Err() error {
}

func (r *row) ScanStruct(dest interface{}) error {
values, err := r.rows.conn.structMap.Map("ScanStruct", r.rows.columns, dest, true)
values, err := r.rows.structMap.Map("ScanStruct", r.rows.columns, dest, true)
if err != nil {
return err
}
Expand Down
13 changes: 8 additions & 5 deletions conn_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (c *connect) query(ctx context.Context, release func(*connect, error), quer
)

if err != nil {
release(c, err)
return nil, err
}

Expand All @@ -41,12 +42,14 @@ func (c *connect) query(ctx context.Context, release func(*connect, error), quer
}

if err = c.sendQuery(body, &options); err != nil {
release(c, err)
return nil, err
}

init, err := c.firstBlock(ctx, onProcess)

if err != nil {
release(c, err)
return nil, err
}

Expand All @@ -69,11 +72,11 @@ func (c *connect) query(ctx context.Context, release func(*connect, error), quer
}()

return &rows{
conn: c,
block: init,
stream: stream,
errors: errors,
columns: init.ColumnsNames(),
block: init,
stream: stream,
errors: errors,
columns: init.ColumnsNames(),
structMap: c.structMap,
}, nil
}

Expand Down

0 comments on commit 9c3199d

Please sign in to comment.