Skip site navigation (1) Skip section navigation (2)

Re: BUG #3031: PHP (and others?) cannot close a connection when "in" a COPY-statement

From: Arjen van der Meijden <acmmailing(at)tweakers(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3031: PHP (and others?) cannot close a connection when "in" a COPY-statement
Date: 2007-02-20 07:21:25
Message-ID: 45DAA175.2040705@tweakers.net (view raw or flat)
Thread:
Lists: pgsql-bugs
On 20-2-2007 8:07 Tom Lane wrote:
> It's surely incorrect as a means of getting out of a COPY state.  To
> tell the truth, if their intention is to close the connection
> unceremoniously, they should just do that, ie PQfinish or just quit
> the application.  So I'd suggest removing that loop.

I think its meant as a generic way of closing the connection. I.e. not 
only to close the connection as a last-resort "clean things up before we 
return to the webserver/console, but also half-way if the client asks 
for it (as the code behind 'pg_close').

I.e. you don't want memory-leaks to build up because someone, for some 
reason, needs something like this and the internal code doesn't clean up 
something that easily could've been cleaned up:

while($something)
{
  $c = pg_connect("..");
  // Queries
  pg_close($c);
}

Although obviously, that kind of code is not so common and should only 
be used if there is a very good reason not to open/close the connection 
outside the loop. Besides that, its very common in php to just leave the 
garbage to the php-engine, probably even worse than in Java.
I guess, that if they really wanted to keep something like this 
while-loop, they need to request the result-status and if its not the 
result of a finished query (either failed, ok, empty, etc) they should 
send a cancel request?

Anyway, I'll add your advice to that bug-report.

Best regards,

Arjen

In response to

pgsql-bugs by date

Next:From: Michael MeskesDate: 2007-02-20 13:09:32
Subject: Re: BUG #2973: Compile Error with MIPSpro compiler
Previous:From: Tom LaneDate: 2007-02-20 07:07:52
Subject: Re: BUG #3031: PHP (and others?) cannot close a connection when "in" a COPY-statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group