Skip site navigation (1) Skip section navigation (2)

Re: Incremental results from libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Incremental results from libpq
Date: 2005-11-10 17:03:12
Message-ID: 9994.1131642192@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)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

In response to

Responses

pgsql-interfaces by date

Next:From: Frank van VugtDate: 2005-11-10 17:09:54
Subject: Re: Incremental results from libpq
Previous:From: Frank van VugtDate: 2005-11-10 16:51:54
Subject: Re: Incremental results from libpq

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group