Mercurial > hg > monetdb-perl
comparison DBD/t/11prep.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 plan tests => 15; | |
20 } else { | |
21 plan skip_all => 'Cannot test without DB info'; | |
22 } | |
23 | |
24 pass('Simple prepare/execute/finish tests'); | |
25 | |
26 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n"; | |
27 pass('Database connection created'); | |
28 | |
29 my $tbl = $DBD_TEST::table_name; | |
30 | |
31 { | |
32 local ($dbh->{PrintError}, $dbh->{RaiseError}, $dbh->{Warn}); | |
33 $dbh->{PrintError} = 0; $dbh->{RaiseError} = 0; $dbh->{Warn} = 0; | |
34 $dbh->do("DROP TABLE $tbl"); | |
35 } | |
36 | |
37 ok( $dbh->disconnect,'Disconnect'); | |
38 | |
39 $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n"; | |
40 pass('Database connection created'); | |
41 { | |
42 local $dbh->{PrintError} = 0; | |
43 local $dbh->{RaiseError} = 1; | |
44 ok( !eval{ $dbh->do("DROP TABLE $tbl") },"DROP TABLE $tbl"); | |
45 print $@, "\n"; | |
46 } | |
47 ok( $dbh->do("CREATE TABLE $tbl( chr char( 1 ) )"),"CREATE TABLE $tbl"); | |
48 | |
49 my $sth; | |
50 ok( $sth = $dbh->prepare("SELECT * FROM $tbl"),"SELECT * FROM $tbl"); | |
51 ok( $sth->execute,'Execute'); | |
52 ok( $sth->finish,'Finish'); | |
53 ok( $sth = $dbh->prepare("SELECT * FROM $tbl"),"SELECT * FROM $tbl"); | |
54 ok( $sth->finish,'Finish'); | |
55 ok( $sth = $dbh->prepare("SELECT * FROM $tbl"),"SELECT * FROM $tbl"); | |
56 ok( !( $sth = undef ),'Set sth to undefined'); | |
57 #ok( $sth = $dbh->prepare("SELECT * FROM $tbl", { monetdb_ => ... } ),"SELECT * FROM $tbl ( monetdb_ => ... )"); | |
58 #ok( $sth->execute,'Execute'); | |
59 #ok( !( $sth = undef ),'Set sth to undefined'); | |
60 ok( $dbh->do("DROP TABLE $tbl"),"DROP TABLE $tbl"); | |
61 | |
62 ok( $dbh->disconnect,'Disconnect'); |