1825795 Members
2160 Online
109687 Solutions
New Discussion

Re: DB starting error

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: DB starting error

>I am attaching the plperl.sl

I can't duplicate the problem with a dummy load of just plperl.sl.

Other than shipping the whole application, I don't see too many ways to solve it. Can you attach libperl.sl?

I suppose I can provide my test case so you can try it on your system:
load_shlib.c:
#include
#include
int main(int argc, char **argv) {
if (argc < 2) return 2;
void *handle = dlopen(argv[1], RTLD_GLOBAL | RTLD_LAZY);
if (!handle) {
fprintf(stderr, "dlopen failed: %s\n", dlerror());
return 1;
}
return 0;
}

$ cc -Ae -g load_shlib.c -mt -lcl -Wl,+s
$ SHLIB_PATH=. a.out plperl.sl
Shinji Teragaito_1
Respected Contributor

Re: DB starting error

I installed perl D.5.8.8.B from 11.11 0809 Application media
because libperl.sl was not available for B.5.6.1.C (too old :-).

When compiling PostgreSQL --with-perl (perl D.5.8.8.B), I was not
able to build plperl. I got the following message during the
build under src/pl/plperl:

*** Cannot build PL/Perl because libperl is not a shared library.
*** You might have to rebuild your Perl installation. Refer to
*** the documentation for details.

The root cause is the symbol "useshrplib" is false even at
perl-D.5.8.8.B.

% /opt/perl_32/bin/perl -MConfig -e 'print "$Config{useshrplib}\n"'
false
%

So I built perl 5.10.0 from source code with 'Configure -Duseshrplib'.

% /usr/local/perl5/bin/perl -MConfig -e 'print "$Config{useshrplib}\n"'
true
%

% env CC=cc CFLAGS="+O2" ./configure \
--without-readline --without-zlib --with-perl \
--enable-integer-datetimes --with-openssl 2>&1 | tee configure.log
% make 2>&1 | tee make.log

% more make.log
..(snip)..
/usr/bin/ld +h libregress.sl.0 -b +b '/usr/local/pgsql/lib' regress.o -L../../
../src/port -o libregress.sl.0
rm -f libregress.sl
ln -s libregress.sl.0 libregress.sl
rm -f regress.sl
ln -s libregress.sl.0 regress.sl
/usr/local/bin/make -C ../../../contrib/spi refint.sl autoinc.sl
..(snip)..
%

% make check 2>&1 | tee makecheck.log

=======================
All 114 tests passed.
=======================

Afterwards,

$ createdb sample
$ psql -l
List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | EUC_JP
sample | postgres | EUC_JP
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
(4 rows)

$ createlang --echo --dbname=sample --username=postgres plperl
SELECT oid FROM pg_catalog.pg_language WHERE lanname = 'plperl';
CREATE LANGUAGE "plperl";
$

$ chatr /usr/local/pgsql/lib/plperl.sl
/usr/local/pgsql/lib/plperl.sl:
shared library
shared library dynamic path search:
SHLIB_PATH disabled second
embedded path enabled first /usr/local/perl5/lib/5.10.0/PA-RISC2.0/CORE
internal name:
libplperl.sl.0
shared library list:
dynamic /usr/local/perl5/lib/5.10.0/PA-RISC2.0/CORE/libperl.sl
dynamic /usr/lib/libnsl.1
dynamic /usr/lib/libnm.sl
dynamic /usr/lib/libdld.2
dynamic /usr/lib/libm.2
dynamic /usr/lib/libsec.2
dynamic /usr/lib/libc.2
shared vtable support disabled
..(snip)..
$
Shinji Teragaito_1
Respected Contributor

Re: DB starting error

I'm sorry to paste the wrong snippets from make.log. Here's the correct snippet I wanted to paste last night:

