Re: libpq custom row processing

From: Federico Di Gregorio <fog(at)dndg(dot)it>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: libpq custom row processing
Date: 2012-08-07 11:15:11
Message-ID: 5020F8BF.9030208@dndg.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)digregorio(at)dndg(dot)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

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Marko Kreen 2012-08-07 11:41:41 Re: libpq custom row processing
Previous Message Marko Kreen 2012-08-07 10:51:04 Re: libpq custom row processing