Re: DBD::Pg errstr method doesn't return full error messages

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Haworth <pmh(at)edison(dot)ioppublishing(dot)com>
Cc: Vivek Khera <khera(at)kcilink(dot)com>, E(dot)Mergl(at)bawue(dot)de, pgsql-general(at)postgresql(dot)org
Subject: Re: DBD::Pg errstr method doesn't return full error messages
Date: 2001-05-08 18:54:01
Message-ID: 200105081854.f48Is1g22514@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


Has this gotten back to the DBD Perl maintainers?

> On Thu, 3 May 2001 15:24:31 -0400, Vivek Khera wrote:
> > Hi, I'm using DBD::Pg version 0.98 with Postgres 7.1. I'm noticing
> > that quite often on an error, the $dbh->errstr method doesn't return
> > the full error.
>
> Here's a patch to DBD::Pg 0.98 which fixes this:
>
> --- dbdimp.c.orig Tue May 1 11:46:47 2001
> +++ dbdimp.c Tue May 1 11:55:26 2001
> @@ -72,18 +72,21 @@
> char *error_msg;
> {
> D_imp_xxh(h);
> - char *err, *src, *dst;
> + char *err, *src, *dst, *end;
> int len = strlen(error_msg);
>
> - err = (char *)malloc(strlen(error_msg + 1));
> + err = (char *)malloc(len + 1);
> if (!err) {
> return;
> }
> + /* Remove trailing newlines, allowing for multi-line messages */
> + for(end = error_msg + len; end > error_msg && end[-1] == '\n'; --end);
> +
> src = error_msg;
> dst = err;
>
> /* copy error message without trailing newlines */
> - while (*dst != '\0' && *dst != '\n') {
> + while (src < end){
> *dst++ = *src++;
> }
> *dst = '\0';
>
> --
> Peter Haworth pmh(at)edison(dot)ioppublishing(dot)com
> "A good messenger expects to get shot."
> --Larry Wall
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-05-08 18:59:56 Re: IpcMemoryCreate: shmget failed (Invalid argument)
Previous Message Ian Harding 2001-05-08 18:48:00 pltcl question

Browse pgsql-hackers by date

  From Date Subject
Next Message Edmund Mergl 2001-05-08 19:20:35 Re: DBD::Pg errstr method doesn't return full error messages
Previous Message Bruce Momjian 2001-05-08 18:52:34 Re: Packaging 7.1.1