Re: [patch] libpq one-row-at-a-time API
От | Leon Smith |
---|---|
Тема | Re: [patch] libpq one-row-at-a-time API |
Дата | |
Msg-id | CAPwAf1nfCftYfU+6c=mgmMF-uxCPguw-thuV4DaxH=+cqKOPgA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [patch] libpq one-row-at-a-time API (Merlin Moncure <mmoncure@gmail.com>) |
Ответы |
Re: [patch] libpq one-row-at-a-time API
|
Список | pgsql-hackers |
Hey, this thread was pointed out to me just a few days ago, but I'll start by saying that I think this thread is on exactly the right track. I don't like the callback API, and think that PQsetSingleRowMode should be offered in place of it. But I do have one
On Sat, Jun 16, 2012 at 10:22 AM, Marko Kreen <markokr@gmail.com> wrote:
The function can be called only after PQsend* and before any
rows have arrived. This guarantees there will be no surprises
to PQexec* users who expect full resultset at once.
Ok, I'm guessing you mean that "before you call PQgetResult or PQgetRowData", or maybe "before you call PQgetResult or PQgetRowData and it returns a result or partial result." Because it would be a race condition if you meant exactly what you said. (Though I don't understand how this could possibly be implemented without some source of concurrency, which libpq doesn't do.) Maybe this is a little overly pendantic, but I do want to confirm the intention here.
One other possibility, Tom Lane fretted ever so slightly about the use of malloc/free per row... what about instead of PQsetSingleRowMode, you have PQsetChunkedRowMode that takes a chunkSize parameter. A chunkSize <= 0 would be equivalent to what we have today, a chunkSize of 1 means you get what you have from PQsetSingleRowMode, and larger chunkSizes would wait until n rows have been received before returning them all in a single result. I don't know that this suggestion is all that important, but it seems like an obvious generalization that might possibly be useful.
Best,
Leon
В списке pgsql-hackers по дате отправления: