Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: david_dick [...] iprimus.com.au
Cc:
AdminCc:

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



Subject: forking confuses server side prepared statements
When using server side prepare statements and forking a child process, even if the child process is marked with an 'InactiveDestroy' flag, the parent process immediately hits an error when it attempts to reuse a pre-prepared statement. See attached file to reproduce problem.
#! /usr/local/bin/perl -wT use strict; use DBI(); MAIN: { $ENV{'DBI_DSN'} ||= 'dbi:Pg:dbname=template1'; $ENV{'DBI_USER'} ||= 'postgres'; $ENV{'DBI_PASS'} ||= ''; my ($dbh) = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, {RaiseError => 1, PrintError => 0, AutoCommit => 0}); # $dbh->{pg_server_prepare} = 0; my ($sql) = qq[SELECT * FROM pg_tables WHERE tablename LIKE ?]; my ($sth) = $dbh->prepare($sql); $sth->execute('foo'); $sth->finish(); my ($pid); if ($pid = fork()) { waitpid($pid, 0); unless ($? == 0) { die("Child failed to execute successfully\n"); } } elsif (defined $pid) { $dbh->{'InactiveDestroy'} = 1; exit(0); } else { die("Failed to fork:$!\n"); } $sth->execute('foo'); $sth->finish(); $dbh->disconnect(); }
From: bkw [...] weisshuhn.de
[DDICK - Sat Oct 8 00:20:46 2005]: Show quoted text
> When using server side prepare statements and forking a child process, > even if the child process is marked with an 'InactiveDestroy' flag, > the parent process immediately hits an error when it attempts to > reuse a pre-prepared statement. See attached file to reproduce > problem.
I found that setting pg_server_prepare to 0 works around this for now.