From: | "Peter Haworth" <pmh(at)edison(dot)ioppublishing(dot)com> |
---|---|
To: | Vivek Khera <khera(at)kcilink(dot)com>, E(dot)Mergl(at)bawue(dot)de |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: DBD::Pg errstr method doesn't return full error messages |
Date: | 2001-05-04 11:49:57 |
Message-ID: | PGM.20010504114957.21664.386@edison.ioppublishing.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | mlw | 2001-05-04 12:02:52 | Re: Metaphone function attachment |
Previous Message | Alan Young | 2001-05-04 10:24:31 | Compiling pl/perl problems. |
From | Date | Subject | |
---|---|---|---|
Next Message | mlw | 2001-05-04 12:02:17 | Re: New Linux xfs/reiser file systems |
Previous Message | The Hermit Hacker | 2001-05-04 11:45:06 | Re: CVSup not working! |