Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8D0ABB61DE2; Fri, 3 Jun 2011 02:54:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21541-09; Fri, 3 Jun 2011 05:54:20 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 54607B61D8D; Fri, 3 Jun 2011 02:54:20 -0300 (ADT) Received: by fxm17 with SMTP id 17so1121090fxm.19 for ; Thu, 02 Jun 2011 22:54:19 -0700 (PDT) Received: by 10.223.73.139 with SMTP id q11mr1685278faj.56.1307080459523; Thu, 02 Jun 2011 22:54:19 -0700 (PDT) Received: from [192.168.1.104] (101-20-133-95.pool.ukrtel.net [95.133.20.101]) by mx.google.com with ESMTPS id n15sm387318fag.18.2011.06.02.22.54.17 (version=SSLv3 cipher=OTHER); Thu, 02 Jun 2011 22:54:18 -0700 (PDT) Date: Fri, 3 Jun 2011 08:54:13 +0300 From: Pavel Golub Reply-To: Pavel Golub Organization: Microolap X-Priority: 3 (Normal) Message-ID: <163769889.20110603085413@gf.microolap.com> To: Andrew Chernow CC: Alvaro Herrera , Pavel Golub , PostgreSQL Hackers , pgsql-interfaces Subject: Re: [HACKERS] PQdeleteTuple function in libpq In-Reply-To: <4DE7B660.8040704@esilo.com> References: <147534417.20110601184310@gf.microolap.com> <4DE6A5B7.2070700@esilo.com> <707574086.20110602112826@gf.microolap.com> <4DE79A58.4010608@esilo.com> <1307026778-sup-415@alvh.no-ip.org> <4DE7B660.8040704@esilo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/10 X-Sequence-Number: 6955 Hello, Andrew. You wrote: AC> On 6/2/2011 11:02 AM, Alvaro Herrera wrote: >> Excerpts from Andrew Chernow's message of jue jun 02 10:12:40 -0400 2011: >> >>>> Andrew, why we have PQmakeEmptyPGresult, PQcopyResult, >>>> PQsetResultAttrs, PQsetvalue and PQresultAlloc in this case? Of course >>>> there's no big deal with their absence but let's be consistent. >>> >>> I'm not entirely sure what you are trying to do, but can't you use >>> PQmakeEmptyPGresult, PQsetResultAttrs and PQsetvalue to construct a >>> result that excludes the tuples you don't want followed by a >>> PQclear(initial_result)? >> >> Seems pretty wasteful if you want to delete a single tuple from a large >> result. I think if you desired to compact the result to free some >> memory after deleting a large fraction of the tuples in the result it >> could be useful to do that, otherwise just live with the unused holes in >> the storage area as suggested by Pavel. >> AC> Another solution is to manually cursor through the set (like grab 1000 AC> tuples at a time) and copy the set to your own structure. That way, the AC> temporary double memory to perform the copy is not as big of a hit. By AC> using your own structure, you can organize the memory in a fashion that AC> is optimized for your requirement. I agree that there are a lot of possible solutions. But let me compare my function with official PQsetValue: 1. Both allow changing data in PGresult 2. Both allow changing tuples number 3. Both leave old data untouchable to be eliminated by PQClear 4. PQsetValue allocates more memory during work, mine not (it even may allow deleted tuple to be reused with a little fix) So why shouldn't we have both of them to make life easier? -- With best wishes, Pavel mailto:pavel@gf.microolap.com