X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F6F6DA7BA for ; Thu, 10 Nov 2005 13:03:18 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99157-03 for ; Thu, 10 Nov 2005 17:03:17 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CA721DA5BB for ; Thu, 10 Nov 2005 13:03:16 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jAAH3C1N009995; Thu, 10 Nov 2005 12:03:12 -0500 (EST) To: Frank van Vugt Cc: pgsql-interfaces@postgresql.org Subject: Re: Incremental results from libpq In-reply-to: <200511101751.55377.ftm.van.vugt@foxi.nl> References: <4D426B54-E08F-4DE9-9776-D46610CA4968@slamb.org> <19391.1131571328@sss.pgh.pa.us> <84C7635D-EAF2-40CF-A71C-976077D5465A@slamb.org> <200511101751.55377.ftm.van.vugt@foxi.nl> Comments: In-reply-to Frank van Vugt message dated "Thu, 10 Nov 2005 17:51:54 +0100" Date: Thu, 10 Nov 2005 12:03:12 -0500 Message-ID: <9994.1131642192@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/16 X-Sequence-Number: 5812 Frank van Vugt writes: > The main reason why libpq does what it does is that this way we do not > have to expose in the API the notion of a command that fails part way > through. If you support partial result fetching then you'll have to > deal with the idea that a SELECT could fail after you've already > returned some rows to the client. > I'm wondering, what kind of failure do you have in mind, here? There are lots of possibilities, but one fairly obvious example is SELECT 1/x FROM tab; where the 10000'th row of tab contains x = 0. The server will detect the zero-divide error only after it's already shipped 9999 rows to the client. Currently, when libpq gets the error it throws away the 9999 rows and just returns an "error" PQresult to the application. If you let libpq return some rows before it's got the whole result set, then you need to decide what the API behavior ought to be for a failure after a partial result set has been returned. This in turn requires a little thought about how client apps are likely to want to cope with this scenario, so that you don't come up with a painful-to-use API. regards, tom lane