5 if (defined $ENV{DBI_DSN}) {
8 plan skip_all => 'cannot test without DB info';
11 my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
12 {RaiseError => 1, AutoCommit => 0}
15 'connect with transaction'
18 $dbh->do(q{INSERT INTO test (id, name, val) VALUES (1, 'foo', 'horse')});
19 $dbh->do(q{INSERT INTO test (id, name, val) VALUES (2, 'bar', 'chicken')});
20 $dbh->do(q{INSERT INTO test (id, name, val) VALUES (3, 'baz', 'pig')});
30 my $sth = $dbh->prepare($sql);
34 while (my ($id, $name) = $sth->fetchrow_array()) {
35 if (defined($id) && defined($name)) {
50 $sth = $dbh->prepare($sql);
54 while (my ($id, $name) = $sth->fetchrow_array()) {
69 $sth = $dbh->prepare($sql);
73 while (my ($id, $name) = $sth->fetchrow_array()) {
74 if (defined($id) && defined($name)) {
84 # Attempt to test whether or not we can get unicode out of the database
85 # correctly. Reuse the previous sth.
88 skip "need Encode module for unicode tests", 3 if $@;
89 local $dbh->{pg_enable_utf8} = 1;
90 $dbh->do("INSERT INTO test (id, name, val) VALUES (4, '\001\000dam', 'cow')");
92 my ($id, $name) = $sth->fetchrow_array();
93 ok(Encode::is_utf8($name),
94 'returned data has utf8 bit set'
97 'returned utf8 data is not corrupted'
101 my ($id2, $name2) = $sth->fetchrow_array();
102 ok(! Encode::is_utf8($name2),
103 'returned ASCII data has not got utf8 bit set'
114 $sth = $dbh->prepare($sql);
115 $sth->execute('foo');
118 while (my ($id, $name) = $sth->fetchrow_array()) {
119 if (defined($id) && defined($name)) {
126 'fetch one row on name'
129 ok($dbh->disconnect(),