Re: Proposed new libpq API

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Chris Bitmead <chrisb(at)nimrod(dot)itg(dot)telstra(dot)com(dot)au>
Cc: "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgresql(dot)org>, pgsql-oo(at)postgresql(dot)org, Chris Bitmead <chris(at)bitmead(dot)com>
Subject: Re: Proposed new libpq API
Date: 2000-07-05 08:05:18
Message-ID: 3962EC3E.BAEFF960@tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chris Bitmead wrote:
>
> I've been thinking about what changes are necessary to the libpq
> interface to support returning variable type tuples. This was
> discussed a number of months back but an exact interface wasn't nailed
> down.

Let me propose an additional possible solution for the most common case
needing to return multiple types of tuples, the case of select ** --
just
have a tupletype for each tuple, possibly as an implies field and return
NULL
for missing fields (returning nulls is cheap - each only occupies one
bit)
so that

SELECT user
UNION
SELECT nextval('myseq');

would return a result with the following structure

type() | user (text) | nextval(int)
-----------------------------------
t1 | postgres | NULL
t2 | NULL | 1

such way of returning tuples could possibly make also non-OO folks happy
as the result will still be table-shaped ;)

> Let me then put forward the following suggestion open for comment. The
> suggestion is very similar to the original postgres solution to this
> problem. What I have added is some consideration of how a streaming
> interface should work, and hopefully I will incorporate that
> enhancement while I'm at it.
>
> Into libpq will be (re)introduced the concept of a group. Tuples which
> are returned will be from a finite number of different layouts.
>
> Thus there will be an API PQnfieldsGroup(PGresult, group_num). And
> similar for PQftypeGroup etc. There will be a PQgroup(PGresult,
> tuple_num) which will tell you which group any given tuple belongs to.

Seems good ;).

Will the group carry only structurte or will it have some "higher"
meaning -
i.e. will rows selected form two different tables with the same
structure
be in the same group ?

----------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2000-07-05 08:39:39 Re: Article on MySQL vs. Postgres
Previous Message Chris Bitmead 2000-07-05 07:31:18 Re: Proposed new libpq API