Re: Not clear on what PQgetResult does

Lists: pgsql-interfaces
From: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Not clear on what PQgetResult does
Date: 2005-11-17 19:00:41
Message-ID: 437CD359.5080908@ll.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

I don't understand in what sense PQgetResult is asynchronous. Obviously
PQsendQuery returns immediately and apparently PQgetResult() allows me
to get separate results from multiple queries submitted together, but...

Let's say I have a table with 1,000,000 rows and I PQsendQuery() a query
to get them all. When I call PQgetResult() the first time, will it
block until all 1,000,000 are ready, or will it send back everything
that's ready at the time I call it?

If the latter, is pgtcl's pg_getresult supposed to work the same way?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 19:38:18
Message-ID: 451.1132256298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

David Rysdam <drysdam(at)ll(dot)mit(dot)edu> writes:
> I don't understand in what sense PQgetResult is asynchronous.

It isn't. You can use it in an asynchronous client, but the way you do
that is by not calling it until PQisBusy says you can (which means the
whole result has arrived, and you're just calling PQgetResult to get
hold of it).

> If the latter, is pgtcl's pg_getresult supposed to work the same way?

Dunno ... there was no such command last time I looked at pgtcl.

regards, tom lane


From: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
To:
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 20:01:52
Message-ID: 437CE1B0.3040001@ll.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

Tom Lane wrote:

>David Rysdam <drysdam(at)ll(dot)mit(dot)edu> writes:
>
>
>>I don't understand in what sense PQgetResult is asynchronous.
>>
>>
>
>It isn't. You can use it in an asynchronous client, but the way you do
>that is by not calling it until PQisBusy says you can (which means the
>whole result has arrived, and you're just calling PQgetResult to get
>hold of it).
>
So there's no way to have libpq return partial results before they are
all ready?

If I may, I would like to express some degree of incredulity. Even the
version of Sybase I'm using does this right and it's from 1997!


From: Brett Schwarz <brett_schwarz(at)yahoo(dot)com>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 20:14:58
Message-ID: 20051117201458.4244.qmail@web34601.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces


>
> Let's say I have a table with 1,000,000 rows and I
> PQsendQuery() a query
> to get them all. When I call PQgetResult() the
> first time, will it
> block until all 1,000,000 are ready, or will it send
> back everything
> that's ready at the time I call it?
>
> If the latter, is pgtcl's pg_getresult supposed to
> work the same way?
>

pg_getresult really is just a wrapper around
PQgetResult, so it should behave the same.

See the README.async in pgtcl if you want more info on
async with pgtcl.

--brett

--brett



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 20:40:34
Message-ID: 437CEAC2.6050001@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

>
>>
>> It isn't. You can use it in an asynchronous client, but the way you do
>> that is by not calling it until PQisBusy says you can (which means the
>> whole result has arrived, and you're just calling PQgetResult to get
>> hold of it).
>>
> So there's no way to have libpq return partial results before they are
> all ready?
>
> If I may, I would like to express some degree of incredulity. Even
> the version of Sybase I'm using does this right and it's from 1997!
I am sure we would welcome a patch ;))

Sincerely,

Joshua D. Drake

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match


From: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
To:
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 20:42:54
Message-ID: 437CEB4E.5040402@ll.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

Joshua D. Drake wrote:

>>
>>>
>>> It isn't. You can use it in an asynchronous client, but the way you do
>>> that is by not calling it until PQisBusy says you can (which means the
>>> whole result has arrived, and you're just calling PQgetResult to get
>>> hold of it).
>>>
>> So there's no way to have libpq return partial results before they
>> are all ready?
>>
>> If I may, I would like to express some degree of incredulity. Even
>> the version of Sybase I'm using does this right and it's from 1997!
>
> I am sure we would welcome a patch ;))

To be honest, this is almost enough to drive me away from PG. But I
like everything else about it, so I could perhaps give a patch a whirl.
Or are there underlying server reasons why this won't work?


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 21:16:35
Message-ID: 20051117211635.GD10976@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

