pl/perl extension fails on Windows

Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>

From: Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-07-12T12:19:09Z
Lists: pgsql-hackers
Hi,

I compiled PG 10 beta1/beta2 with "--with-perl" option on Windows and the
extension crashes the database.
--
postgres=# create extension plperl;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
postgres=#

It doesn't produce crashdump (in $DATA/crashdumps) but the log contains the
following error:

*src/pl/plperl/Util.c: loadable library and perl binaries are mismatched
(got handshake key 0A900080, needed 0AC80080)*
--

This is seen with Perl 5.24 but not with 5.20, 5.16. What I found is that
the handshake function is added in Perl 5.21.x and probably that is why we
don't see this issue in earlier versions.

The Perl that is used during compilation and on the target machine is same.
So probably plperl is not able to load the perl library. It works fine on
Linux and MacOS.

-- 
Sandeep Thakkar
EDB

Commits

  1. MSVC: Test whether 32-bit Perl needs -D_USE_32BIT_TIME_T.

  2. Further tweaks to compiler flags for PL/Perl on Windows.

  3. Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant.

  4. PL/Perl portability fix: absorb relevant -D switches from Perl.

  5. PL/Perl portability fix: avoid including XSUB.h in plperl.c.