Re: Allow substitute allocators for PGresult. - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: Allow substitute allocators for PGresult.
Date
Msg-id 20111112220223.GR24234@tamriel.snowman.net
Whole thread Raw
In response to Re: Allow substitute allocators for PGresult.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Well, loading data in a form whereby the application can access it
> without going through the PGresult accessor functions would be an
> entirely different (and vastly larger) project.

Looking through the thread, I agree that it's a different thing than
what's being discussed here.

> I'm not sure I want
> to open that can of worms --- it seems like you could write a huge
> amount of code trying to provide every format someone might want,
> and still find that there were impedance mismatches for many
> applications.

The OCI approach is actually very similar to how we handle our
catalogs internally..  Imagine you define a C struct which matched your
table structure, then you allocate 5000 (or however) of those, give the
base pointer to the 'getResult' call and a integer array of offsets into
that structure for each of the columns.  There might have been a few
other minor things (like some notion of how to handle NULLs), but it was
pretty straight-forward from the C perspective, imv.

Trying to provide alternative formats (I'm guessing you were referring
to something like XML..?  Or some complex structure?) would certainly be
a whole different ballgame.
Thanks,
    Stephen

> AIUI Kyotaro-san is just suggesting that the app should be able to
> provide a substitute malloc function for use in allocating PGresult
> space (and not, I think, anything else that libpq allocates internally).
> Basically this would allow PGresults to be cleaned up with methods other
> than calling PQclear on each one.  It wouldn't affect how you'd interact
> with one while you had it.  That seems like pretty much exactly what we
> want for preventing memory leaks in the backend; but is it going to be
> useful for other apps?
>
>             regards, tom lane

pgsql-hackers by date:

Previous
From: Matteo Beccati
Date:
Subject: Re: Allow substitute allocators for PGresult.
Next
From: Florian Pflug
Date:
Subject: Re: why do we need two snapshots per query?