Re: allowing multiple PQclear() calls - Mailing list pgsql-hackers

From Boszormenyi Zoltan
Subject Re: allowing multiple PQclear() calls
Date
Msg-id 50C72493.2060402@cybertec.at
Whole thread Raw
In response to Re: allowing multiple PQclear() calls  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: allowing multiple PQclear() calls  (Josh Kupershmidt <schmiddy@gmail.com>)
Re: allowing multiple PQclear() calls  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
2012-12-11 12:45 keltezéssel, Simon Riggs írta:
> On 11 December 2012 10:39, Marko Kreen <markokr@gmail.com> wrote:
>> On Tue, Dec 11, 2012 at 6:59 AM, Josh Kupershmidt <schmiddy@gmail.com> wrote:
>>> Would it be crazy to add an "already_freed" flag to the pg_result
>>> struct which PQclear() would set, or some equivalent safety mechanism,
>>> to avoid this hassle for users?
>> Such mechanism already exist - you just need to set
>> your PGresult pointer to NULL after each PQclear().
> So why doesn't PQclear() do that?

Because then PQclear() would need a ** not a *. Do you want its
interface changed for 9.3 and break compatibility with previous versions?
Same can be said for e.g. PQfinish(). Calling it again crashes your client,
as I have recently discovered when I added atexit() functions that
does "if (conn) PQfinish(conn);"  and the normal flow didn't do conn = NULL;
after it was done.

>
> Maintaining a pointer to something that no longer exists seems strange.
>
> Under what conditions would anybody want the old pointer value after PQclear() ?


>


--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de     http://www.postgresql.at/




pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: allowing multiple PQclear() calls
Next
From: Josh Kupershmidt
Date:
Subject: Re: allowing multiple PQclear() calls