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

From Marko Kreen
Subject Re: allowing multiple PQclear() calls
Date
Msg-id CACMqXCKM-ooPR=qXpvauvHi1ZjdijijE0Jjtum0SAZAow7Ri-g@mail.gmail.com
Whole thread Raw
In response to Re: allowing multiple PQclear() calls  (Boszormenyi Zoltan <zb@cybertec.at>)
Responses Re: allowing multiple PQclear() calls
Re: allowing multiple PQclear() calls
List pgsql-hackers
On Wed, Jan 2, 2013 at 5:11 PM, Boszormenyi Zoltan <zb@cybertec.at> wrote:
> 2012-12-11 16:09 keltezéssel, Simon Riggs írta:
>
>> On 11 December 2012 12:18, Boszormenyi Zoltan <zb@cybertec.at> 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?

--
marko



pgsql-hackers by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: allowing multiple PQclear() calls
Next
From: Kohei KaiGai
Date:
Subject: Re: ALTER .. OWNER TO error mislabels schema as other object type