I found a bug in the following code from ClickHouse (it breaks on large SELECTs). It reads from Net::HTTP read_entity_body():
sub _read_body { my ($self) = @_; my @response; while (1) { my $buf; my $n = $self->_get_socket()->read_entity_body($buf, 1024); die "can't read response: $!" unless defined $n; last unless $n; push @response, split (/\n/, $buf); } return \@response; }
and replaced it with
sub _read_body { my ($self) = @_; my @response; + my $content = ''; while (1) { my $buf; my $n = $self->_get_socket()->read_entity_body($buf, 1024); die "can't read response: $!" unless defined $n; last unless $n; - push @response, split (/\n/, $buf); + $content .= $buf; } + push @response, split (/\n/, $content); + return \@response; }
My pull request is here: https://github.com/elcamlost/perl-DBD-ClickHouse/pull/4, but is not accepted (nor fixed). This fix works but the problem is that now everything is doubled in memory (and this is used to select from database so it can be huge). I'm looking for a suggestion how to make it less memory hungry or simply cleaner. I tried to use other module (HTTP-ClickHouse), but it has the same bug so this is obviously something that is easy to get wrong.

In reply to How to split rows coming from the database by mocnii

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.