Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TqQcQ-0008FV-Qw for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jan 2013 15:52:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TqQcP-0004Cr-TO for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jan 2013 15:52:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TqQcO-0004Cl-Un for pgsql-hackers@postgresql.org; Wed, 02 Jan 2013 15:52:37 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TqQcL-0000VT-NU for pgsql-hackers@postgresql.org; Wed, 02 Jan 2013 15:52:36 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id DF54728321; Wed, 2 Jan 2013 07:52:29 -0800 (PST) Received: from zcs-prod-mta-1.vmware.com (zcs-prod-mta-1.vmware.com [10.113.163.63]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id DB0AA4013F; Wed, 2 Jan 2013 07:52:29 -0800 (PST) Received: from zcs-prod-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-mta-1.vmware.com (Postfix) with ESMTP id C48BCE150A; Wed, 2 Jan 2013 07:52:29 -0800 (PST) Received: from [10.113.224.96] (unknown [10.113.160.14]) by zcs-prod-mta-1.vmware.com (Postfix) with ESMTPSA id DDE83E1517; Wed, 2 Jan 2013 07:52:27 -0800 (PST) Message-ID: <50E457C4.40709@vmware.com> Date: Wed, 02 Jan 2013 17:52:36 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 To: Marko Kreen CC: Boszormenyi Zoltan , Simon Riggs , Josh Kupershmidt , pgsql-hackers Subject: Re: allowing multiple PQclear() calls References: <50C72493.2060402@cybertec.at> <50E44E35.40900@cybertec.at> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 02.01.2013 17:27, Marko Kreen wrote: > On Wed, Jan 2, 2013 at 5:11 PM, Boszormenyi Zoltan wrote: >> 2012-12-11 16:09 keltez=E9ssel, Simon Riggs =EDrta: >> >>> On 11 December 2012 12:18, Boszormenyi Zoltan 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 versio= ns? >>> >>> 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 behaviou= r. > * 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.=20 It's the caller's responsibility to set the pointer to NULL after=20 PQclear(), same as it's the caller's responsibility to set a pointer to=20 NULL after calling free(), or to set the fd variable to -1 after calling=20 close(fd). There's plenty of precedence for this pattern, and it=20 shouldn't surprise any programmer. - Heikki --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers