Mercurial > hg > monetdb-perl
diff MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm @ 50:96edc4137944
When processing query results, check all lines to see if a line contains an error message (i.e. starts with a '!').
This solves the problem that when an UPDATE is aborted due to transaction conflict, existing code only processes the first line of result, which contains <N> affected rows, but fails to process the second line, which contains the transaction aborted error.
Added two conditions to guard against "Use of uninitialized value" errors, one due to index-out-of-band, the other due to already closed connection.
Replaces '\t' with '\ \ '
author | Ying Zhang <y.zhang@cwi.nl> |
---|---|
date | Wed, 14 Jul 2021 22:07:16 +0200 (2021-07-14) |
parents | 44da5de4a725 |
children | 91ec04bb88c6 |
line wrap: on
line diff
--- a/MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm +++ b/MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm @@ -233,7 +233,7 @@ sub getRow { if ($chars[0] eq '!') { $self->error($row); my $i = 1; - while ($self->{lines}[$i] =~ '!') { + while (defined $self->{lines}[$i] and $self->{lines}[$i] =~ '!') { $self->error($self->{lines}[$i]); $i++; } @@ -288,6 +288,19 @@ sub getBlock { $self->{hdrs} = []; if ($chars[0] eq '&') { + # check for any line containing an error message in this block + my $founderr = 0; + foreach (@{$self->{lines}}) { + if (substr($_, 0, 1) eq "!"){ + $self->error($_); + $founderr++; + } + } + if ($founderr > 0) { + $self->{active} = 0; + return -1; + } + if ($chars[1] eq '1' || $chars[1] eq 6) { if ($chars[1] eq '1') { # &1 id result-count nr-cols rows-in-this-block