David Rysdam wrote:
> Joshua D. Drake wrote:
>
> >>>It isn't. You can use it in an asynchronous client, but the way you do
> >>>that is by not calling it until PQisBusy says you can (which means the
> >>>whole result has arrived, and you're just calling PQgetResult to get
> >>>hold of it).
> >>>
> >>So there's no way to have libpq return partial results before they
> >>are all ready?
> >>
> >>If I may, I would like to express some degree of incredulity. Even
> >>the version of Sybase I'm using does this right and it's from 1997!
> >
> >I am sure we would welcome a patch ;))
>
> To be honest, this is almost enough to drive me away from PG.

If you are in need of partial results you may as well use a cursor and
fetch from it, a bunch at a time.

> Or are there underlying server reasons why this won't work?

This topic was discussed four days ago I think ... look for a thread
with subject "Incremental results from libpq" on the archives of this
list.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 21:39:24
Message-ID: 8816.1132263564@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

David Rysdam <drysdam(at)ll(dot)mit(dot)edu> writes:
> To be honest, this is almost enough to drive me away from PG. But I
> like everything else about it, so I could perhaps give a patch a whirl.
> Or are there underlying server reasons why this won't work?

Have you bothered to read the preceding discussion you were pointed at?
http://archives.postgresql.org/pgsql-interfaces/2005-11/index.php

regards, tom lane


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-17 21:40:37
Message-ID: 437CF8D5.6050804@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces


>
> To be honest, this is almost enough to drive me away from PG. But I
> like everything else about it, so I could perhaps give a patch a
> whirl. Or are there underlying server reasons why this won't work?
I thought (I could be wrong) that tom said that the support was in the
protocol but that libpq did not support it, so I would guess there is no
reason
except that there is no patch.

Sincerely,

Joshua D. Drake

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-22 22:32:37
Message-ID: 200511222232.jAMMWbO25551@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

David Rysdam wrote:
> Joshua D. Drake wrote:
>
> >>
> >>>
> >>> It isn't. You can use it in an asynchronous client, but the way you do
> >>> that is by not calling it until PQisBusy says you can (which means the
> >>> whole result has arrived, and you're just calling PQgetResult to get
> >>> hold of it).
> >>>
> >> So there's no way to have libpq return partial results before they
> >> are all ready?
> >>
> >> If I may, I would like to express some degree of incredulity. Even
> >> the version of Sybase I'm using does this right and it's from 1997!
> >
> > I am sure we would welcome a patch ;))
>
> To be honest, this is almost enough to drive me away from PG.

I think you should return to Sybase as soon as you can! :-)

Seriously, look at the current TODO list and the issues involved.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: David Rysdam <drysdam(at)ll(dot)mit(dot)edu>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Not clear on what PQgetResult does
Date: 2005-11-22 22:33:18
Message-ID: 200511222233.jAMMXI925739@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

Alvaro Herrera wrote:
> David Rysdam wrote:
> > Joshua D. Drake wrote:
> >
> > >>>It isn't. You can use it in an asynchronous client, but the way you do
> > >>>that is by not calling it until PQisBusy says you can (which means the
> > >>>whole result has arrived, and you're just calling PQgetResult to get
> > >>>hold of it).
> > >>>
> > >>So there's no way to have libpq return partial results before they
> > >>are all ready?
> > >>
> > >>If I may, I would like to express some degree of incredulity. Even
> > >>the version of Sybase I'm using does this right and it's from 1997!
> > >
> > >I am sure we would welcome a patch ;))
> >
> > To be honest, this is almost enough to drive me away from PG.
>
> If you are in need of partial results you may as well use a cursor and
> fetch from it, a bunch at a time.

Right, this is the standard way.

> > Or are there underlying server reasons why this won't work?
>
> This topic was discussed four days ago I think ... look for a thread
> with subject "Incremental results from libpq" on the archives of this
> list.

That thread has already been condensed into a TODO entry.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073