2010-09-20 22:08:53 +02:00
|
|
|
# src/pl/plpython/Makefile
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2001-05-12 03:30:30 +02:00
|
|
|
subdir = src/pl/plpython
|
|
|
|
top_builddir = ../../..
|
|
|
|
include $(top_builddir)/src/Makefile.global
|
2001-05-09 21:54:38 +02:00
|
|
|
|
|
|
|
|
2015-05-03 14:17:04 +02:00
|
|
|
# On Windows we have to remove -lpython from the link since we are
|
|
|
|
# building our own
|
2004-10-06 11:20:41 +02:00
|
|
|
ifeq ($(PORTNAME), win32)
|
2007-02-09 16:56:00 +01:00
|
|
|
override python_libspec =
|
2004-10-06 11:20:41 +02:00
|
|
|
endif
|
|
|
|
|
2011-03-01 03:31:39 +01:00
|
|
|
override CPPFLAGS := -I. -I$(srcdir) $(python_includespec) $(CPPFLAGS)
|
2004-11-19 20:23:01 +01:00
|
|
|
|
|
|
|
rpathdir = $(python_libdir)
|
2001-05-25 17:48:33 +02:00
|
|
|
|
2014-07-14 20:07:52 +02:00
|
|
|
PGFILEDESC = "PL/Python - procedural language"
|
|
|
|
|
2009-12-15 23:59:55 +01:00
|
|
|
NAME = plpython$(python_majorversion)
|
2011-03-05 03:51:14 +01:00
|
|
|
|
2011-12-18 20:14:16 +01:00
|
|
|
OBJS = \
|
2019-12-18 02:42:40 +01:00
|
|
|
$(WIN32RES) \
|
2011-12-18 20:14:16 +01:00
|
|
|
plpy_cursorobject.o \
|
|
|
|
plpy_elog.o \
|
|
|
|
plpy_exec.o \
|
|
|
|
plpy_main.o \
|
|
|
|
plpy_planobject.o \
|
|
|
|
plpy_plpymodule.o \
|
|
|
|
plpy_procedure.o \
|
|
|
|
plpy_resultobject.o \
|
|
|
|
plpy_spi.o \
|
|
|
|
plpy_subxactobject.o \
|
|
|
|
plpy_typeio.o \
|
2019-12-18 02:42:40 +01:00
|
|
|
plpy_util.o
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2020-02-19 22:59:14 +01:00
|
|
|
DATA = $(NAME)u.control $(NAME)u--1.0.sql
|
2011-03-05 03:51:14 +01:00
|
|
|
|
2018-09-16 19:46:45 +02:00
|
|
|
# header files to install - it's not clear which of these might be needed
|
|
|
|
# so install them all.
|
|
|
|
INCS = plpython.h \
|
|
|
|
plpy_cursorobject.h \
|
|
|
|
plpy_elog.h \
|
|
|
|
plpy_exec.h \
|
|
|
|
plpy_main.h \
|
|
|
|
plpy_planobject.h \
|
|
|
|
plpy_plpymodule.h \
|
|
|
|
plpy_procedure.h \
|
|
|
|
plpy_resultobject.h \
|
|
|
|
plpy_spi.h \
|
|
|
|
plpy_subxactobject.h \
|
|
|
|
plpy_typeio.h \
|
|
|
|
plpy_util.h
|
2004-10-06 11:20:41 +02:00
|
|
|
|
|
|
|
# Python on win32 ships with import libraries only for Microsoft Visual C++,
|
|
|
|
# which are not compatible with mingw gcc. Therefore we need to build a
|
|
|
|
# new import library to link with.
|
|
|
|
ifeq ($(PORTNAME), win32)
|
2014-02-14 17:31:35 +01:00
|
|
|
|
2004-10-06 11:20:41 +02:00
|
|
|
pytverstr=$(subst .,,${python_version})
|
2014-02-14 17:31:35 +01:00
|
|
|
PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
|
|
|
|
|
2004-10-06 11:20:41 +02:00
|
|
|
OBJS += libpython${pytverstr}.a
|
2014-02-14 17:31:35 +01:00
|
|
|
|
2004-10-06 11:20:41 +02:00
|
|
|
libpython${pytverstr}.a: python${pytverstr}.def
|
2014-02-14 17:31:35 +01:00
|
|
|
dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib libpython${pytverstr}.a
|
|
|
|
|
2014-11-03 03:43:30 +01:00
|
|
|
python${pytverstr}.def:
|
2022-02-10 19:44:05 +01:00
|
|
|
gendef - $(PYTHONDLL) > $@
|
2014-02-14 17:31:35 +01:00
|
|
|
|
|
|
|
endif # win32
|
2004-10-06 11:20:41 +02:00
|
|
|
|
|
|
|
|
2009-01-15 14:49:57 +01:00
|
|
|
SHLIB_LINK = $(python_libspec) $(python_additional_libs) $(filter -lintl,$(LIBS))
|
2001-05-12 19:49:32 +02:00
|
|
|
|
2009-12-15 23:59:55 +01:00
|
|
|
REGRESS_OPTS = --dbname=$(PL_TESTDB)
|
2011-03-05 21:13:15 +01:00
|
|
|
|
2009-08-12 18:37:26 +02:00
|
|
|
REGRESS = \
|
|
|
|
plpython_schema \
|
|
|
|
plpython_populate \
|
|
|
|
plpython_test \
|
2010-01-22 16:45:15 +01:00
|
|
|
plpython_do \
|
2009-08-12 18:37:26 +02:00
|
|
|
plpython_global \
|
|
|
|
plpython_import \
|
|
|
|
plpython_spi \
|
|
|
|
plpython_newline \
|
|
|
|
plpython_void \
|
2017-11-30 14:46:13 +01:00
|
|
|
plpython_call \
|
2009-08-12 18:37:26 +02:00
|
|
|
plpython_params \
|
|
|
|
plpython_setof \
|
|
|
|
plpython_record \
|
|
|
|
plpython_trigger \
|
2009-08-14 15:42:16 +02:00
|
|
|
plpython_types \
|
2009-08-12 18:37:26 +02:00
|
|
|
plpython_error \
|
2016-06-07 15:33:41 +02:00
|
|
|
plpython_ereport \
|
2009-08-12 18:37:26 +02:00
|
|
|
plpython_unicode \
|
2011-02-22 22:33:44 +01:00
|
|
|
plpython_quote \
|
2011-02-26 15:53:11 +01:00
|
|
|
plpython_composite \
|
2011-02-27 16:09:56 +01:00
|
|
|
plpython_subtransaction \
|
Transaction control in PL procedures
In each of the supplied procedural languages (PL/pgSQL, PL/Perl,
PL/Python, PL/Tcl), add language-specific commit and rollback
functions/commands to control transactions in procedures in that
language. Add similar underlying functions to SPI. Some additional
cleanup so that transaction commit or abort doesn't blow away data
structures still used by the procedure call. Add execution context
tracking to CALL and DO statements so that transaction control commands
can only be issued in top-level procedure and block calls, not function
calls or other procedure or block calls.
- SPI
Add a new function SPI_connect_ext() that is like SPI_connect() but
allows passing option flags. The only option flag right now is
SPI_OPT_NONATOMIC. A nonatomic SPI connection can execute transaction
control commands, otherwise it's not allowed. This is meant to be
passed down from CALL and DO statements which themselves know in which
context they are called. A nonatomic SPI connection uses different
memory management. A normal SPI connection allocates its memory in
TopTransactionContext. For nonatomic connections we use PortalContext
instead. As the comment in SPI_connect_ext() (previously SPI_connect())
indicates, one could potentially use PortalContext in all cases, but it
seems safest to leave the existing uses alone, because this stuff is
complicated enough already.
SPI also gets new functions SPI_start_transaction(), SPI_commit(), and
SPI_rollback(), which can be used by PLs to implement their transaction
control logic.
- portalmem.c
Some adjustments were made in the code that cleans up portals at
transaction abort. The portal code could already handle a command
*committing* a transaction and continuing (e.g., VACUUM), but it was not
quite prepared for a command *aborting* a transaction and continuing.
In AtAbort_Portals(), remove the code that marks an active portal as
failed. As the comment there already predicted, this doesn't work if
the running command wants to keep running after transaction abort. And
it's actually not necessary, because pquery.c is careful to run all
portal code in a PG_TRY block and explicitly runs MarkPortalFailed() if
there is an exception. So the code in AtAbort_Portals() is never used
anyway.
In AtAbort_Portals() and AtCleanup_Portals(), we need to be careful not
to clean up active portals too much. This mirrors similar code in
PreCommit_Portals().
- PL/Perl
Gets new functions spi_commit() and spi_rollback()
- PL/pgSQL
Gets new commands COMMIT and ROLLBACK.
Update the PL/SQL porting example in the documentation to reflect that
transactions are now possible in procedures.
- PL/Python
Gets new functions plpy.commit and plpy.rollback.
- PL/Tcl
Gets new commands commit and rollback.
Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2018-01-22 14:30:16 +01:00
|
|
|
plpython_transaction \
|
2009-08-12 18:37:26 +02:00
|
|
|
plpython_drop
|
2011-03-05 21:13:15 +01:00
|
|
|
|
2001-05-12 03:30:30 +02:00
|
|
|
include $(top_srcdir)/src/Makefile.shlib
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2016-10-01 19:35:13 +02:00
|
|
|
all: all-lib
|
|
|
|
|
2018-04-10 22:14:55 +02:00
|
|
|
# Ensure parallel safety if a build is started in this directory
|
|
|
|
$(OBJS): | submake-generated-headers
|
|
|
|
|
2011-03-06 00:32:06 +01:00
|
|
|
install: all install-lib install-data
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
installdirs: installdirs-lib
|
2022-08-31 07:42:01 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/extension' '$(DESTDIR)$(includedir_server)'
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2011-03-05 03:51:14 +01:00
|
|
|
uninstall: uninstall-lib uninstall-data
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2011-03-06 00:32:06 +01:00
|
|
|
install-data: installdirs
|
2011-05-01 23:37:07 +02:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
|
2018-09-16 19:46:45 +02:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(INCS)) '$(DESTDIR)$(includedir_server)'
|
2011-03-05 03:51:14 +01:00
|
|
|
|
|
|
|
uninstall-data:
|
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
|
2015-04-26 16:33:14 +02:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/, plpython.h plpy_util.h)
|
2011-03-05 03:51:14 +01:00
|
|
|
|
|
|
|
.PHONY: install-data uninstall-data
|
|
|
|
|
|
|
|
|
2016-07-01 21:08:55 +02:00
|
|
|
check: submake-pg-regress
|
2011-02-14 20:52:32 +01:00
|
|
|
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
|
|
|
|
|
2016-07-01 21:08:55 +02:00
|
|
|
installcheck: submake-pg-regress
|
2011-02-14 20:52:32 +01:00
|
|
|
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-17 04:26:33 +02:00
|
|
|
|
2005-05-14 19:55:22 +02:00
|
|
|
|
2016-07-01 21:08:55 +02:00
|
|
|
.PHONY: submake-pg-regress
|
2018-04-12 16:38:48 +02:00
|
|
|
submake-pg-regress: | submake-generated-headers
|
2006-07-19 04:37:00 +02:00
|
|
|
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
2005-05-14 19:55:22 +02:00
|
|
|
|
2011-02-28 17:41:10 +01:00
|
|
|
clean distclean: clean-lib
|
2001-05-12 03:30:30 +02:00
|
|
|
rm -f $(OBJS)
|
2011-02-14 20:52:32 +01:00
|
|
|
rm -rf $(pg_regress_clean_files)
|
2004-10-06 11:20:41 +02:00
|
|
|
ifeq ($(PORTNAME), win32)
|
|
|
|
rm -f python${pytverstr}.def
|
|
|
|
endif
|
2001-05-09 21:54:38 +02:00
|
|
|
|
2011-07-03 19:55:02 +02:00
|
|
|
|
|
|
|
# Force this dependency to be known even without dependency info built:
|
2011-12-18 21:34:53 +01:00
|
|
|
plpy_plpymodule.o: spiexceptions.h
|
2011-07-03 19:55:02 +02:00
|
|
|
|
|
|
|
spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
|
|
|
|
$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
|
|
|
|
|
|
|
|
distprep: spiexceptions.h
|
|
|
|
|
|
|
|
maintainer-clean: distclean
|
|
|
|
rm -f spiexceptions.h
|