|
1 | 1 | /********************************************************************** |
2 | 2 | * plperl.c - perl as a procedural language for PostgreSQL |
3 | 3 | * |
4 | | - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.147 2009/06/04 15:59:55 adunstan Exp $ |
| 4 | + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.148 2009/06/05 20:32:00 adunstan Exp $ |
5 | 5 | * |
6 | 6 | **********************************************************************/ |
7 | 7 |
|
@@ -401,6 +401,8 @@ plperl_init_interp(void) |
401 | 401 |
|
402 | 402 | intnargs=3; |
403 | 403 |
|
| 404 | +char*dummy_perl_env[1]= {NULL }; |
| 405 | + |
404 | 406 | #ifdefWIN32 |
405 | 407 |
|
406 | 408 | /* |
@@ -443,11 +445,19 @@ plperl_init_interp(void) |
443 | 445 | save_time=loc ?pstrdup(loc) :NULL; |
444 | 446 | #endif |
445 | 447 |
|
446 | | - |
447 | | -#ifdefPERL_SYS_INIT3 |
| 448 | +/**** |
| 449 | + * The perl API docs state that PERL_SYS_INIT3 should be called before |
| 450 | + * allocating interprters. Unfortunately, on some platforms this fails |
| 451 | + * in the Perl_do_taint() routine, which is called when the platform is |
| 452 | + * using the system's malloc() instead of perl's own. Other platforms, |
| 453 | + * notably Windows, fail if PERL_SYS_INIT3 is not called. So we call it |
| 454 | + * if it's available, unless perl is using the system malloc(), which is |
| 455 | + * true when MYMALLOC is set. |
| 456 | + */ |
| 457 | +#if defined(PERL_SYS_INIT3)&& !defined(MYMALLOC) |
448 | 458 | /* only call this the first time through, as per perlembed man page */ |
449 | 459 | if (interp_state==INTERP_NONE) |
450 | | -PERL_SYS_INIT3(&nargs, (char***)&embedding,NULL); |
| 460 | +PERL_SYS_INIT3(&nargs, (char***)&embedding,(char***)&dummy_perl_env); |
451 | 461 | #endif |
452 | 462 |
|
453 | 463 | plperl_held_interp=perl_alloc(); |
|