plperl on windows

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: plperl on windows
Date: 2021-10-04 21:38:16
Message-ID: 20211004213816.t5zgv4ba5zfijqzc@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

For https://postgr.es/m/20211001222752.wrz7erzh4cajvgp6@alap3.anarazel.de I
was trying to enable plperl on windows. And run into quite a few roadblocks -
enough that I gave up.

1) plperl doesn't build against a modern-ish perl. The fix for that seems easy
enough: https://postgr.es/m/20200501134711.08750c5f@antares.wagner.home

2) For some reason src/tools/install.pl doesn't install plperl[u].control,
plperl[u]--1.0.sql - But apparently the buildfarm doesn't have that issue,
because drongo successfully ran the plperl tests?

3) When building against strawberry perl 5.32.1.1 I see errors when loading
plperl

4) When building against strawberry perl 5.30.3.1 I see a crash during
execution of very simple statements [1]

5) Finally when building against strawberry perl 5.28.2.1, plperl kinda
works. But there's a lot of regression test failures, many of them
seemingly around error trapping.

I saw that there's also active state perl, but it seems to require clicking
through some terms and conditions for every download that I don't want to
agree to.

Greetings,

Andres Freund

[1]
Exception thrown at 0x000000006FD75DB8 (perl530.dll) in postgres.exe: 0xC0000005: Access violation reading location 0x0000000000000008.
perl530.dll!Perl_mg_get() + 56 bytes Unknown
plperl.dll!select_perl_context(bool trusted) Line 667 C
plperl.dll!plperl_inline_handler(FunctionCallInfoBaseData * fcinfo) Line 1941 C
plperl.dll!plperlu_inline_handler(FunctionCallInfoBaseData * fcinfo) Line 2064 C
postgres.exe!FunctionCall1Coll(FmgrInfo * flinfo, unsigned int collation, unsigned __int64 arg1) Line 1138 C
postgres.exe!OidFunctionCall1Coll(unsigned int functionId, unsigned int collation, unsigned __int64 arg1) Line 1417 C
postgres.exe!ExecuteDoStmt(ParseState * pstate, DoStmt * stmt, bool atomic) Line 2146 C
postgres.exe!standard_ProcessUtility(PlannedStmt * pstmt, const char * queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfoData * params, QueryEnvironment * queryEnv, _DestReceiver * dest, QueryCompletion * qc) Line 712 C
postgres.exe!ProcessUtility(PlannedStmt * pstmt, const char * queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfoData * params, QueryEnvironment * queryEnv, _DestReceiver * dest, QueryCompletion * qc) Line 530 C
postgres.exe!PortalRunUtility(PortalData * portal, PlannedStmt * pstmt, bool isTopLevel, bool setHoldSnapshot, _DestReceiver * dest, QueryCompletion * qc) Line 1157 C
postgres.exe!PortalRunMulti(PortalData * portal, bool isTopLevel, bool setHoldSnapshot, _DestReceiver * dest, _DestReceiver * altdest, QueryCompletion * qc) Line 1306 C
postgres.exe!PortalRun(PortalData * portal, long count, bool isTopLevel, bool run_once, _DestReceiver * dest, _DestReceiver * altdest, QueryCompletion * qc) Line 790 C
postgres.exe!exec_simple_query(const char * query_string) Line 1222 C
postgres.exe!PostgresMain(const char * dbname, const char * username) Line 4499 C
postgres.exe!BackendRun(Port * port) Line 4561 C
postgres.exe!SubPostmasterMain(int argc, char * * argv) Line 5066 C
postgres.exe!main(int argc, char * * argv) Line 190 C
postgres.exe!invoke_main() Line 79 C++
postgres.exe!__scrt_common_main_seh() Line 288 C++
postgres.exe!__scrt_common_main() Line 331 C++
postgres.exe!mainCRTStartup(void * __formal) Line 17 C++
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown

[2]
--- C:/Users/anfreund/src/postgres/src/pl/plperl/expected/plperl.out 2021-03-02 00:29:34.416742000 -0800
+++ C:/Users/anfreund/src/postgres/src/pl/plperl/results/plperl.out 2021-10-04 14:31:45.773612500 -0700
@@ -660,8 +660,11 @@
return $result;
$$ LANGUAGE plperl;
SELECT perl_spi_prepared_bad(4.35) as "double precision";
-ERROR: type "does_not_exist" does not exist at line 2.
-CONTEXT: PL/Perl function "perl_spi_prepared_bad"
+ double precision
+------------------
+
+(1 row)
+
-- Test with a row type
CREATE OR REPLACE FUNCTION perl_spi_prepared() RETURNS INTEGER AS $$
my $x = spi_prepare('select $1::footype AS a', 'footype');
@@ -696,37 +699,28 @@
NOTICE: This is a test
-- check that restricted operations are rejected in a plperl DO block
DO $$ system("/nonesuch"); $$ LANGUAGE plperl;
-ERROR: 'system' trapped by operation mask at line 1.
-CONTEXT: PL/Perl anonymous code block
...

--- C:/Users/anfreund/src/postgres/src/pl/plperl/expected/plperl_plperlu.out 2021-03-02 00:29:34.425742300 -0800
+++ C:/Users/anfreund/src/postgres/src/pl/plperl/results/plperl_plperlu.out 2021-10-04 14:31:48.065612400 -0700
@@ -10,11 +10,17 @@
return 1;
$$ LANGUAGE plperlu; -- compile plperlu code
SELECT * FROM bar(); -- throws exception normally (running plperl)
-ERROR: syntax error at or near "invalid" at line 4.
-CONTEXT: PL/Perl function "bar"
+ bar
+-----
+
+(1 row)
+
SELECT * FROM foo(); -- used to cause backend crash (after switching to plperlu)
-ERROR: syntax error at or near "invalid" at line 4. at line 2.
-CONTEXT: PL/Perl function "foo"
+ foo
+-----
+ 1
+(1 row)
+
-ERROR: Unable to load Errno.pm into plperl at line 2.
-BEGIN failed--compilation aborted at line 2.
+ERROR: didn't get a CODE reference from compiling function "use_plperl"
CONTEXT: compilation of PL/Perl function "use_plperl"
-- make sure our overloaded require op gets restored/set correctly
select use_plperlu();
@@ -86,6 +91,5 @@
AS $$
use Errno;
$$;
-ERROR: Unable to load Errno.pm into plperl at line 2.
-BEGIN failed--compilation aborted at line 2.
+ERROR: didn't get a CODE reference from compiling function "use_plperl"
CONTEXT: compilation of PL/Perl function "use_plperl"

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-10-04 22:02:13 Re: plperl on windows
Previous Message Jaime Casanova 2021-10-04 21:27:54 Re: Patch: Range Merge Join