Re: [PATCHES] libpq type system 0.9a

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Andrew Chernow" <ac(at)esilo(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Bruce Momjian" <bruce(at)momjian(dot)us>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Greg Sabino Mullane" <greg(at)turnstep(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] libpq type system 0.9a
Date: 2008-04-09 15:33:43
Message-ID: b42b73150804090833s62f696c4i9c18f5a04e9e7c51@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Wed, Apr 9, 2008 at 11:17 AM, Andrew Chernow <ac(at)esilo(dot)com> wrote:
> We can read args->get.result properties using PQfuncs with no problem. But
> we have no way of assign these values to our result 'r'.

By the way, our decision to 'create the result' when exposing arrays
and composites saved us from creating lot of interface code to access
these structures from user code...the result already gave us what we
needed. Just in case anybody missed it, the way arrays of composites
would be handled in libpq would be like this:

PGarray array;
PQgetf(res, 0, "%foo[]", 0, &array); // foo being a composite(a int, b float)
PQclear(res);

for (i = 0; i < PQntuples(array.res); i++)
{
a int;
b float;
PQgetf(array.res, i, "%int %float", 0, &a, 1, &b);
[...]
}
PQclear(array.res);

In the getf call, the brackets tell libpq that this is an array and a
new result is created to present the array...one column for simple
array, multiple columns if the array is composite. This can be
recursed if the composite is nested. We support all the PGget*
functions for the newly created array, providing the OIDs of the
internal composite elements for example. This is, IMO, payoff of
doing all the work with the type handlers...we don't have to make a
special version of getf that operates over arrays for example.

The upshot of this is that, however separation occurs, the PGresult is
a first class citizen to the types library.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Chernow 2008-04-09 15:37:36 Re: [PATCHES] libpq type system 0.9a
Previous Message Tom Lane 2008-04-09 15:32:03 Re: [PATCHES] libpq type system 0.9a

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Chernow 2008-04-09 15:37:36 Re: [PATCHES] libpq type system 0.9a
Previous Message Tom Lane 2008-04-09 15:32:03 Re: [PATCHES] libpq type system 0.9a