Changeset: 3ee6b959a958 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ee6b959a958
Modified Files:
clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
monetdb5/tests/mapi/Tests/perl_dbi.stable.out
sql/test/mapi/Tests/perl_dbi.stable.out
Branch: Dec2011
Log Message:
MonetDB-CLI: fix MAL server interaction
Since the progressive fetching enhancement from bug #2891, retrieving
results from a MAL server failed, because the progressive code relies on
the metadata headers as sent by the SQL server. In case we detect a
result without these metadata headers, fall back to the old buffered way
of reading, such that the total tuple count is available.
This fixes the failing MAL perl_dbi (malsample.pl) test.
diffs (110 lines):
diff --git a/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
b/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
--- a/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
+++ b/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
@@ -86,11 +86,11 @@ sub query
my $tpe = $h->getReply();
if ($tpe > 0) {
- # "regular" resultset
+ # "regular" resultset, or just "tuple"
$self->{querytype} = 1;
- $self->{id} = $h->{id};
- $self->{affrows} = $h->{count};
- $self->{colcnt} = $h->{nrcols};
+ $self->{id} = $h->{id} || -1;
+ $self->{affrows} = $h->{count} if $h->{count};
+ $self->{colcnt} = $h->{nrcols} if $h->{nrcols};
my $hdr;
foreach $hdr (@{$h->{hdrs}}) {
@@ -105,6 +105,21 @@ sub query
}
# TODO: table_name
}
+ # we must pre-fetch if this is not an SQL result-set
+ if (!$h->{count}) {
+ do {
+ my @cols = split(/,\t */, $h->{row});
+ my $i = -1;
+ while (++$i < @cols) {
+ $cols[$i] =~ s/^\[ //;
+ $cols[$i] =~ s/[ \t]+\]$//;
+ $cols[$i] = MonetDB::CLI::MapiPP->unquote($cols[$i]);
+ }
+ push(@{$self->{rows}}, [@cols]);
+ } while (($tpe = $h->getReply()) > 0);
+ $self->{affrows} = @{$self->{rows}};
+ undef $self->{id};
+ }
} elsif ($tpe == -1) {
# error
die $h->{errstr};
@@ -125,7 +140,7 @@ sub id
{
my ($self) = @_;
- return $self->{id};
+ return $self->{id} || -1;
}
sub rows_affected
@@ -166,21 +181,24 @@ sub length
sub fetch
{
my ($self) = @_;
-
+
return if ++$self->{i} >= $self->{affrows};
- my @cols = split(/,\t */, $self->{h}->{row});
- my $i = -1;
- while (++$i < @cols) {
- $cols[$i] =~ s/^\[ //;
- $cols[$i] =~ s/[ \t]+\]$//;
- $cols[$i] = MonetDB::CLI::MapiPP->unquote($cols[$i]);
+ if ($self->{id}) {
+ my @cols = split(/,\t */, $self->{h}->{row});
+ my $i = -1;
+ while (++$i < @cols) {
+ $cols[$i] =~ s/^\[ //;
+ $cols[$i] =~ s/[ \t]+\]$//;
+ $cols[$i] = MonetDB::CLI::MapiPP->unquote($cols[$i]);
+ }
+ $self->{currow} = [@cols];
+ $self->{h}->getReply();
+ } else {
+ $self->{currow} = $self->{rows}[$self->{i}];
}
- $self->{currow} = [@cols];
- $self->{h}->getReply();
-
- return $self->{colcnt};
+ return @{$self->{currow}};
}
sub field
diff --git a/monetdb5/tests/mapi/Tests/perl_dbi.stable.out
b/monetdb5/tests/mapi/Tests/perl_dbi.stable.out
--- a/monetdb5/tests/mapi/Tests/perl_dbi.stable.out
+++ b/monetdb5/tests/mapi/Tests/perl_dbi.stable.out
@@ -35,7 +35,7 @@ data sources: dbi:monetdb:
field[0]: 2, last index: 0
field[0]: 3, last index: 0
ERROR REPORTED: DBD::monetdb::st execute failed: SyntaxException:parseError:(
xyz 1);;
-SyntaxException:parseError: ^<identifier> expected at
/ufs/fabian/scratch/monetdb/Aug2011/program-x86_64/lib/perl5/vendor_perl/5.12.3/x86_64-linux/MonetDB/CLI/MapiPP.pm
line 120.
+SyntaxException:parseError: ^<identifier> expected at
/ufs/fabian/scratch/monetdb/Aug2011/program-x86_64/lib/perl5/vendor_perl/5.12.3/x86_64-linux/MonetDB/CLI/MapiPP.pm
line 125.
bun: 3, three
bun: 7, seven
rows: 2, fields: 2
diff --git a/sql/test/mapi/Tests/perl_dbi.stable.out
b/sql/test/mapi/Tests/perl_dbi.stable.out
--- a/sql/test/mapi/Tests/perl_dbi.stable.out
+++ b/sql/test/mapi/Tests/perl_dbi.stable.out
@@ -34,7 +34,7 @@ Start a simple Monet SQL interaction
data sources: dbi:monetdb:
field[0]: 2, last index: 0
field[0]: 3, last index: 0
-ERROR REPORTED: DBD::monetdb::st execute failed: syntax error, unexpected
IDENT, expecting SELECT or '(' in: "( xyz" at
/home/niels/scratch/monetdb/Linux-x86_64/lib64/perl5/vendor_perl/MonetDB/CLI/MapiPP.pm
line 110.
+ERROR REPORTED: DBD::monetdb::st execute failed: syntax error, unexpected
IDENT, expecting SELECT or '(' in: "( xyz" at
/home/niels/scratch/monetdb/Linux-x86_64/lib64/perl5/vendor_perl/MonetDB/CLI/MapiPP.pm
line 125.
bun: 3, three
bun: 7, seven
rows: 2, fields: 2
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list