Changeset: 96edc4137944 for monetdb-perl
URL: https://dev.monetdb.org/hg/monetdb-perl/rev/96edc4137944
Modified Files:
        DBD/monetdb.pm
        MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm
        MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
Branch: default
Log Message:

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 '\ \ '


diffs (67 lines):

diff --git a/DBD/monetdb.pm b/DBD/monetdb.pm
--- a/DBD/monetdb.pm
+++ b/DBD/monetdb.pm
@@ -457,7 +457,7 @@ SQL
     $sql .= " order by uk_table_schem, uk_table_name, fk_table_schem, 
fk_table_name, ordinal_position\n";
     my $sth = $dbh->prepare($sql) or return;
     $sth->execute(@bv) or return;
-       $dbh->set_err(0,"Catalog parameters c1 and c2 have to be an empty 
strings, as MonetDB does not support multiple catalogs") if $c1 ne "" || $c2 ne 
"";
+    $dbh->set_err(0,"Catalog parameters c1 and c2 have to be an empty strings, 
as MonetDB does not support multiple catalogs") if $c1 ne "" || $c2 ne "";
     return $sth;
 }
 
diff --git a/MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm 
b/MonetDB-CLI-MapiPP/MonetDB/CLI/Mapi.pm
--- 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
diff --git a/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm 
b/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
--- a/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
+++ b/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
@@ -27,7 +27,7 @@ sub connect
   my ($class, $host, $port, $user, $pass, $lang, $db) = @_;
 
   my $h = new MonetDB::CLI::Mapi($host, $port, $user, $pass, $lang, $db, 0)
-       or die "Making connection failed: $@";
+    or die "Making connection failed: $@";
 
   bless { h => $h },'MonetDB::CLI::MapiPP::Cxn';
 }
@@ -56,7 +56,9 @@ sub DESTROY
 {
   my ($self) = @_;
 
-  $self->{h}->disconnect();
+  if (defined $self->{h}) {
+    $self->{h}->disconnect();
+  }
 
   return;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to