Re: allowing multiple PQclear() calls
От | Dmitriy Igrishin |
---|---|
Тема | Re: allowing multiple PQclear() calls |
Дата | |
Msg-id | CAAfz9KPSb+D-idkTKOGxDuNmh_tQaY4pqih_dZPSqnZmE0=J3w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: allowing multiple PQclear() calls (Heikki Linnakangas <hlinnakangas@vmware.com>) |
Список | pgsql-hackers |
<div dir="ltr"><br /><div class="gmail_extra"><br /><br /><div class="gmail_quote">2013/1/2 Heikki Linnakangas <span dir="ltr"><<ahref="mailto:hlinnakangas@vmware.com" target="_blank">hlinnakangas@vmware.com</a>></span><br /><blockquoteclass="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On02.01.2013 17:27, Marko Kreen wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px#ccc solid;padding-left:1ex"> On Wed, Jan 2, 2013 at 5:11 PM, Boszormenyi Zoltan<<a href="mailto:zb@cybertec.at"target="_blank">zb@cybertec.at</a>> wrote:<br /><blockquote class="gmail_quote" style="margin:00 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> 2012-12-11 16:09 keltezéssel, Simon Riggs írta:<br/><br /><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On11 December 2012 12:18, Boszormenyi Zoltan<<a href="mailto:zb@cybertec.at" target="_blank">zb@cybertec.at</a>> wrote:<br/><br /><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquoteclass="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquoteclass="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Such mechanism already exist - you just need to set<br /> your PGresult pointer to NULL after eachPQclear().<br /></blockquote><br /> So why doesn't PQclear() do that?<br /></blockquote><br /><br /> Because then PQclear()would need a ** not a *. Do you want its<br /> interface changed for 9.3 and break compatibility with previous versions?<br/></blockquote><br /> No, but we should introduce a new public API call that is safer,<br /> otherwise we getpeople continually re-inventing new private APIs that<br /> Do the Right Thing, as the two other respondents have shown.<br/><br /></blockquote><br /> How about these macros?<br /></blockquote><br /> * Use do { } while (0) around the macrosto get proper statement behaviour.<br /> * The if() is not needed, both PQclear and PQfinish do it internally.<br />* Docs<br /><br /> Should the names show somehow that they are macros?<br /> Or is it enough that it's mentioned in documentation?<br/></blockquote><br /></div> IMHO this doesn't belong into libpq, the interface is fine as it is. It's thecaller's responsibility to set the pointer to NULL after PQclear(), same as it's the caller's responsibility to set apointer to NULL after calling free(), or to set the fd variable to -1 after calling close(fd). There's plenty of precedencefor this pattern, and it shouldn't surprise any programmer.</blockquote><div style="style">True. +1</div><div style="style"><br/></div></div>-- <br />// Dmitriy.<br /><br /></div></div>
В списке pgsql-hackers по дате отправления: