|
|
|
# Makefile for PL/Perl
|
|
|
|
# src/pl/plperl/GNUmakefile
|
|
|
|
|
|
|
|
subdir = src/pl/plperl
|
|
|
|
top_builddir = ../../..
|
|
|
|
include $(top_builddir)/src/Makefile.global
|
|
|
|
|
|
|
|
ifeq ($(PORTNAME), win32)
|
|
|
|
override CPPFLAGS += -DPLPERL_HAVE_UID_GID
|
|
|
|
# Perl on win32 contains /* within comment all over the header file,
|
|
|
|
# so disable this warning.
|
|
|
|
override CPPFLAGS += -Wno-comment
|
|
|
|
endif
|
|
|
|
|
Still further rethinking of build changes for macOS Mojave.
To avoid the sorts of problems complained of by Jakob Egger, it'd be
best if configure didn't emit any references to the sysroot path at all.
In the case of PL/Tcl, we can do that just by keeping our hands off the
TCL_INCLUDE_SPEC string altogether. In the case of PL/Perl, we need to
substitute -iwithsysroot for -I in the compile commands, which is easily
handled if we change to using a configure output variable that includes
the switch not only the directory name. Since PL/Tcl and PL/Python
already do it like that, this seems like good consistency cleanup anyway.
Hence, this replaces the advice given to Perl-related extensions in commit
5e2217131; instead of writing "-I$(perl_archlibexp)/CORE", they should
just write "$(perl_includespec)". (The old way continues to work, but not
on recent macOS.)
It's still the case that configure needs to be aware of the sysroot
path internally, but that's cleaner than what we had before.
As before, back-patch to all supported versions.
Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
7 years ago
|
|
|
# Note: we need to include the perl_includespec directory last,
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
8 years ago
|
|
|
# probably because it sometimes contains some header files with names
|
|
|
|
# that clash with some of ours, or with some that we include, notably on
|
|
|
|
# Windows.
|
Still further rethinking of build changes for macOS Mojave.
To avoid the sorts of problems complained of by Jakob Egger, it'd be
best if configure didn't emit any references to the sysroot path at all.
In the case of PL/Tcl, we can do that just by keeping our hands off the
TCL_INCLUDE_SPEC string altogether. In the case of PL/Perl, we need to
substitute -iwithsysroot for -I in the compile commands, which is easily
handled if we change to using a configure output variable that includes
the switch not only the directory name. Since PL/Tcl and PL/Python
already do it like that, this seems like good consistency cleanup anyway.
Hence, this replaces the advice given to Perl-related extensions in commit
5e2217131; instead of writing "-I$(perl_archlibexp)/CORE", they should
just write "$(perl_includespec)". (The old way continues to work, but not
on recent macOS.)
It's still the case that configure needs to be aware of the sysroot
path internally, but that's cleaner than what we had before.
As before, back-patch to all supported versions.
Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
7 years ago
|
|
|
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)
|
|
|
|
|
Still further rethinking of build changes for macOS Mojave.
To avoid the sorts of problems complained of by Jakob Egger, it'd be
best if configure didn't emit any references to the sysroot path at all.
In the case of PL/Tcl, we can do that just by keeping our hands off the
TCL_INCLUDE_SPEC string altogether. In the case of PL/Perl, we need to
substitute -iwithsysroot for -I in the compile commands, which is easily
handled if we change to using a configure output variable that includes
the switch not only the directory name. Since PL/Tcl and PL/Python
already do it like that, this seems like good consistency cleanup anyway.
Hence, this replaces the advice given to Perl-related extensions in commit
5e2217131; instead of writing "-I$(perl_archlibexp)/CORE", they should
just write "$(perl_includespec)". (The old way continues to work, but not
on recent macOS.)
It's still the case that configure needs to be aware of the sysroot
path internally, but that's cleaner than what we had before.
As before, back-patch to all supported versions.
Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
7 years ago
|
|
|
# this is often, but not always, the same directory named by perl_includespec
|
|
|
|
rpathdir = $(perl_archlibexp)/CORE
|
|
|
|
|
|
|
|
PGFILEDESC = "PL/Perl - procedural language"
|
|
|
|
|
|
|
|
NAME = plperl
|
|
|
|
|
|
|
|
OBJS = plperl.o SPI.o Util.o $(WIN32RES)
|
|
|
|
|
|
|
|
DATA = plperl.control plperl--1.0.sql plperl--unpackaged--1.0.sql \
|
|
|
|
plperlu.control plperlu--1.0.sql plperlu--unpackaged--1.0.sql
|
|
|
|
|
|
|
|
PERLCHUNKS = plc_perlboot.pl plc_trusted.pl
|
|
|
|
|
|
|
|
# Perl 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)
|
|
|
|
|
|
|
|
perlwithver := $(subst -l,,$(filter -l%, $(perl_embed_ldflags)))
|
|
|
|
PERLDLL := $(dir $(subst ',,$(PERL)))$(perlwithver).dll
|
|
|
|
# we no longer want to include the original -l spec in SHLIB_LINK
|
|
|
|
override perl_embed_ldflags :=
|
|
|
|
|
|
|
|
OBJS += lib$(perlwithver).a
|
|
|
|
|
|
|
|
lib$(perlwithver).a: $(perlwithver).def
|
|
|
|
dlltool --dllname $(perlwithver).dll --def $(perlwithver).def --output-lib lib$(perlwithver).a
|
|
|
|
|
|
|
|
$(perlwithver).def: $(PERLDLL)
|
|
|
|
pexports $^ > $@
|
|
|
|
|
|
|
|
endif # win32
|
|
|
|
|
|
|
|
|
|
|
|
SHLIB_LINK = $(perl_embed_ldflags)
|
|
|
|
|
|
|
|
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=plperl --load-extension=plperlu
|
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>
8 years ago
|
|
|
REGRESS = plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array plperl_call plperl_transaction
|
|
|
|
# if Perl can support two interpreters in one backend,
|
|
|
|
# test plperl-and-plperlu cases
|
|
|
|
ifneq ($(PERL),)
|
|
|
|
ifeq ($(shell $(PERL) -V:usemultiplicity), usemultiplicity='define';)
|
|
|
|
REGRESS += plperl_plperlu
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# where to find xsubpp for building XS.
|
|
|
|
XSUBPPDIR = $(shell $(PERL) -e 'use List::Util qw(first); print first { -r "$$_/ExtUtils/xsubpp" } @INC')
|
|
|
|
|
|
|
|
include $(top_srcdir)/src/Makefile.shlib
|
|
|
|
|
|
|
|
plperl.o: perlchunks.h plperl_opmask.h plperl_helpers.h
|
|
|
|
|
|
|
|
plperl_opmask.h: plperl_opmask.pl
|
|
|
|
@if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
|
|
|
|
$(PERL) $< $@
|
|
|
|
|
|
|
|
perlchunks.h: $(PERLCHUNKS)
|
|
|
|
@if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
|
|
|
|
$(PERL) $(srcdir)/text2macro.pl --strip='^(\#.*|\s*)$$' $^ > $@
|
|
|
|
|
|
|
|
all: all-lib
|
|
|
|
|
|
|
|
%.c: %.xs
|
|
|
|
@if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
|
|
|
|
# xsubpp -output option is required for coverage+vpath, but requires Perl 5.9.3
|
|
|
|
ifeq ($(enable_coverage)$(vpath_build),yesyes)
|
|
|
|
$(PERL) $(XSUBPPDIR)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap -output $@ $<
|
|
|
|
else
|
|
|
|
$(PERL) $(XSUBPPDIR)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap $< >$@
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
install: all install-lib install-data
|
|
|
|
|
|
|
|
installdirs: installdirs-lib
|
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/extension' '$(DESTDIR)$(includedir_server)'
|
|
|
|
|
|
|
|
uninstall: uninstall-lib uninstall-data
|
|
|
|
|
|
|
|
install-data: installdirs
|
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
|
|
|
|
$(INSTALL_DATA) $(srcdir)/plperl.h $(srcdir)/ppport.h $(srcdir)/plperl_helpers.h '$(DESTDIR)$(includedir_server)'
|
|
|
|
|
|
|
|
uninstall-data:
|
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
|
|
|
|
rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/, plperl.h ppport.h)
|
|
|
|
|
|
|
|
.PHONY: install-data uninstall-data
|
|
|
|
|
|
|
|
|
|
|
|
check: submake
|
|
|
|
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
|
|
|
|
|
|
|
|
installcheck: submake
|
|
|
|
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
|
|
|
|
|
|
|
|
.PHONY: submake
|
|
|
|
submake:
|
|
|
|
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
|
|
|
|
|
|
|
clean distclean maintainer-clean: clean-lib
|
|
|
|
rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
|
|
|
|
rm -rf $(pg_regress_clean_files)
|
|
|
|
ifeq ($(PORTNAME), win32)
|
|
|
|
rm -f $(perlwithver).def
|
|
|
|
endif
|