Mercurial > hg > monetdb-perl
view mclient.pl @ 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 | 8c8bd15f7a0b |
children |
line wrap: on
line source
#!/usr/bin/env perl # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. use MonetDB::CLI::Mapi; my $db = shift || ''; my $port = shift || 50000; my ($monet, $line); $monet = new MonetDB::CLI::Mapi('localhost', $port, 'monetdb', 'monetdb', 'sql', $db, 0); print "> "; while ( !(($line=<>) =~ /\q/) ){ my $res = 0; $monet->doRequest($line); while( ($res = $monet->getReply()) > 0 ) { print $monet->{row} . "\n"; } if ($res < 0) { if ($res == -1) { print $monet->{errstr}; } elsif ($res == -2) { print "$monet->{count} rows affected\n"; } } print "> "; } $monet->disconnect(); 1;