and replaced it withsub _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; }
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.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; }
In reply to How to split rows coming from the database by mocnii
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |