Subject: | read-only undef returned for NULLs in arrays |
Date: | Mon, 5 Oct 2015 11:29:07 -0500 |
To: | bug-DBD-Pg [...] rt.cpan.org |
From: | Sergiy Zuban <s.zuban [...] gmail.com> |
In Perl 5.20+ handling of NULLs in arrays is not consistent with NULLs
in regular
columns. Code below fails in attempt to modify undef value, because it's
marked as read-only.
my $sth = $dbh->prepare(qq!SELECT 5, NULL, ARRAY[1,2,3], ARRAY[1,NULL,3]!);
$sth->execute;
while( my $row = $sth->fetchrow_arrayref )
{
$row->[0] += 0; # ok
$row->[1] += 0; # ok
$_ += 0 foreach @{ $row->[2] }; # ok
$_ += 0 foreach @{ $row->[3] }; # error: Modification of a read-only
value attempted
}
It may be related to the way how read-only and copy-on-write scalars should
be checked in perl 5.20+:
http://search.cpan.org/~rjbs/perl-5.20.0/pod/perlguts.pod#Read-Only_Values
DBI 1.634
DBD::Pg 3.5.3
PostgreSQL 9.4.4
This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux
--
Sergiy Zuban