Re: Incremental results from libpq - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: Incremental results from libpq
Date
Msg-id 9994.1131642192@sss.pgh.pa.us
Whole thread Raw
In response to Re: Incremental results from libpq  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Responses Re: Incremental results from libpq
List pgsql-interfaces
Frank van Vugt <ftm.van.vugt@foxi.nl> 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


pgsql-interfaces by date:

Previous
From: Frank van Vugt
Date:
Subject: Re: Incremental results from libpq
Next
From: Frank van Vugt
Date:
Subject: Re: Incremental results from libpq