X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D901FD1B4FF for ; Tue, 23 Sep 2003 23:01:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 61080-07 for ; Tue, 23 Sep 2003 20:01:04 -0300 (ADT) Received: from wind.ukr.net (wind.ukr.net [212.42.64.10]) by svr1.postgresql.org (Postfix) with ESMTP id 556E8D1B57D for ; Tue, 23 Sep 2003 20:01:01 -0300 (ADT) Received: from 82-19.odessa.dialup.ukr.net ([212.42.82.19]) by wind.ukr.net with esmtp ID 1A1w9O-0006PI-B8 ; Wed, 24 Sep 2003 02:00:58 +0300 From: Igor Shevchenko To: pgsql-interfaces@postgresql.org Subject: Re: libpq: how to get a sequence of partial PGresult-s Date: Wed, 24 Sep 2003 02:00:05 +0300 User-Agent: KMail/1.5.2 References: <200309240109.17024.igor@carcass.ath.cx> <23995.1064356049@sss.pgh.pa.us> In-Reply-To: <23995.1064356049@sss.pgh.pa.us> Cc: Tom Lane MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309240200.05695.igor@carcass.ath.cx> X-WIND.UKR.NET-ID: 5eb41c7c0b36b308b91dae9fd34de8f1 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/63 X-Sequence-Number: 4481 On Wednesday 24 September 2003 01:27, you wrote: > Igor Shevchenko 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