agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Heikki Linnakangas <[email protected]>
To: Marko Kreen <[email protected]>
Cc: Boszormenyi Zoltan <[email protected]>
Cc: Simon Riggs <[email protected]>
Cc: Josh Kupershmidt <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: allowing multiple PQclear() calls
Date: Wed, 02 Jan 2013 17:52:36 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACMqXCKM-ooPR=qXpvauvHi1ZjdijijE0Jjtum0SAZAow7Ri-g@mail.gmail.com>
References: <CAK3UJREYBP9rVjgra65NO36bvAJeY9SE_qnXhFCk+tzpuviE2w@mail.gmail.com>
	<CACMqXCJVVJ_6WsOM-mo5h4tL=wYiv-qKz0k_0O+SuFhLsbp-qQ@mail.gmail.com>
	<CA+U5nML7ecex7oF83HGvozc=ww97fkcUvMSv7eXYgCNx437LKQ@mail.gmail.com>
	<[email protected]>
	<CA+U5nML4jNyCGMfXZJ94p7NBxQkVsVL+LrWeS26dd1rVNboPxQ@mail.gmail.com>
	<[email protected]>
	<CACMqXCKM-ooPR=qXpvauvHi1ZjdijijE0Jjtum0SAZAow7Ri-g@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-hackers>

On 02.01.2013 17:27, Marko Kreen wrote:
> On Wed, Jan 2, 2013 at 5:11 PM, Boszormenyi Zoltan<[email protected]>  wrote:
>> 2012-12-11 16:09 keltezéssel, Simon Riggs írta:
>>
>>> On 11 December 2012 12:18, Boszormenyi Zoltan<[email protected]>  wrote:
>>>
>>>>>> 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?
>>>
>>> No, but we should introduce a new public API call that is safer,
>>> otherwise we get people continually re-inventing new private APIs that
>>> Do the Right Thing, as the two other respondents have shown.
>>>
>>
>> How about these macros?
>
> * Use do { } while (0) around the macros to get proper statement behaviour.
> * The if() is not needed, both PQclear and PQfinish do it internally.
> * Docs
>
> Should the names show somehow that they are macros?
> Or is it enough that it's mentioned in documentation?

IMHO this doesn't belong into libpq, the interface is fine as it is. 
It's the caller's responsibility to set the pointer to NULL after 
PQclear(), same as it's the caller's responsibility to set a pointer to 
NULL after calling free(), or to set the fd variable to -1 after calling 
close(fd). There's plenty of precedence for this pattern, and it 
shouldn't surprise any programmer.

- Heikki


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (17+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: allowing multiple PQclear() calls
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox