postgres.git / summary / log / commit / refs
commit abf4b00a8783d44c96f457922c311153f2bb7468
Author: Andrew Dunstan <andrew@dunslane.net>
Date: Fri Jun 05 20:32:15 2009 +0000
First released in: 8.4.0, 7.4.26, 8.0.22, 8.1.18, 8.2.14, 8.3.8
Adjust recent PERL_SYS_INIT3 call to avoid platforms where it might fail, and to remove compilation warning. Backpatch the release 7.4
src/pl/plperl/plperl.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 20cfb51a8b7..50eee09ef13 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.136.2.1 2009/06/04 16:00:11 adunstan Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.136.2.2 2009/06/05 20:32:15 adunstan Exp $
*
**********************************************************************/
@@ -388,6 +388,8 @@ plperl_init_interp(void)
int nargs = 3;
+ char *dummy_perl_env[1] = { NULL };
+
#ifdef WIN32
/*
@@ -430,11 +432,19 @@ plperl_init_interp(void)
save_time = loc ? pstrdup(loc) : NULL;
#endif
-
-#ifdef PERL_SYS_INIT3
+ /****
+ * The perl API docs state that PERL_SYS_INIT3 should be called before
+ * allocating interprters. Unfortunately, on some platforms this fails
+ * in the Perl_do_taint() routine, which is called when the platform is
+ * using the system's malloc() instead of perl's own. Other platforms,
+ * notably Windows, fail if PERL_SYS_INIT3 is not called. So we call it
+ * if it's available, unless perl is using the system malloc(), which is
+ * true when MYMALLOC is set.
+ */
+#if defined(PERL_SYS_INIT3) && !defined(MYMALLOC)
/* only call this the first time through, as per perlembed man page */
if (interp_state == INTERP_NONE)
- PERL_SYS_INIT3(&nargs, (char ***) &embedding, NULL);
+ PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char***)&dummy_perl_env);
#endif
plperl_held_interp = perl_alloc();
[parent: b2ec4f2ad6e8]