Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeryk committed Mar 1, 2024
1 parent 8693a42 commit 67895ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions clickhouse_rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func (r *rows) Next() (result bool) {
}
next:
if r.row >= r.block.Rows() {
if r.stream == nil {
return false
}
select {
case err := <-r.errors:
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion conn_http_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func (h *httpConnect) query(ctx context.Context, release func(*connect, error),
return nil, err
}

if res.ContentLength == 0 {
block := &proto.Block{}
return &rows{
block: block,
columns: block.ColumnsNames(),
structMap: &structMap{},
}, nil
}

rw := h.compressionPool.Get()
// The HTTPReaderWriter.NewReader will create a reader that will decompress it if needed,
// cause adding Accept-Encoding:gzip on your request means response won’t be automatically decompressed
Expand All @@ -65,7 +74,7 @@ func (h *httpConnect) query(ctx context.Context, release func(*connect, error),
}
chReader := chproto.NewReader(reader)
block, err := h.readData(ctx, chReader)
if err != nil {
if err != nil && !errors.Is(err, io.EOF) {
res.Body.Close()
h.compressionPool.Put(rw)
return nil, err
Expand Down Expand Up @@ -103,6 +112,9 @@ func (h *httpConnect) query(ctx context.Context, release func(*connect, error),
close(errCh)
}()

if block == nil {
block = &proto.Block{}
}
return &rows{
block: block,
stream: stream,
Expand Down

0 comments on commit 67895ad

Please sign in to comment.