Re: Building DBD::Pg - Mailing list pgsql-general

From Peter Haworth
Subject Re: Building DBD::Pg
Date
Msg-id PGM.20010508101126.11356.390@edison.ioppublishing.com
Whole thread Raw
In response to Building DBD::Pg  ("Simon Crute" <simon-news@nospam.geordie.demon.co.uk>)
List pgsql-general
On Thu, 3 May 2001 23:03:57 +0100, Simon Crute wrote:
> [simon@sunshine DBD-Pg-0.98]$ make test
> PERL_DL_NONLAZY=1
> /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.6.0/i686-linux
>  -I/usr/local/lib/perl5/5.6.0 test.pl
> OS: linux
> Use of uninitialized value in join at test.pl line 53.
> DBI->data_sources .......... not ok:
> DBI->connect(dbname=template1) failed: No pg_hb at test.pl line 59
> DBI->connect ............... not ok: No pg_hb at test.pl line 59.
> make: *** [test_dynamic] Error 255

One problem is that the error message is being truncated. This patch to DBD::Pg fixes that. The other problem is
indicatedby the truncated error message, which I guess is complaining about pg_hba.conf 

--- 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@edison.ioppublishing.com
"It's gotten to the point where the only place you can get work done is at
home, because no one bugs you, and the best place to entertain yourself is
at work, because the Internet connections are faster."      -- Scott Adams

pgsql-general by date:

Previous
From: "Michael Ansley (UK)"
Date:
Subject: RE: OODBMS vs. RDBMS
Next
From: Justin Clift
Date:
Subject: Re: Re: Database Recovery Help...