Skip Menu |

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

Report information
The Basics
Id: 83017
Status: rejected
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: purification [...] ukr.net
Cc:
AdminCc:

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



Subject: [FEATURE REQUEST] DBD::Pg $sth with server-side prepares fails when executed in forked process due to unreliable prepare_name scheme
Date: Tue, 29 Jan 2013 00:13:37 +0200
To: bug-DBD-Pg [...] rt.cpan.org
From: retaliation <purification [...] ukr.net>
When $sth is prepared inside a forked process, and then executed multiple times in a forked processes, it fails in a second and all next calls due to forked process producing the same prepare_name. The current code is as follows: /* Name is "dbdpg_xPID_#", where x is 'p'ositive or 'n'egative */ sprintf(imp_sth->prepare_name,"dbdpg_%c%d_%d", (imp_dbh->pid_number < 0 ? 'n' : 'p'), abs(imp_dbh->pid_number), imp_dbh->prepare_number); I think it would be better if this code was replaced with a reliable scheme, for example UUID-based.
Not sure I understand - wouldn't forking create other problems? One cannot fork active database connections, as the messages will start interfering with each other.
DBI handles do not work across forks. Use something like DBIx::Connector to get around that -- but even still, you cannot prepare a statement handle in one process and execute it in another.