X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F05B32C62E for ; Fri, 15 Oct 2004 15:21:48 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33247-08 for ; Fri, 15 Oct 2004 14:21:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2D1D632C61B for ; Fri, 15 Oct 2004 15:21:43 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i9FELUbF008900; Fri, 15 Oct 2004 10:21:30 -0400 (EDT) To: Christoph Haller Cc: sad , pgsql-sql@postgresql.org Subject: Re: libpq-fe: PQgetvalue() ? In-reply-to: <416F90ED.A65CB3B1@rodos.fzk.de> References: <200410141634.22769.sad@bankir.ru> <416F90ED.A65CB3B1@rodos.fzk.de> Comments: In-reply-to Christoph Haller message dated "Fri, 15 Oct 2004 10:57:18 +0200" Date: Fri, 15 Oct 2004 10:21:29 -0400 Message-ID: <8899.1097850089@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/100 X-Sequence-Number: 19203 Christoph Haller writes: > You cannot PQclear(pgresult_varible) while cstring_varible is in use. > You do not need to free cstring_variable, PQclear(pgresult_varible) will do. > I personally prefer to allocate local memory, "strcpy" PQgetvalue, > and then PQclear. But that's a matter of taste, I suppose. That is surely overkill. PQgetvalue doesn't allocate new memory for its result. The docs are reasonably clear, I thought: The pointer returned by PQgetvalue points to storage that is part of the PGresult structure. One should not modify the data it points to, and one must explicitly copy the data into other storage if it is to be used past the lifetime of the PGresult structure itself. regards, tom lane