pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. 6+ messages / 1 participants [nested] [flat]
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-28 16:25 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-28 16:25 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. In Perl builds that define PERL_IMPLICIT_SYS, XSUB.h defines macros that replace a whole lot of basic libc functions with Perl functions. We can't tolerate that in plperl.c; it breaks at least PG_TRY and probably other stuff. The core idea of this patch is to include XSUB.h only in the .xs files where it's really needed, and to move any code broken by PERL_IMPLICIT_SYS out of the .xs files and into plperl.c. The reason this hasn't been a problem before is that our build techniques did not result in PERL_IMPLICIT_SYS appearing as a #define in PL/Perl, even on some platforms where Perl thinks it is defined. That's about to change in order to fix a nasty portability issue, so we need this work to make the code safe for that. Rather unaccountably, the Perl people chose XSUB.h as the place to provide the versions of the aTHX/aTHX_ macros that are needed by code that's not explicitly aware of the MULTIPLICITY API conventions. Hence, just removing XSUB.h from plperl.c fails miserably. But we can work around that by defining PERL_NO_GET_CONTEXT (which would make the relevant stanza of XSUB.h a no-op anyway). As explained in perlguts.pod, that means we need to add a "dTHX" macro call in every C function that calls a Perl API function. In most of them we just add this at the top; but since the macro fetches the current Perl interpreter pointer, more care is needed in functions that switch the active interpreter. Lack of the macro is easily recognized since it results in bleats about "my_perl" not being defined. (A nice side benefit of this is that it significantly reduces the number of fetches of the current interpreter pointer. On my machine, plperl.so gets more than 10% smaller, and there's probably some performance win too. We could reduce the number of fetches still more by decorating the code with pTHX_/aTHX_ macros to pass the interpreter pointer around, as explained by perlguts.pod; but that's a task for another day.) Formatting note: pgindent seems happy to treat "dTHX;" as a declaration so long as it's the first thing after the left brace, as we'd already observed with respect to the similar macro "dSP;". If you try to put it later in a set of declarations, pgindent puts ugly extra space around it. Having removed XSUB.h from plperl.c, we need only move the support functions for spi_return_next and util_elog (both of which use PG_TRY) out of the .xs files and into plperl.c. This seems sufficient to avoid the known problems caused by PERL_IMPLICIT_SYS, although we could move more code if additional issues emerge. This will need to be back-patched, but first let's see what the buildfarm makes of it. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/bebe174bb4462ef079a1d7eeafb82ff969f160a4 Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 6 +- src/pl/plperl/SPI.xs | 32 +---- src/pl/plperl/Util.xs | 44 +----- src/pl/plperl/plperl.c | 244 +++++++++++++++++++++++++--------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 4 + 6 files changed, 210 insertions(+), 137 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-31 16:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-31 16:38 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. Back-patch of commit bebe174bb4462ef079a1d7eeafb82ff969f160a4, which see for more info. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/30a5c8bfbd7bec07385c7d40305b06385d700b3f Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 6 +- src/pl/plperl/SPI.xs | 32 +---- src/pl/plperl/Util.xs | 44 +----- src/pl/plperl/plperl.c | 244 +++++++++++++++++++++++++--------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 4 + 6 files changed, 210 insertions(+), 137 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-31 16:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-31 16:38 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. Back-patch of commit bebe174bb4462ef079a1d7eeafb82ff969f160a4, which see for more info. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/99eea89dbe31fbd78d08a56e53f5bc272bbcd064 Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 6 +- src/pl/plperl/SPI.xs | 32 +---- src/pl/plperl/Util.xs | 44 +----- src/pl/plperl/plperl.c | 244 +++++++++++++++++++++++++--------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 4 + 6 files changed, 210 insertions(+), 137 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-31 16:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-31 16:38 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. Back-patch of commit bebe174bb4462ef079a1d7eeafb82ff969f160a4, which see for more info. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d48180ec812d6d2c1c17900613d05bf6e8d76994 Modified Files -------------- src/pl/plperl/SPI.xs | 32 +----- src/pl/plperl/Util.xs | 44 +------- src/pl/plperl/plperl.c | 238 +++++++++++++++++++++++++++++++---------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 6 ++ 5 files changed, 206 insertions(+), 131 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-31 16:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-31 16:38 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. Back-patch of commit bebe174bb4462ef079a1d7eeafb82ff969f160a4, which see for more info. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ REL9_3_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b92f17277eb92da18366ccddeffcea997692f9e5 Modified Files -------------- src/pl/plperl/SPI.xs | 32 +----- src/pl/plperl/Util.xs | 44 +------- src/pl/plperl/plperl.c | 236 +++++++++++++++++++++++++++++++---------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 6 ++ 5 files changed, 205 insertions(+), 130 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. @ 2017-07-31 16:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2017-07-31 16:38 UTC (permalink / raw) To: pgsql-committers PL/Perl portability fix: avoid including XSUB.h in plperl.c. Back-patch of commit bebe174bb4462ef079a1d7eeafb82ff969f160a4, which see for more info. Patch by me, with some help from Ashutosh Sharma Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com Branch ------ REL9_2_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b4b958251fbfc45690656d306938a76a46d91145 Modified Files -------------- src/pl/plperl/SPI.xs | 32 +----- src/pl/plperl/Util.xs | 44 +------- src/pl/plperl/plperl.c | 236 +++++++++++++++++++++++++++++++---------- src/pl/plperl/plperl.h | 17 ++- src/pl/plperl/plperl_helpers.h | 6 ++ 5 files changed, 205 insertions(+), 130 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2017-07-31 16:38 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2017-07-28 16:25 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us> 2017-07-31 16:38 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us> 2017-07-31 16:38 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us> 2017-07-31 16:38 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us> 2017-07-31 16:38 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us> 2017-07-31 16:38 pgsql: PL/Perl portability fix: avoid including XSUB.h in plperl.c. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox