Re: [PATCHES] libpq type system 0.9a

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] libpq type system 0.9a
Date: 2008-04-10 17:36:29
Message-ID: 47FE501D.5070807@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> PQresultErrorMessage at this point --- if you haven't already
> checked the PGresult to be "okay", you should certainly not be
> trying to extract fields from it. So I don't see that you
> are saving any steps here.

Correct, I agree. Our thinking was flawed. The issue we face is that,
unlike getvalue, getf can fail in many ways ... like bad format string
or type mismatch. If you would rather us introduce a pqtypes specific
error for getf. putf doesn't suffer from this issue because it uses
PGparamErrorMessage.

>> Same holds true for PGconn.
>
> I'm not convinced about that side either. It doesn't fail the basic
> const-ness test, perhaps, but it still looks mostly like you
>are trying to avoid the necessity to think hard about how you're
>going to report

The issue is not a matter of know-how, it is a matter of creating
ambiguos situations in regards to where the error is (I'm thinking from
a libpq user's perspective). This only applies to PQparamExec and
fiends, NOT PQputf. All existing exec/send functions put an error in
the conn (if the result is NULL check the conn).

paramexec can fail prior to internally calling PQexecParams, in which
case it returns NULL because no result has been constructed yet. The
question is, where does the error go?

res = paramexec(conn, param, ...
if(!res)
// check pgconn or pgparam?
// can conn have an old error (false-pos)

Not using the conn's error msg means that one must check the param and
conn if the return value is NULL. I think the best behavior here is to
check PQerrorMessage when any exec function returns a NULL result,
including pqtypes. If not, I think it could get confusing to the API user.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-04-10 17:40:53 Re: [PATCHES] libpq type system 0.9a
Previous Message Bruce Momjian 2008-04-10 17:26:12 Re: Index AM change proposals, redux

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-04-10 17:40:53 Re: [PATCHES] libpq type system 0.9a
Previous Message Andrew Chernow 2008-04-10 17:06:43 Re: [PATCHES] libpq type system 0.9a