annotate DBD/t/15many.t @ 26:a0b0ed79f8ab

Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 15 Dec 2020 15:05:24 +0100 (2020-12-15)
parents
children 536255410444
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
1 #!perl -I./t
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
2
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
3 # This Source Code Form is subject to the terms of the Mozilla Public
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
6 #
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
7 # Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
8
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
9 $| = 1;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
10
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
11 use strict;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
12 use warnings;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
13 use DBI();
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
14 use DBD_TEST();
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
15
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
16 use Test::More;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
17
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
18 if (defined $ENV{DBI_DSN}) {
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
19 plan tests => 4;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
20 } else {
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
21 plan skip_all => 'Cannot test without DB info';
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
22 }
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
23
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
24 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n";
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
25 pass('Database connection created');
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
26
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
27 # fetch 1000 of the 5000 rows, see Bug 2889
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
28 my $query = qq{
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
29 SELECT * FROM sys.generate_series(0,5000);
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
30 };
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
31 my $sth = $dbh->prepare($query);
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
32 $sth->execute;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
33 my $r = $sth->fetchall_arrayref(undef, 1000);
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
34 my $count = scalar(@{$r}); # don't say perl isn't weird
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
35 ok($count == 1000, 'got 1000 rows as requested');
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
36
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
37 # fetch a lot of rows and see we don't get disconnected halfway, see Bug 2897
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
38 $query = qq{
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
39 SELECT * FROM tables, sys.generate_series(0,1000);
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
40 };
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
41 $sth = $dbh->prepare($query);
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
42 $sth->execute;
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
43 $r = $sth->fetchall_arrayref();
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
44 $count = scalar(@{$r});
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
45 ok($count % 1000 == 0, "got $count rows");
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
46
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
47
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
48
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
49
a0b0ed79f8ab Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
50 ok( $dbh->disconnect,'Disconnect');