Re: Connection Error message in ECPG

From: Matthew Vanecek <mevanecek(at)yahoo(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Postgresql Interfaces List <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Connection Error message in ECPG
Date: 2003-02-11 04:50:11
Message-ID: 1044939011.6526.29.camel@reliant.home.pri
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces

On Mon, 2003-02-10 at 06:44, Michael Meskes wrote:
> On Sat, Feb 08, 2003 at 01:50:38PM -0600, Matthew Vanecek wrote:
> > What would it take to get a better error message out of the ECPG
> > interface, when a connection fails? It uses PQstatus(conn) to check the
> > status, but it doesn't use PQerrorMessage(conn) to get the error from
> > the backend and string it into sqlca.sqlerrm.sqlerrmc. Is there a way
> > to get that message from ECPG currently? If not, where do I file an
> No, you're completely right.
> > RFE, or submit a patch?
> The RFE has been noted, a patch can be send to me or any other committer
> of course, but I'd prefer you send it directly to me, so I can remove it
> from my todo list.

May I say, "ARGH!". I'm spoiled by DB2, with short simple messages and
distinct error codes. I was working on a patch, but there's absolutely
no way to predict the size of the PQerrorMessage() message, and I hate
to send out a truncated error message. :(

What may be a better idea is to provide a function (a la sqlprint) that
returns the error message the backend returns. The backend error
message would be stored in one field, and of course provide the same
guarantees that PQerrorMessage() does (i.e., this field is susceptible
to change without notice after an operation). That way, the -402
message stays the same, and interested programs could access the backend
error message after receiving a non-zero return code.

What would be really handy is if the back-end had a table of error codes
and matching strings it used (all less than 70 chars, of course!!),
instead of the nebulous CONNECTION_BAD, and hard-wired error messages...

Thanks for the reply. I'll try to work on the, oh, sqlerrmsg,
function. It should be relatively easy to implement.

What do you think?
Matthew Vanecek
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
For 93 million miles, there is nothing between the sun and my shadow except me.
I'm always getting in the way of something...

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2003-02-11 15:41:30 libpqxx 1.4.0 released
Previous Message Tom Lane 2003-02-11 04:35:43 Re: Any timeout feature(in libPQ) suitable for my case?