Re: [PATCH] binary heap implementation - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [PATCH] binary heap implementation
Date
Msg-id CA+TgmoZURwA13OhpjVmUtkikqhsNBSNhoWa-qYTCuUETN=0rsg@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] binary heap implementation  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: [PATCH] binary heap implementation
List pgsql-hackers
On Thu, Nov 15, 2012 at 11:22 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> On 2012-11-14 18:41:12 +0530, Abhijit Menon-Sen wrote:
>> There are two or three places in the Postgres source that implement heap
>> sort (e.g. tuplesort.c, nodeMergeAppend.c), and it's also needed by the
>> BDR code. It seemed reasonable to factor out the functionality.
>
> pg_dump also contains a binary heap implementation if memory serves
> right which makes me wonder whether we should try binaryheap.[ch]
> backend clean... It currently uses palloc/pfree.
>
> Too bad we don't have a memory allocation routine which easily works in
> the backend and frontend... palloc references MemoryContextAlloc and
> CurrentMemoryContext so thats not that easy to emulate.

I think there's a clear need for a library of code that can be shared
by frontend and backend code.  I don't necessarily want to punt
everything into libpq, though.  What I wonder if we might do is create
something like src/lib/pgguts that contains routines for memory
allocation, error handling, stringinfos (so that you don't have to use
PQexpBuffer in the frontend and StringInfo in the backend), etc. and
make that usable by both front-end and back-end code.  I think that
would be a tremendously nice thing to have.

I don't think we should make it this patch's problem to do that, but
I'd be strongly in favor of such a thing if someone wants to put it
together.  It's been a huge nuisance for me in the past and all
indicates are that the work you're doing on LR is just going to
exacerbate that problem.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [PATCH 03/14] Add simple xlogdump tool
Next
From: Andres Freund
Date:
Subject: Re: [PATCH 03/14] Add simple xlogdump tool