Subject: | $sth->bind_col(...) does not work with array columns |
The following script demonstrates the bug:
---
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect('dbi:Pg:dbname=test', 'myuser', 'mysecret', {
AutoCommit => 1, RaiseError => 1 });
$dbh->do('CREATE TABLE array_test (id int, nums INT[])');
$dbh->do(q(INSERT INTO array_test (id, nums) VALUES (1, '{1,2,3}')));
my $sth = $dbh->prepare('SELECT id, nums FROM array_test');
$sth->execute;
my($id, $nums);
$sth->bind_col(1, \$id);
$sth->bind_col(2, \$nums);
$sth->fetch;
print "DBD::Pg version $DBD::Pg::VERSION\n";
print "id: $id, nums: $nums\n";
$sth->finish;
$dbh->do('DROP TABLE array_test');
$dbh->disconnect;
---
It works correctly with DBD::Pg version 1.49, printing:
DBD::Pg version 1.49
id: 1, nums: {1,2,3}
but with DBD::Pg, it prints the following:
DBD::Pg version 2.0.0
id: 1, nums:
Setting $dbh->{'pg_expand_array'} = 0 is a workaround, but bind_col()
should definitely work even if pg_expand_array is turned on. Since this
is the default, it is even more important that this bug get fixed.