Skip Menu |

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

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

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

Bug Information
Severity: (no value)
Broken in: 3.5.0
Fixed in: 3.7.1



Subject: memory management error using question mark operator
Date: Wed, 03 Jan 2018 16:42:20 +0000
To: bug-DBD-Pg [...] rt.cpan.org
From: Ryley Breiddal <ryleyb [...] gmail.com>
I filed this on github (https://github.com/bucardo/dbdpg/issues/33) already, but since CPAN seems to be more active, here is the report: I have code that uses bind parameters and the ? operator for a JSONB field. I get a variety of different errors, each time I run my test script. Test Script: use strict; use DBI; use DBD::Pg; my $connect_info = { dsn => 'dbi:Pg:dbname=xxx host=localhost port=5432', user => 'username', password => 'password' }; my $qry = q{ select count(*) from tablename where col1 = $1 and jsonb_col \? 'key' and 1 = $2 }; for (my $i=0;$i<50;$i++){ print STDERR "iteration $i..."; my $dbh = DBI->connect($connect_info->{dsn},$connect_info->{user},$connect_info->{password}); my $sqlh = $dbh->prepare($qry) || warn "Can't prepare SQL statement: $DBI::errstr\n"; $sqlh->bind_param('$1',10000); $sqlh->bind_param('$2',1); $sqlh->execute() || warn "Cant execute SQL statement: $DBI::errstr\n"; $sqlh->finish(); $dbh->disconnect(); print STDERR "done \n"; } Example output: iteration 0...done iteration 1...Statement has no placeholders to bind at test-dbd-pg.pl line 25. *** Error in `perl': double free or corruption (fasttop): 0x0000000001cb2480 *** Aborted Another run: iteration 0...done iteration 1...DBD::Pg::st execute failed: ERROR: invalid byte sequence for encoding "UTF8": 0xcf 0x03 at test-dbd-pg.pl line 28. Cant execute SQL statement: ERROR: invalid byte sequence for encoding "UTF8": 0xcf 0x03 done ... (repeated 48 more times) If I take out the bind params or only have one of them, it works fine. If I replace "jsonb_col \? 'key' " in the where clause with " jsonb_typeof(jsonb_col->'key') is not null" it works fine. System info: -Postgresql 9.6.1 -DBD::Pg 3.7.0 -DBI 1.637 Other than those, I believe stock Debian Jessie. Regards, Ryley
Thank you for reporting this. It may be the error already fixed in 22c134d850e857e1f9d0b67e2830a44c34ca623d: please test it out if you can (just pull git HEAD should work too)
Going to assume this is fixed: marking as patched for now.