Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 112309
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: andreas.guldstrand [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 3.6.0



Subject: $DBDPG_DEFAULT doesn't seem to work properly
Date: Tue, 23 Feb 2016 13:35:07 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Andreas Guldstrand <andreas.guldstrand [...] gmail.com>
When using $DBDPG_DEFAULT the first time in a script, it seems to simply stringify as if I had put it in quotes. Example script: #!/usr/bin/env perl use DBI; my $dbh = DBI->connect('dbi:Pg:dbname=test', '', ''); $dbh->do('create table if not exists test ( id serial primary key, var varchar not null default \'Test\')'); $dbh->do('insert into test (var) values (?)', {}, $DBD::Pg::DBDPG_DEFAULT); my $ref = $dbh->selectall_arrayref('select var from test'); print $ref->[0][0], "\n"; -- Expected output: Test -- Actual output: DBD::Pg::DefaultValue=HASH(0x210de88) If the column was an int, this would have made it error instead: #!/usr/bin/env perl use DBI; my $dbh = DBI->connect('dbi:Pg:dbname=test', '', ''); $dbh->do('create table if not exists test ( id serial primary key, var int not null default 121)'); $dbh->do('insert into test (var) values (?)', {}, $DBD::Pg::DBDPG_DEFAULT); my $ref = $dbh->selectall_arrayref('select var from test'); print $ref->[0][0], "\n"; -- Expected output: 121 -- Actual output: DBD::Pg::db do failed: ERROR: invalid input syntax for integer: "DBD::Pg::DefaultValue=HASH(0xebfe78)" at ./test.pl line 5. However, every subsequent use of $DBDPG_DEFAULT in the same script works fine: #!/usr/bin/env perl use DBI; my $dbh = DBI->connect('dbi:Pg:dbname=test', '', ''); $dbh->do('create table if not exists test ( id serial primary key, var varchar not null default \'Test\')'); $dbh->do('insert into test (var) values (?)', {}, $DBD::Pg::DBDPG_DEFAULT); $dbh->do('insert into test (var) values (?)', {}, $DBD::Pg::DBDPG_DEFAULT); my $ref = $dbh->selectall_arrayref('select var from test'); print $ref->[0][0], "\n"; print $ref->[1][0], "\n"; -- Expected output: Test Test -- Actual output: DBD::Pg::DefaultValue=HASH(0x20abf88) Test (Between every run, I execute `dropdb test; createdb test;`)
Subject: [rt.cpan.org #112309] My versions of relevant things
Date: Tue, 23 Feb 2016 13:48:09 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Andreas Guldstrand <andreas.guldstrand [...] gmail.com>
perl: 5.22.0 DBI: 1.634 DBD::Pg: 3.5.3 Postgresql: 9.4.5
Thanks for the report: can reproduce. Looks like the test in dbdimp.c for SvAMAGIC() is giving a false positive.
For the records: Looks like sometimes DEFAULT_VALUES arrives as an IV with RV pointing to the object as expected. The second time through it has change to a PV, which is why this error was so hard to catch. We put a !SvAMAGIC check in to make sure we don't croak about binding references for magic scalars, but we cannot do that globally anymore, so we need to make sure we check these particular ones (defaultvalue and current)
Should be fixed in 39299909de24d8c74db0df1160bb18137ff041de Thank you for the report and test case.
Resolved in version 3.6.0