1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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.
This commit is contained in:
Peter Eisentraut
2001-05-12 17:49:32 +00:00
parent 02549a2d2c
commit bbc3920fe9
12 changed files with 738 additions and 498 deletions

View File

@ -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@

View File

@ -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

View File

@ -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)
# Python 2 seems to want libdb.
#SHLIB_LINK += -ldb2
# 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.
# version 2.x
ifneq (,$(findstring 2.,$(python_version)))
EXTRA_MODULES = array cmath errno math md5 operator pcre sha time
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)
# version 1.x
ifneq (,$(findstring 1.,$(python_version)))
EXTRA_MODULES = arraymodule cmathmodule errnomodule mathmodule md5module operator shamodule timemodule
endif
SHLIB_LINK += $(addprefix $(python_dynlibdir)/, $(addsuffix $(DLSUFFIX), $(EXTRA_MODULES)))
include $(top_srcdir)/src/Makefile.shlib

View File

@ -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>
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.

View File

@ -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');

View File

@ -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