Mercurial > hg > monetdb-perl
comparison DBD/t/75mil.t @ 0:cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Mon, 19 Sep 2016 15:15:52 +0200 (2016-09-19) |
parents | |
children | a0ec9e080a5b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cedccb7e0143 |
---|---|
1 #!perl -I./t | |
2 | |
3 # This Source Code Form is subject to the terms of the Mozilla Public | |
4 # License, v. 2.0. If a copy of the MPL was not distributed with this | |
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
6 # | |
7 # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. | |
8 | |
9 $| = 1; | |
10 | |
11 use strict; | |
12 use warnings; | |
13 use DBI(); | |
14 use DBD_TEST(); | |
15 | |
16 use Test::More; | |
17 | |
18 if (defined $ENV{DBI_DSN}) { | |
19 if ($ENV{DBI_DSN} =~ /dbi:monetdb:/) { | |
20 plan tests => 30; | |
21 } else { | |
22 plan skip_all => 'dbi:monetdb: specific tests'; | |
23 } | |
24 } else { | |
25 plan skip_all => 'Cannot test without DB info'; | |
26 } | |
27 | |
28 pass('MIL tests'); | |
29 | |
30 $ENV{DBI_DSN} .= ';language=mil'; | |
31 | |
32 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n"; | |
33 pass('Database connection created'); | |
34 | |
35 for ( 7 .. 9 ) | |
36 { | |
37 my $sth = $dbh->prepare("print( $_ );"); | |
38 ok( defined $sth,'Statement handle defined'); | |
39 ok( $sth->execute,'execute'); | |
40 my $row = $sth->fetch; | |
41 is( $#$row, 0,'last index'); | |
42 is( $row->[0], $_,'field 0'); | |
43 } | |
44 { | |
45 local $dbh->{PrintError} = 0; | |
46 my $sth = $dbh->prepare('( xyz 1);'); | |
47 ok(!$sth->execute,'execute'); | |
48 like( $sth->errstr, qr/!ERROR:/,'Error expected'); | |
49 } | |
50 ok( $dbh->do( $_ ), $_) for 'var b := new( int, str );'; | |
51 ok( $dbh->do( $_ ), $_) for 'insert( b, 3,"T3");'; | |
52 { | |
53 my $sth = $dbh->prepare('insert( b, ?, ? );'); | |
54 ok( defined $sth,'Statement handle defined'); | |
55 ok( $sth->bind_param( 1, 7 , DBI::SQL_INTEGER() ),'bind'); | |
56 ok( $sth->bind_param( 2,'T7' ),'bind'); | |
57 ok( $sth->execute,'execute'); | |
58 } | |
59 { | |
60 my $sth = $dbh->prepare('print( b );'); | |
61 ok( defined $sth,'Statement handle defined'); | |
62 ok( $sth->execute,'execute'); | |
63 for ( 3, 7 ) | |
64 { | |
65 my $row = $sth->fetch; | |
66 is( $row->[0], $_ ,"fetch $_"); | |
67 is( $row->[1],"T$_","fetch T$_"); | |
68 } | |
69 } | |
70 ok( $dbh->rollback,'Rollback'); | |
71 ok( $dbh->disconnect,'Disconnect'); |