Re: libpq sendQuery -- getResult not returning until all queries complete

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Kelly Burkhart <kelly(dot)burkhart(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: libpq sendQuery -- getResult not returning until all queries complete
Date: 2010-12-22 17:06:30
Message-ID: AANLkTi=Tbf4k=J6nSt4f0br1CB8NMrVWEPEKYLXqTug-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 22, 2010 at 11:38 AM, Kelly Burkhart
<kelly(dot)burkhart(at)gmail(dot)com> wrote:
> On Wed, Dec 22, 2010 at 10:19 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>> have you ruled out sending all the data you need to send into say, a
>> plpgsal function and doing the work there?
>>
>
> Not sure that would do what they need, which is get a list of users,
> get a list of accounts, get perhaps several other lists of other
> things to populate gui elements (mostly small queries).  To do this
> within a stored procedure, the procedure would either have to return
> multiple PGresult objects with different columns (is that possible?)
> or we'd have to shoehorn everything into one result set with some kind
> of indicator on each row to indicate what kind of row it is.  The
> second option is (to me anyway) clearly inferior to just sending a
> list of queries then reaping their PGresults as they come in.

it is completely possible.

create type account_t as row(id int, name text);

create or replace function app_login(
accounts out account_t[]
users out user_t[]) returns record as
$$
begin
select array(select id, name from account into accounts);
...

end;
$$ language plpgsql;

arrays come back over libpq as text, unless you use libpqtypes (which
i co-wrote) :-).

http://libpqtypes.esilo.com/man3/pqt-composites.html

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2010-12-22 17:13:08 Re: could not open relation...No such file or directory
Previous Message Tom Lane 2010-12-22 17:03:30 Re: could not open relation...No such file or directory