[PATCH] DBD::Pg configuration setup

2010-10-15 Thread H.Merijn Brand
PATCH at the end and attached ...

I have a system - and so do most of my customers with the same
architecture - where the base system has postgres installed.

But alas, it is version 7. That will not do. Their install is in /opt,
but as it is *system* postgress, they decided to link /opt/.../libpg.so
to /usr/lib/hpux64, which is the default $LD_LIBRARY_PATH of every
single user on the system.

I set POSTGRES_HOME to /pro/pgsql, which is a symlink to the postgres
version I am currently building against (e.g. /pro/pgsql-8.4.3). I do
have several to match what is installed at the customer. They all have
the /pro/pgsql symlink, so I can rest assured that the libs are found
whatever version I build when distributing.

When I set POSTGRES_HOME and POSTGRES_LIB (POSTGRES_INCLUDE setting
does not propagate into the binary, so I accept the return value of
App::Info), the *compilation* works fine, with just 2 warnings:

DBD-Pg-2.17.1  env POSTGRES_HOME=/pro/pgsql POSTGRES_LIB=/pro/pgsql/lib perl 
Makefile.PL
Configuring DBD::Pg 2.17.1
PostgreSQL version: 80403 (default port: 5432)
POSTGRES_HOME: /pro/pgsql
POSTGRES_INCLUDE: /pro/pgsql-8.4.3/include
POSTGRES_LIB: /pro/pgsql/lib
OS: hpux
Using DBI 1.615 (for perl 5.010001 on IA64.ARCHREV_0-LP64) installed in 
/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI/
Writing Makefile for DBD::Pg

