Make plperl's $_TD trigger data a global rather than a lexical variable,
authorAndrew Dunstan
Mon, 29 May 2006 13:51:23 +0000 (13:51 +0000)
committerAndrew Dunstan
Mon, 29 May 2006 13:51:23 +0000 (13:51 +0000)
with a fresh local value for each invocation, to avoid unexpected sharing
violations. Per recent -hackers discussion.

doc/src/sgml/plperl.sgml
src/pl/plperl/plperl.c

index 02260d59a7c49b7bbdc89cd6df1924c6ec5c956c..94a375587fc6f6d020ed500d93fa2845077f1e37 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   PL/Perl - Perl Procedural Language
@@ -660,8 +660,9 @@ $$ LANGUAGE plperl;
   
    PL/Perl can be used to write trigger functions.  In a trigger function,
    the hash reference $_TD contains information about the
-   current trigger event.  The fields of the $_TD hash
-   reference are:
+   current trigger event. $_TD is a global variable, 
+   which gets a separate local value for each invocation of the trigger. 
+   The fields of the $_TD hash reference are:
 
    
     
index b0ca84b1886b16605c7f22ae9f3e5f6844ef791e..9b03834d408ee1a1f3f06eb4036e8993d1e521f7 100644 (file)
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plperl.c - perl as a procedural language for PostgreSQL
  *
- *   $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.109 2006/05/26 17:34:16 adunstan Exp $
+ *   $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.110 2006/05/29 13:51:23 adunstan Exp $
  *
  **********************************************************************/
 
@@ -771,7 +771,7 @@ plperl_create_sub(char *s, bool trusted)
    ENTER;
    SAVETMPS;
    PUSHMARK(SP);
-   XPUSHs(sv_2mortal(newSVpv("my $_TD=$_[0]; shift;", 0)));
+   XPUSHs(sv_2mortal(newSVpv("our $_TD; local $_TD=$_[0]; shift;", 0)));
    XPUSHs(sv_2mortal(newSVpv(s, 0)));
    PUTBACK;