Re: libpq custom row processing - Mailing list psycopg

From Federico Di Gregorio
Subject Re: libpq custom row processing
Date
Msg-id 5020F8BF.9030208@dndg.it
Whole thread Raw
In response to Re: libpq custom row processing  (Marko Kreen <markokr@gmail.com>)
Responses Re: libpq custom row processing
List psycopg
On 07/08/12 12:51, Marko Kreen wrote:
> The callback API has been rolled back and final 9.2 will have
> single-row-mode instead:
>
>   http://www.postgresql.org/docs/devel/static/libpq-single-row-mode.html
>
> Callback API was hard to use and did not support iterative
> result processing.  This API should fix both problems.

Interesting, but this is quite intimidating:

While processing a query, the server may return some rows and then
encounter an error, causing the query to be aborted. Ordinarily, libpq
discards any such rows and reports only the error. But in single-row
mode, those rows will have already been returned to the application.
Hence, the application will see some PGRES_SINGLE_TUPLE PGresult objects
followed by a PGRES_FATAL_ERROR object. For proper transactional
behavior, the application must be designed to discard or undo whatever
has been done with the previously-processed rows, if the query
ultimately fails.

Making sure old code continues to work and doesn't process the initial
tuples before an exception is throw will be challenging.

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Studio Associato Di Nunzio e Di Gregorio                  http://dndg.it
 Everything will be OK at the end. If it's not OK, it's not the end.
                                                              -- Unknown

psycopg by date:

Previous
From: Marko Kreen
Date:
Subject: Re: libpq custom row processing
Next
From: Marko Kreen
Date:
Subject: Re: libpq custom row processing