DBD-Pg-2.17.1  make
cp lib/Bundle/DBD/Pg.pm blib/lib/Bundle/DBD/Pg.pm
cp Pg.pm blib/lib/DBD/Pg.pm
/pro/bin/perl -p -e s/~DRIVER~/Pg/g; s/^do\(/dontdo\(/ 
/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI/Driver.xst  Pg.xsi
/pro/bin/perl /pro/lib/perl5/5.10.1/ExtUtils/xsubpp  -typemap 
/pro/lib/perl5/5.10.1/ExtUtils/typemap  Pg.xs  Pg.xsc  mv Pg.xsc Pg.c
cc -c  -I/pro/pgsql-8.4.3/include 
-I/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI -Ae 
-DPERL_DONT_CREATE_GVSV +Z -z -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DD64 
-I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  
-DPGLIBVERSION=80403 -DPGDEFPORT=5432 +O2 +Onolimit  -DPERL_EXTMALLOC_DEF 
-Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc 
-Dcalloc=Perl_calloc -DVERSION=\2.17.1\ -DXS_VERSION=\2.17.1\ +Z 
-I/pro/lib/perl5/5.10.1/IA64.ARCHREV_0-LP64/CORE   Pg.c
cc -c  -I/pro/pgsql-8.4.3/include 
-I/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI -Ae 
-DPERL_DONT_CREATE_GVSV +Z -z -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DD64 
-I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  
-DPGLIBVERSION=80403 -DPGDEFPORT=5432 +O2 +Onolimit  -DPERL_EXTMALLOC_DEF 
-Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc 
-Dcalloc=Perl_calloc -DVERSION=\2.17.1\ -DXS_VERSION=\2.17.1\ +Z 
-I/pro/lib/perl5/5.10.1/IA64.ARCHREV_0-LP64/CORE   dbdimp.c
dbdimp.c, line 4472: warning #2068-D: integer conversion resulted in a
  change of sign
if (!pg_db_end_txn(aTHX_ dbh, imp_dbh, -1==loid ? 0 : 1))
   ^

cc -c  -I/pro/pgsql-8.4.3/include 
-I/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI -Ae 
-DPERL_DONT_CREATE_GVSV +Z -z -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DD64 
-I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  
-DPGLIBVERSION=80403 -DPGDEFPORT=5432 +O2 +Onolimit  -DPERL_EXTMALLOC_DEF 
-Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc 
-Dcalloc=Perl_calloc -DVERSION=\2.17.1\ -DXS_VERSION=\2.17.1\ +Z 
-I/pro/lib/perl5/5.10.1/IA64.ARCHREV_0-LP64/CORE   quote.c
quote.c, line 334: warning #2513-D: a value of type const char * cannot be
  assigned to an entity of type char *
result = string;
   ^


cc -c  -I/pro/pgsql-8.4.3/include 
-I/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/auto/DBI -Ae 
-DPERL_DONT_CREATE_GVSV +Z -z -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DD64 
-I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  
-DPGLIBVERSION=80403 -DPGDEFPORT=5432 +O2 +Onolimit  -DPERL_EXTMALLOC_DEF 
-Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc 
-Dcalloc=Perl_calloc -DVERSION=\2.17.1\ -DXS_VERSION=\2.17.1\ +Z 
-I/pro/lib/perl5/5.10.1/IA64.ARCHREV_0-LP64/CORE   types.c
Running Mkbootstrap for DBD::Pg ()
chmod 644 Pg.bs
rm -f blib/arch/auto/DBD/Pg/Pg.so


But *linking* breaks, because the default -L flags from $LDFLAGS and
$LDDLFLAGS are in front of $EXTRALIBS and/or $LDLOADLIBS and the linker
now picks up the postgres-7 library :( :(

EXTRALIBS = -L/pro/pgsql/lib -lpq
LDLOADLIBS = -L/pro/pgsql/lib -lpq -lm
BSLOADLIBS =
LD_RUN_PATH = /pro/pgsql/lib

LD_RUN_PATH=/pro/pgsq/lib /usr/bin/ld  -b +vnocompatwarnings -L/pro/local/lib 
-L/usr/lib/hpux64 Pg.o dbdimp.o quote.o types.o  -o blib/arch/auto/DBD/Pg/Pg.so 
 \
   -L/pro/pgsql/lib -lpq -lm  \

chmod 755 blib/arch/auto/DBD/Pg/Pg.so
cp Pg.bs blib/arch/auto/DBD/Pg/Pg.bs
chmod 644 blib/arch/auto/DBD/Pg/Pg.bs
Manifying blib/man3/Bundle::DBD::Pg.3
Manifying blib/man3/DBD::Pg.3

After I changed my Makefile.PL and started over (see patch below), I
get 

Re: [PATCH] DBD::Pg configuration setup

2010-10-15 Thread David E. Wheeler
On Oct 15, 2010, at 7:43 AM, H.Merijn Brand wrote:

 Good enough for now.
 
 And here's the patch. FWIW HP-UX 9 is so archaic that even /I/ do not
 have access to it anymore :)
 
 --8---
 --- Makefile.PL.org 2010-04-07 22:52:55 +0200
 +++ Makefile.PL 2010-10-15 16:35:35 +0200
 @@ -211,19 +211,16 @@ my %opts =
 PERL_MALLOC_OK = 1,
 NEEDS_LINKING  = 1,
 NO_META= 1,
 - NORECURS   = 1,
 +NORECURS   = 1,
 clean  = { FILES = 'trace Pg.xsi README.testdatabase' },
 - realclean  = { FILES = 'dbdpg_test_database/' },
 +realclean  = { FILES = 'dbdpg_test_database/' },
 +macro  = {
 +   LDFLAGS = -L$POSTGRES_LIB $Config{ldflags},
 +   LDDLFLAGS   = -L$POSTGRES_LIB $Config{lddlflags},
 +   },
 );
 
 -if ($os eq 'hpux') {
 -my $osvers = $Config{osvers};
 -if ($osvers  10) {
 -print Warning: Forced to build static not dynamic on $os 
 $osvers.\a\n;
 -$opts{LINKTYPE} = 'static';
 -}
 -}
 -elsif ($os =~ /Win32/) {
 +if ($os =~ /Win32/) {
my $msdir = $POSTGRES_LIB;
$msdir =~ s{$}{/ms};
$opts{LIBS}[0] .=  -L$msdir -lsecur32;
 --8---

Seems like a pretty straight-forward patch. Happy to see one OS-specific hack 
removed.

David



Re: DBD::CSV

2010-10-15 Thread Jens Rehsack
2010/10/14 H.Merijn Brand h.m.br...@xs4all.nl:
 Regarding RT#61513, Here's a script that shows both.

 As this is completely withing the realm of your changes to initializing
 DBD::File for DBD::DBM, I'd appreciate a pointer in where to look ...

 tux09:/pro/3gl/CPAN/DBD-CSV/sandbox 425  perl rt61513.pl 0
     0      0 root
     1      1 bin
     2      2 daemon
     4      7 lp
 tux09:/pro/3gl/CPAN/DBD-CSV/sandbox 426  perl rt61513.pl 1
 DBD::CSV::st execute failed:
 Execution ERROR: Cannot open /pro/3gl/CPAN/DBD-CSV/sandbox/dinges: No such 
 file or directory (2) at 
 /pro/lib/perl5/site_perl/5.12.2/i686-linux-64int-ld/DBD/File.pm line 690
 .

  [for Statement select * from dinges where uid  5 order by uid] at 
 rt61513.pl line 31.
 execute failed:
 Execution ERROR: Cannot open /pro/3gl/CPAN/DBD-CSV/sandbox/dinges: No such 
 file or directory (2) at 
 /pro/lib/perl5/site_perl/5.12.2/i686-linux-64int-ld/DBD/File.pm line 690

Thanks for the test, Merijn. I Fixed it on the road and committed it
into sqlengine
branch along with other fixes yesterday and today.

I strongly suggest not merging into the trunk and releasing before I
found a tuit
to add tests for a lot of things.

Best regards,
Jens