Re: [HACKERS] Custom allocators in libpq

Поиск
Список
Период
Сортировка
От Aaron Patterson
Тема Re: [HACKERS] Custom allocators in libpq
Дата
Msg-id 20170828195920.GA74042@TC.local
обсуждение исходный текст
Ответ на Re: [HACKERS] Custom allocators in libpq  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Aug 28, 2017 at 03:11:26PM -0400, Tom Lane wrote:
> Aaron Patterson <tenderlove@ruby-lang.org> writes:
> > I would like to be able to configure libpq with custom malloc functions.
> 
> I can see the potential value of this ...
> 
> > This patch doesn't replace all malloc calls to the configured ones, just
> > the mallocs related to creating result objects (which is what I'm
> > concerned with).
> 
> ... but it seems like you're giving up a lot of the possible uses if
> you don't make it apply uniformly.

I'm happy to make the changes uniformly!  I'll do that and update the
patch.

> I admit I'm not sure how we'd handle
> the initial creation of a connection object with a custom malloc.  The
> obvious solution of requiring the functions to be specified at PQconnect
> time seems to require Yet Another PQconnect Variant, which is not very
> appetizing.

Other libraries I've worked with allow me to malloc a struct, then pass
it to an initialization function.  This might take a bit of refactoring,
like introducing a new `PQconnectStart`, but might be worth while.

> I also wonder whether you wouldn't want a passthrough argument.
> For instance, one of the use-cases that springs to mind immediately is
> teaching postgres_fdw and dblink to use this so that their result objects
> are palloc'd not malloc'd, allowing removal of lots of PG_TRY overhead.
> While I suppose we could have the hook functions always allocate in
> CurrentMemoryContext, it'd likely be useful to be able to specify
> "use context X" at creation time.

We don't need this for the Ruby wrapper, but I've seen other libraries
do it.  I'm happy to add it as well.

Thanks!

-- 
Aaron Patterson
http://tenderlovemaking.com/



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] expanding inheritance in partition bound order
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] Custom allocators in libpq