ar crs libplperl.a plperl.o spi_internal.o SPI.o
ranlib libplperl.a
/usr/bin/ld +h libplperl.sl.0 -b +b '/usr/local/perl5/lib/5.10.0/PA-RISC2.0/CORE' plperl.o \
spi_internal.o SPI.o -L/usr/local/lib -L/usr/local/perl5/lib/5.10.0/PA-RISC2.0/CORE \
-L../../../src/port -lperl -lnsl -lnm -lmalloc -ldld -lm -lcrypt -lsec -lc -o libplperl.sl.0
rm -f libplperl.sl
ln -s libplperl.sl.0 libplperl.sl
make[3]: Leaving directory `/var/tmp/postgresql-8.3.4/src/pl/plperl'

Only plperl.sl is available in /usr/local/pgsql/lib.

% more makeinstall.log
..(snip)..
gmake[3]: Entering directory `/var/tmp/postgresql-8.3.4/src/pl/plperl'
/bin/sh ../../../config/install-sh -c -m 555 libplperl.sl.0 '/usr/local/pgsql/lib/plperl.sl'
gmake[3]: Leaving directory `/var/tmp/postgresql-8.3.4/src/pl/plperl
..(snip)..
%
Sutapa Dey
Frequent Advisor

Re: DB starting error

Hi Shinji,

I tried to install the perl5 from source after downloading perl-5.8.3.tar.gz.

The configure options I used is:
./Configure -des -Duseshrplib -Dprefix=/usr/local/perl5

The perl got built successfully and it is showing to be 64-bit PA Binary that is PARISC2.0 executable.

But unfortunately after this when I am trying to enable postgres support for plperl , it is not creating the plperl.sl shared library

The configure options I am passing for this is :

./configure --prefix=/opt/iexpress/postgresql --with-perl --enable-integer-datetimes --with-openssl --libdir=/opt/iexpress/postgresql/lib/hpux32 --without-readline --without-zlib --without-docdir

Please give some suggestions.
Sutapa Dey
Frequent Advisor

Re: DB starting error

I also ran a gmake check and got the following error:

./pg_regress --temp-install=./tmp_check --top-builddir=../../.. --temp-port=55432 --schedule=./parallel_schedule --multibyte=SQL_ASCII --load-language=plpgsql
============== creating temporary installation ==============
============== initializing database system ==============

pg_regress: initdb failed
Examine ./log/initdb.log for the reason.
Command was: "/opt/iexpress/postgresql/src/postgresql-8.2.4/src/test/regress/./tmp_check/install//opt/iexpress/postgresql/bin/initdb" -D "/opt/iexpress/postgresql/src/postgresql-8.2.4/src/test/regress/./tmp_check/data" -L "/opt/iexpress/postgresql/src/postgresql-8.2.4/src/test/regress/./tmp_check/install//opt/iexpress/postgresql/share" --noclean > "./log/initdb.log" 2>&1
gmake[2]: *** [check] Error 2
gmake[2]: Leaving directory `/opt/iexpress/postgresql/src/postgresql-8.2.4/src/test/regress'
gmake[1]: *** [check] Error 2
gmake[1]: Leaving directory `/opt/iexpress/postgresql/src/postgresql-8.2.4/src/test'
gmake: *** [check] Error 2


When I checked in /opt/pgsql/src/postgresql-8.2.4/src/test/regress/log/initdb.log
It says:
# more /opt/pgsql/src/postgresql-8.2.4/src/test/regress/log/initdb.log
Running in noclean mode. Mistakes will not be cleaned up.
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
Shinji Teragaito_1
Respected Contributor

Re: DB starting error

> But unfortunately after this when I am trying to enable postgres
> support for plperl , it is not creating the plperl.sl shared library

When configuring PostgreSQL, did you use the newly created perl ?
In you case, you should have the following result:

% which perl
/usr/local/perl5/bin/perl
%


Here's the summary to build PostgreSQL with PL/PERL.

(1) How to build Perl with a shared libperl
-------------------------------------------

I downloaded perl-5.10.0 source code from http://www.perl.org/.

% gzcat perl-5.10.0.tar.gz | tar xvf -
% cd perl-5.10.0

[64-bit build]
% ./Configure -des -Duseshrplib -Duse64bitall \
-Dprefix=/usr/local/perl5 2>&1 | tee Configure.log

% make 2>&1 | tee make.log
% make test 2>&1 | tee maketest.log

% su
# make install 2>&1 | tee makeinstall.log
# exit

% export PATH=/usr/local/perl5/bin:$PATH

NOTE: /usr/local/perl5/bin/perl should be used from now on.

% perl -MConfig -e 'print "$Config{useshrplib}\n"'
true
%

(2) How to build PostgreSQL with PL/PERL
----------------------------------------

I downloaded posgresql 8.3.5 from http://www.postgresql.org/

% gzcat postgresql-8.3.5.tar.gz | tar xvf -
% cd postgresql-8.3.5

[64-bit build]

% env CC=cc CFLAGS="+O2 +DD64" ./configure \
--without-readline --without-zlib --with-perl \
--enable-integer-datetimes --with-openssl 2>&1 | tee configure.log

% vi src/Makefile.global
< perl_embed_ldflags = +DD64 -L/usr/local/lib -L/lib/pa20_64 -L/usr/local/perl5/
< lib/5.10.0/PA-RISC2.0-LP64/CORE -lperl -lnsl -lnm -ldl -ldld -lm -lsec -lc
--
> perl_embed_ldflags = -L/usr/local/lib -L/lib/pa20_64 -L/usr/local/perl5/
> lib/5.10.0/PA-RISC2.0-LP64/CORE -lperl -lnsl -lnm -ldl -ldld -lm -lsec -lc

If you don't have +DD64 in the following output, you don't have to
change the perl_embed_ldflags line in src/Makefile.global. If you have
it and don't change the line, you will have a link error for libplperl.sl.0.

% perl -MExtUtils::Embed -e ldopts
-Wl,-E -Wl,-B,deferred +DD64 -L/usr/local/lib -L/lib/pa20_64 -L/usr/local/perl5/lib/5.10.0/PA-RISC2.0-LP64/CORE -lperl -lnsl -lnm -ldl -ldld -lm -lsec -lc

% gmake 2>&1 | tee make.log
% gmake check 2>&1 | tee makecheck.log

=======================
All 114 tests passed.
=======================

%

I hope this helps you.

Sutapa Dey
Frequent Advisor

Re: DB starting error

Thanks to all I have been able to sucessfully complete this task. My special thanks goes to Teragito Shinji......