dbdpg icon indicating copy to clipboard operation
dbdpg copied to clipboard

Fixed call pg_pid_number

Open true-alex opened this issue 2 years ago • 3 comments

Problem: The code block returning pg_pid_number could never be called.

Fixed bug added to commit 1bfec5fc2532a2f217ceaf0fa188d8bc977b0154 on June 23, 2007

true-alex avatar Sep 29 '22 12:09 true-alex

Could you add a test case please?

esabol avatar Sep 29 '22 15:09 esabol

use strict;
use warnings;
use DBD::Pg;

my $dbh = DBI->connect("dbi:Pg:dbname=postgres;host=localhost;port=5432",
                       "username","",{AutoCommit => 1, RaiseError => 1, PrintError => 0 });
print $dbh->{pg_pid_number}."\n";
$dbh->disconnect();

On the pre-patch version, the result is "Use of uninitialized value in concatenation (.) or string at - line 7."

Returns the PID after applying the patch.

I cannot think of a case when, with careful programming, this call would be necessary, except for debugging, it was not for nothing that this call was in the code with the comment "undocumented". Unless to understand after the fork the connection is open in this process or in parent.

true-alex avatar Sep 30 '22 09:09 true-alex

@true-alex : I mean add a test to one of the t/*.t files as part of your pull request. I'm not sure, but I think it should go in t/02attribs.t. Thank you!

esabol avatar Sep 30 '22 14:09 esabol

On digging into this, it is simply getting the current PID, which is already available to programs via $$ or getpid(), so maybe we don't need to expose this at all? It's only in the code as a convenience for building the name of a prepared statement.

turnstep avatar Mar 05 '23 00:03 turnstep

Removed mention of it in bd8a349b33aa4080232f6a0380d8f0d5ebcb7dad

turnstep avatar Aug 14 '23 17:08 turnstep