Re: [patch] libpq one-row-at-a-time API

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [patch] libpq one-row-at-a-time API
Date: 2012-07-24 16:25:41
Message-ID: CAHyXU0z9ic+LZPFbccNdNZhyGsvd8Q-kgna5-hzD-vj+Hi6+Wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 24, 2012 at 11:08 AM, Marko Kreen <markokr(at)gmail(dot)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. so, if
given that choice, I'd argue for branch 2, forcing a PGresult pull on
each row. However, what you were gunning for via branch 1 which is
extra performance via removing the extra allocs is important and
useful; hopefully we can get the best of both worlds, or punt and
settle on branch 2.

>> For example, maybe PQsetSingleRowMode maybe should return a result object?
>
> 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.

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2012-07-24 16:35:05 Re: [patch] libpq one-row-at-a-time API
Previous Message Marko Kreen 2012-07-24 16:08:28 Re: [patch] libpq one-row-at-a-time API