From: Igor Shevchenko <igor@carcass.ath.cx>
To: pgsql-interfaces@postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: libpq: how to get a sequence of partial PGresult-s
Date: Wed, 24 Sep 2003 02:00:05 +0300
Message-ID: <200309240200.05695.igor@carcass.ath.cx> (raw)
In-Reply-To: <23995.1064356049@sss.pgh.pa.us>
References: <200309240109.17024.igor@carcass.ath.cx>
<23995.1064356049@sss.pgh.pa.us>
On Wednesday 24 September 2003 01:27, you wrote:
> Igor Shevchenko <igor@carcass.ath.cx> writes:
> > Is there any way to get/process this partial PGresult in my
> > app ? I haven't found any API function for this, so I thought about an
> > additional function for the libpq's API -
> > PGresult* PQgetNextResult ( PGconn* conn );
>
> I think this is a really bad idea, because it destroys libpq's basic
> concept that you get either success or failure for a command. Peeking
> at a partially-arrived result might give you back some rows only to get
> an error later (since the backend may fail partway through a query).
Unfortunately there's no way to archieve both streaming an errorless
PQgetResult, but in case of error, the application will recieve an error
message later anyway. So, in this context, it can only be application's
resposibility to rollback changes done by data that is already processed.
Btw, the same can happen with cursors approach.
> I'm not sure that the partially constructed result is valid anyway;
> the last row may be in a funny state. And what happens if the
> application does a PQclear() on it??
The application would recieve a deep copy of PGresult, so PQclear() wouldn't
affect current PGconn->result.
Btw, I was thinking about PQgetNextResult only for the async/non-blocking
context.
--
Best regards,
Igor Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: igor@carcass.ath.cx, tgl@sss.pgh.pa.us
Subject: Re: libpq: how to get a sequence of partial PGresult-s
In-Reply-To: <200309240200.05695.igor@carcass.ath.cx>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox