Thread: Connection Error message in ECPG

Connection Error message in ECPG

From
Matthew Vanecek
Date:
Hi,
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
RFE, or submit a patch?

Thanks,
--
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...

Re: Connection Error message in ECPG

From
Michael Meskes
Date:
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.

Michael
--
Michael Meskes
Email: Michael@Fam-Meskes.De
ICQ: 179140304
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


Re: Connection Error message in ECPG

From
Matthew Vanecek
Date:
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...