Re: [patch] libpq one-row-at-a-time API - Mailing list pgsql-hackers

From Marko Kreen
Subject Re: [patch] libpq one-row-at-a-time API
Date
Msg-id CACMqXCJZgVn+rVYiCsZxh_wSRRdcPuHsa-6YbHygLu+f7CVQ8Q@mail.gmail.com
Whole thread Raw
In response to Re: [patch] libpq one-row-at-a-time API  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: [patch] libpq one-row-at-a-time API
List pgsql-hackers
On Tue, Jul 24, 2012 at 7:25 PM, Merlin Moncure <mmoncure@gmail.com> wrote:
> On Tue, Jul 24, 2012 at 11:08 AM, Marko Kreen <markokr@gmail.com> wrote:
>>> I'm arguing that *all* data getting must continue to do so through the
>>> result object, and bypassing the result to get at data is breaking the
>>> result abstraction in the libpq api.  I bet you can still maintain
>>> data access through result object while avoiding extra copies.
>>
>> Well, the main problem this week is whether we should
>> apply PQsetSingleRowMode() from single-row-mode1
>> or from single-row-mode2 branch?
>>
>> The PQgetRowData() is unimportant as it just exposes
>> the rowBuf to user and thats all.
>
> right. branch 1 (containing PQgetRowData) seems wrong to me.

Indeed, you are missing the fact that PGgetResult works same
in both branches.,

And please see the benchmart I posted.

Even better, run it yourself...

>> What do you mean by that?  And have you though about both
>> sync and async usage patterns?
>
> No, I haven't -- at least not very well.  The basic idea is that
> PQsetSingleRowMode turns into PQgetSingleRowResult() and returns a
> result object.  For row by row an extra API call gets called (maybe
> PQgetNextRow(PGconn, PGresult)) that does the behind the scenes work
> under the existing result object.  This is the same general structure
> you have in branch 2, but the result allocation is move out of the
> loop.  Presumably sync and async would then follow the same pattern,
> but we'd still have to be able to guarantee non-blocking behavior in
> the async api.

Well, as discussed previously it's worthwhile to keep standard functions
like PQisBusy() and PQgetResult() working sensibly in new mode,
and currently they do so.

If you add new functions, you also need to define the behavior
when new and old one's are mixed and it gets messy quickly.

-- 
marko


pgsql-hackers by date:

Previous
From: Marko Kreen
Date:
Subject: Re: [patch] libpq one-row-at-a-time API
Next
From: Merlin Moncure
Date:
Subject: Re: [patch] libpq one-row-at-a-time API