Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] PQdeleteTuple function in libpq

From: Pavel Golub <pavel(at)microolap(dot)com>
To: Andrew Chernow <ac(at)esilo(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pavel Golub <pavel(at)microolap(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [HACKERS] PQdeleteTuple function in libpq
Date: 2011-06-03 05:54:13
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-interfaces
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(at)gf(dot)microolap(dot)com

In response to

pgsql-hackers by date

Next:From: Peter EisentrautDate: 2011-06-03 09:56:22
Subject: Re: storing TZ along timestamps
Previous:From: Heikki LinnakangasDate: 2011-06-03 05:52:39
Subject: Re: Estimating total amount of shared memory required by postmaster

pgsql-interfaces by date

Next:From: Miguel GarcĂ­aDate: 2011-06-13 23:12:21
Previous:From: Andrew ChernowDate: 2011-06-02 16:12:16
Subject: Re: PQdeleteTuple function in libpq

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group