Changeset: a0b0ed79f8ab for monetdb-perl URL: https://dev.monetdb.org/hg/monetdb-perl?cmd=changeset;node=a0b0ed79f8ab Added Files: DBD/t/15many.t Modified Files: DBD/t/11prep.t DBD/t/41ddtbl.t Branch: default Log Message:
Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here diffs (126 lines): diff --git a/DBD/t/11prep.t b/DBD/t/11prep.t --- a/DBD/t/11prep.t +++ b/DBD/t/11prep.t @@ -10,13 +10,14 @@ use strict; use warnings; +use Data::Dumper; use DBI(); use DBD_TEST(); use Test::More; if (defined $ENV{DBI_DSN}) { - plan tests => 15; + plan tests => 19; } else { plan skip_all => 'Cannot test without DB info'; } @@ -42,7 +43,7 @@ pass('Database connection created'); local $dbh->{PrintError} = 0; local $dbh->{RaiseError} = 1; ok( !eval{ $dbh->do("DROP TABLE $tbl") },"DROP TABLE $tbl"); - print $@, "\n"; + ok( $@ =~ /no such table/, "DROP TABLE failed for the right reason"); } ok( $dbh->do("CREATE TABLE $tbl( chr char( 1 ) )"),"CREATE TABLE $tbl"); @@ -59,4 +60,13 @@ ok( !( $sth = undef ),'Set sth to undefi #ok( !( $sth = undef ),'Set sth to undefined'); ok( $dbh->do("DROP TABLE $tbl"),"DROP TABLE $tbl"); +# Bug 3235 +ok( $sth = $dbh->prepare("SELECT 0"), "SELECT 0"); +ok( $sth->execute, 'Execute'); +my $res = $sth->fetchall_arrayref; +$Data::Dumper::Terse = 1; # don't output names where feasible +my $dumped = Dumper($res); +$dumped =~ s/\s+/ /gm; +ok( $res->[0]->[0] == 0, "yields $dumped"); + ok( $dbh->disconnect,'Disconnect'); diff --git a/DBD/t/15many.t b/DBD/t/15many.t new file mode 100644 --- /dev/null +++ b/DBD/t/15many.t @@ -0,0 +1,50 @@ +#!perl -I./t + +# 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 - 2020 MonetDB B.V. + +$| = 1; + +use strict; +use warnings; +use DBI(); +use DBD_TEST(); + +use Test::More; + +if (defined $ENV{DBI_DSN}) { + plan tests => 4; +} else { + plan skip_all => 'Cannot test without DB info'; +} + +my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n"; +pass('Database connection created'); + +# fetch 1000 of the 5000 rows, see Bug 2889 +my $query = qq{ + SELECT * FROM sys.generate_series(0,5000); +}; +my $sth = $dbh->prepare($query); +$sth->execute; +my $r = $sth->fetchall_arrayref(undef, 1000); +my $count = scalar(@{$r}); # don't say perl isn't weird +ok($count == 1000, 'got 1000 rows as requested'); + +# fetch a lot of rows and see we don't get disconnected halfway, see Bug 2897 +$query = qq{ + SELECT * FROM tables, sys.generate_series(0,1000); +}; +$sth = $dbh->prepare($query); +$sth->execute; +$r = $sth->fetchall_arrayref(); +$count = scalar(@{$r}); +ok($count % 1000 == 0, "got $count rows"); + + + + +ok( $dbh->disconnect,'Disconnect'); diff --git a/DBD/t/41ddtbl.t b/DBD/t/41ddtbl.t --- a/DBD/t/41ddtbl.t +++ b/DBD/t/41ddtbl.t @@ -16,7 +16,7 @@ use DBD_TEST(); use Test::More; if (defined $ENV{DBI_DSN}) { - plan tests => 26; + plan tests => 28; } else { plan skip_all => 'Cannot test without DB info'; } @@ -165,6 +165,16 @@ if ( $sth ) { } $sth = undef; +# Bug 2885 +ok($dbh->table_info('', '%', '%')); +my $stderr; +eval { + local *STDERR; + open STDERR, ">>", \$stderr; + $sth = $dbh->table_info('foo', '%', '%'); +}; +ok($stderr =~ /not support multiple catalogs/, 'MonetDB does not have catalog') + } # ----------------------------------------------------------------------------- _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list