Hej folks,

A few weeks ago after upgrading to a new Ubuntu version I started running into
a weird error in one of my perl scripts. The script uses DBI and DBD::Pg to 
communicate
with a Postgresql 9.1 database server. Most of the database stuff is hidden in 
a little
database abstraction class I have, which handles logging and error checking etc.

Anyhow, I ran into an interesting new error message with simple queries that 
return no
results and don't have any parameters -- like CREATE TABLE.
On a laptop that didn't get updated yet I ran a little test script and found 
out that
running $sth->fetchall_arrayref({}) after a CREATE TABLE would issue a 
(non-fatal) error:
---
DBD::Pg::st fetchall_arrayref failed: no statement executing
---
However, running that same test script again now dies with this error:
---
DBI bind_columns: invalid number of arguments: got handle + 0, expected handle 
+ between 1 and -1
Usage: $h->bind_columns(\$var1 [, \$var2, ...]) at /usr/lib/perl5/DBI.pm line 
2054.
----
Is this change intended, or is this the result of a missing sanity check or 
something? :)
(that first non-fatal error never showed up in my script because my db class 
didn't check
for errors after the fetchall_arrayref)

Here's a little script to reproduce the errors above:
---
#!/usr/bin/perl
use strict;
use warnings;
use DBI;

my $ds = "DBI:Pg:dbname=test;host=localhost";
my $user = 'test';
my $pw = 'test';
my $dbh = DBI->connect($ds, $user, $pw, { AutoCommit => 0, PrintError => 0 });
die "failed to connect" unless defined($dbh);
my $sth = $dbh->prepare("CREATE TABLE test ( id serial )");
die "failed to prepare" if (!$sth || $dbh->err());
$sth->execute() or die "Unable to create table";
die "failed to execute" if ($dbh->err());
# Next line dies on newer DBI versions
my $result = $sth->fetchall_arrayref({});
die "failed to fetchall_arrayref" if ($dbh->err());
$dbh->rollback() or die "Can't rollback";
$dbh->disconnect() or die "can't disconnect";
---

The upgraded Ubuntu laptop runs DBI version 1.622 and DBD::Pg 2.19.2, the older 
one has version 1.616 and DBD::Pg version 2.18.1.

Thanks for reading.

Regards,

Wouter.

Reply via email to