Subject: pkg/23349: [new pkg] databases/postgresql-plpython
To: None <gnats-bugs@gnats.netbsd.org>
From: Michal Pasternak <dotz@irc.pl>
List: netbsd-bugs
Date: 11/03/2003 01:16:18
>Number: 23349
>Category: pkg
>Synopsis: [new pkg] databases/postgresql-plpython
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Nov 03 01:18:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Michal Pasternak <dotz@irc.pl>
>Release: NetBSD 1.6.1
>Organization:
Good People With Bad Reputation
>Environment:
>Description:
I have created pl/python support package for PostgreSQL.
Current pkgsrc entry for postgresql is not yet ready to support
pl/python, so I also included some diffs and patches to it.
>How-To-Repeat:
1) install databases/postgresql
2) setup postgresql installation
3) from shell type:
$ createdb anydb
CREATE DATABASE
$ psql anydb
anydb=# CREATE FUNCTION plpython_call_handler () RETURNS language_handler AS '$libdir/plpython', 'plpython_call_handler' LANGUAGE c;
ERROR: stat failed on file '$libdir/plpython': No such file or directory
>Fix:
Needs some discussion.
For sake of clarity, I am using "postgresql" as an abbreviation for databases/postgresql/
and "plpython" as an abbreviation of databases/postgresql-plpython/.
Also please note, that this pkg is *NOT* available for use together with Python 2.2.3 or
Python 2.3, because rexec module functionality (that the PL/Python interpreter uses) has
been dropped at 2.2.3. You can read a message about it from Python's author, Guido van
Rossum, here: http://archives.postgresql.org/pgsql-hackers/2003-05/msg00687.php
Python's rexec functionality is still considered unsafe. I have included a big fat warning
in plpython's DISPLAY file about that.
First, please download, unzip and install as databases/postgresql-plpython:
http://pasternak.w.lub.pl/postgresql-plpython.import.tgz
Second, please add this patch as pkgsrc/databases/postgresql/patches/patch-aj:
........................................................................................
--- src/pl/plpython/Makefile~ Mon Nov 3 00:26:07 2003
+++ src/pl/plpython/Makefile Mon Nov 3 00:31:31 2003
@@ -8,9 +8,9 @@
# On some platforms we can only build PL/Python if libpython is a
# shared library. Since there is no official way to determine this,
# we see if there is a file that is named like a shared library.
-ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
+#ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
shared_libpython = yes
-endif
+#endif
# If we don't have a shared library and the platform doesn't allow it
# to work without, we have to skip it.
........................................................................................
Well, you could discuss about the quality of the above patch. As the comment
in ${WRKSRC}/src/pl/plpython/Makefile says - there is _no_ official way to determine
if the library is available; if the check for the availability of shared library
is not official, then well... no wonder it didn't work on NetBSD! :)
AFAIK Python's shared library is not available on every platform, so we still need
to check this. How? To enforce the check for the shared library, you can add later
ONLY_FOR_PLATFORM in plpython's Makefile to exclude platforms, which don't have Python
shared library.
Then, please apply the diff below. What does it do? As you can see, it includes checksum
for patch-aj and a post-patch entry. I would like this post-patch entry in
postgresql's Makefile.common - and _not_ in plpython's Makefile,
- for obvious reasons (in the future postgresql Makefile.common could possibly include
some other post-patch commands; if you place post-patch in plpython's Makefile (which includes
postgresql's Makefile.common), they will be duplicated - and thus ignored by make(1)
Ah, don't be afraid with applying those patches, I have checked this: they DO NOT break
postgresql-server build process.
........................................................................................
diff -u -r1.39 Makefile.common
--- Makefile.common 2003/08/18 00:26:24 1.39
+++ Makefile.common 2003/11/02 23:48:11
@@ -84,6 +84,14 @@
${CP} -f ${COMMON_FILESDIR}/GNUmakefile.libpgtcl \
${WRKSRC}/src/interfaces/libpgtcl/GNUmakefile; \
fi
+
+post-patch:
+ ${CP} ${WRKSRC}/src/Makefile.global.in \
+ ${WRKSRC}/src/Makefile.global.in.pkgsrc
+
+ ${SED} -e 's|@python_libspec@|-Wl,-R${PREFIX}/lib @python_libspec@|g' \
+ ${WRKSRC}/src/Makefile.global.in.pkgsrc > \
+ ${WRKSRC}/src/Makefile.global.in
pre-configure:
cd ${WRKSRC} && ${AUTOCONF}
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/databases/postgresql/distinfo,v
retrieving revision 1.18
diff -u -r1.18 distinfo
--- distinfo 2003/08/18 00:26:24 1.18
+++ distinfo 2003/11/02 23:48:11
@@ -10,3 +10,4 @@
SHA1 (patch-ag) = 6d12184b8401e63b8a05c620beb27f28248c22da
SHA1 (patch-ah) = 210c0dda3c32481280fe5f2a9525d33f1d989c6d
SHA1 (patch-ai) = d7889e05ab7963f2b93b46c953cbf1a44e9c0fe5
+SHA1 (patch-aj) = 38cea827132e036aac5e2185a99b04a184a2ea70
.......................................................................................
Then, compile and install postgresql-plpython.
Then, as in "How to repeat" paragraph, do:
anydb=# CREATE FUNCTION plpython_call_handler () RETURNS language_handler AS '$libdir/plpython', 'plpython_call_handler' LANGUAGE c;
CREATE FUNCTION
Success!
You can also try:
cd ${WRKSRC}/src/pl/plpython/ && ./test.sh
from an account which has access to PostgreSQL databases.
Some of tests will fail, depending if you have used Python 2.0 or Python 2.1.
This is really not an issue: I have examined log files and the only failed
functions were the ones, which were not available to Python interpreter because
of restricted mode - and those 2 versions just output error mesasges in a different
manner.
I am also planning to write a patch for plpython module so it could work with Python
versions greater, than 2.1. Sadly, such version would not include any restricted execution.
>Release-Note:
>Audit-Trail:
>Unformatted: