From: | Dmitriy Igrishin <dmitigr(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | Marko Kreen <markokr(at)gmail(dot)com>, Boszormenyi Zoltan <zb(at)cybertec(dot)at>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Josh Kupershmidt <schmiddy(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: allowing multiple PQclear() calls |
Date: | 2013-01-02 16:30:05 |
Message-ID: | CAAfz9KPSb+D-idkTKOGxDuNmh_tQaY4pqih_dZPSqnZmE0=J3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2013/1/2 Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
> On 02.01.2013 17:27, Marko Kreen wrote:
>
>> On Wed, Jan 2, 2013 at 5:11 PM, Boszormenyi Zoltan<zb(at)cybertec(dot)at>
>> wrote:
>>
>>> 2012-12-11 16:09 keltezéssel, Simon Riggs írta:
>>>
>>> On 11 December 2012 12:18, Boszormenyi Zoltan<zb(at)cybertec(dot)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?
>>
>
> 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.
True. +1
--
// Dmitriy.
From | Date | Subject | |
---|---|---|---|
Next Message | Kohei KaiGai | 2013-01-02 16:35:13 | Re: Review of Row Level Security |
Previous Message | Alvaro Herrera | 2013-01-02 16:28:19 | Re: fix bgworkers in EXEC_BACKEND |