diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2001-05-12 17:49:32 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2001-05-12 17:49:32 +0000 |
commit | bbc3920fe9fdefbb16096fd72114d262168fff4e (patch) | |
tree | cbbd6c2cfc0e0e0b51c03c207cbf4d3852057452 /src | |
parent | 02549a2d2c6a7ffc6188fc113c695886308ecfa5 (diff) | |
download | postgresql-bbc3920fe9fdefbb16096fd72114d262168fff4e.tar.gz postgresql-bbc3920fe9fdefbb16096fd72114d262168fff4e.zip |
PL/Python should build portably now, if you can get over the fact that
there's no shared libpython. Test suite works as well. Also, add some
documentation.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.global.in | 10 | ||||
-rw-r--r-- | src/interfaces/python/GNUmakefile | 4 | ||||
-rw-r--r-- | src/pl/plpython/Makefile | 40 | ||||
-rw-r--r-- | src/pl/plpython/TODO | 34 | ||||
-rw-r--r-- | src/pl/plpython/feature.expected | 6 | ||||
-rw-r--r-- | src/pl/plpython/plpython_test.sql | 2 |
6 files changed, 55 insertions, 41 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in index b5155a74d59..f4c94f2468d 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.126 2001/05/09 20:19:30 momjian Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.127 2001/05/12 17:49:32 petere Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -118,8 +118,12 @@ MULTIBYTE = @MULTIBYTE@ enable_shared = @enable_shared@ enable_rpath = @enable_rpath@ -python_extmakefile = @python_extmakefile@ -python_moduledir = @python_moduledir@ +python_version = @python_version@ +python_includedir = @python_includedir@ +python_makefile_pre_in = @python_makefile_pre_in@ +python_moduledir = @python_moduledir@ +python_libspec = @python_libspec@ +python_dynlibdir = @python_dynlibdir@ krb_srvtab = @krb_srvtab@ diff --git a/src/interfaces/python/GNUmakefile b/src/interfaces/python/GNUmakefile index 7e1a1d0bd62..e60e5e91565 100644 --- a/src/interfaces/python/GNUmakefile +++ b/src/interfaces/python/GNUmakefile @@ -4,7 +4,7 @@ # # Written by Peter Eisentraut <peter_e@gmx.net> # -# $Header: /cvsroot/pgsql/src/interfaces/python/Attic/GNUmakefile,v 1.6 2001/03/25 19:44:03 petere Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/python/Attic/GNUmakefile,v 1.7 2001/05/12 17:49:32 petere Exp $ # #------------------------------------------------------------------- @@ -22,7 +22,7 @@ libpq-all: Makefile: Setup.in Makefile.pre.in $(MAKE) -f Makefile.pre.in boot srcdir=$(srcdir) VPATH=$(srcdir) -Makefile.pre.in: $(python_extmakefile) +Makefile.pre.in: $(python_makefile_pre_in) cp $< $@ Setup.in: Setup.in.raw diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile index 88cc8ebb4cb..1ceadc9508b 100644 --- a/src/pl/plpython/Makefile +++ b/src/pl/plpython/Makefile @@ -1,42 +1,36 @@ -# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.4 2001/05/12 01:30:30 petere Exp $ +# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.5 2001/05/12 17:49:32 petere Exp $ subdir = src/pl/plpython top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -# These things ought to go into $(top_srcdir)/config/python.m4 sometime. -PYTHON_VERSION := $(shell $(PYTHON) -c 'import sys; print sys.version[:3]') -PYTHON_INCLUDE := $(shell $(PYTHON) -c 'import sys; print sys.prefix')/include/python$(PYTHON_VERSION) - -override CPPFLAGS := -I$(srcdir) -I$(PYTHON_INCLUDE) $(CPPFLAGS) - -PYTHON_LIB := $(shell $(PYTHON) -c 'import sys; print sys.exec_prefix')/lib/python$(PYTHON_VERSION) +override CPPFLAGS := -I$(srcdir) -I$(python_includedir) $(CPPFLAGS) NAME = plpython SO_MAJOR_VERSION = 0 SO_MINOR_VERSION = 0 OBJS = plpython.o -# This static version might work on most ELF systems... -SHLIB_LINK += $(PYTHON_LIB)/config/libpython$(PYTHON_VERSION).a -# ...otherwise you need a shared version, but you need to build that yourself. -#SHLIB_LINK += -lpython$(PYTHON_VERSION) -# Python uses this. Should become a configure check. -SHLIB_LINK += -lpthread +SHLIB_LINK += $(python_libspec) + +# If you have not patched the dynamic loader files as described in the +# README you will have to link these in manually. You may have to add +# more modules. If you have patched the loader, override +# EXTRA_MODULES to be empty. -# Python 2 seems to want libdb. -#SHLIB_LINK += -ldb2 +# version 2.x +ifneq (,$(findstring 2.,$(python_version))) +EXTRA_MODULES = array cmath errno math md5 operator pcre sha time +endif +# version 1.x +ifneq (,$(findstring 1.,$(python_version))) +EXTRA_MODULES = arraymodule cmathmodule errnomodule mathmodule md5module operator shamodule timemodule +endif -# Hopefully you won't need this utter crap. But if you can't patch -# the appropriate dynloader file, try this. You may have to add other -# modules. -# -#DLDIR=$(PYTHON_LIB)/lib-dynload -#DLHACK=$(DLDIR)/arraymodule.so $(DLDIR)/timemodule.so $(DLDIR)/cmathmodule.so $(DLDIR)/errnomodule.so $(DLDIR)/mathmodule.so $(DLDIR)/md5module.so $(DLDIR)/operator.so $(DLDIR)/shamodule.so -#SHLIB_LINK += $(DLDIR) +SHLIB_LINK += $(addprefix $(python_dynlibdir)/, $(addsuffix $(DLSUFFIX), $(EXTRA_MODULES))) include $(top_srcdir)/src/Makefile.shlib diff --git a/src/pl/plpython/TODO b/src/pl/plpython/TODO index 249949f05af..a8da750f0c2 100644 --- a/src/pl/plpython/TODO +++ b/src/pl/plpython/TODO @@ -1,9 +1,25 @@ -<html> -<head><title>TODO</title></head> -<body bgcolor="white"> -In no special order<br> -<li>allow arrays as function arguments and return values (almost done). -<li>more and better documentation. -<li>improve/automate configuration. -<li>??? -</body>
\ No newline at end of file +In no particular order... + +* Allow arrays as function arguments and return values. (almost done) + +* Create a new restricted execution class that will allow me to pass + function arguments in as locals. Passing them as globals means + functions cannot be called recursively. + +* Functions cache the input and output functions for their arguments, + so the following will make PostgreSQL unhappy: + + create table users (first_name text, last_name text); + create function user_name(user) returns text as 'mycode' language 'plpython'; + select user_name(user) from users; + alter table add column user_id integer; + select user_name(user) from users; + + You have to drop and create the function(s) each time its arguments + are modified (not nice), or don't cache the input and output functions + (slower?), or check if the structure of the argument has been + altered (is this possible, easy, quick?) and recreate cache. + +* Better documentation + +* Add a DB-API compliant interface on top of the SPI interface. diff --git a/src/pl/plpython/feature.expected b/src/pl/plpython/feature.expected index 86722ece10d..eb294479307 100644 --- a/src/pl/plpython/feature.expected +++ b/src/pl/plpython/feature.expected @@ -53,12 +53,12 @@ select import_test_two(users) from users where fname = 'willem'; sha hash of willemdoe is 3cde6b574953b0ca937b4d76ebc40d534d910759 (1 row) -select argument_test_one(users, fname, lname) from users where lname = 'doe'; +select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1; argument_test_one ------------------------------------------------------------------------------------- - willem doe => {'fname': 'willem', 'userid': 3, 'lname': 'doe', 'username': 'w_doe'} - john doe => {'fname': 'john', 'userid': 2, 'lname': 'doe', 'username': 'johnd'} jane doe => {'fname': 'jane', 'userid': 1, 'lname': 'doe', 'username': 'j_doe'} + john doe => {'fname': 'john', 'userid': 2, 'lname': 'doe', 'username': 'johnd'} + willem doe => {'fname': 'willem', 'userid': 3, 'lname': 'doe', 'username': 'w_doe'} (3 rows) select nested_call_one('pass this along'); diff --git a/src/pl/plpython/plpython_test.sql b/src/pl/plpython/plpython_test.sql index 320312972bd..c78b4aa0c7f 100644 --- a/src/pl/plpython/plpython_test.sql +++ b/src/pl/plpython/plpython_test.sql @@ -26,7 +26,7 @@ select import_test_two(users) from users where fname = 'willem'; -- test multiple arguments -- -select argument_test_one(users, fname, lname) from users where lname = 'doe'; +select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1; -- spi and nested calls |