aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2006-05-29 13:51:23 +0000
committerAndrew Dunstan <andrew@dunslane.net>2006-05-29 13:51:23 +0000
commit21e343da35779c622a71fd798d740c4af1d1d915 (patch)
tree2dbe7b40c807ac09015ca96b0c4e0317010f0bc5
parentb32000eda4c4193d60af1b5a5bb3c0c6dd4d7194 (diff)
downloadpostgresql-21e343da35779c622a71fd798d740c4af1d1d915.tar.gz
postgresql-21e343da35779c622a71fd798d740c4af1d1d915.zip
Make plperl's $_TD trigger data a global rather than a lexical variable,
with a fresh local value for each invocation, to avoid unexpected sharing violations. Per recent -hackers discussion.
-rw-r--r--doc/src/sgml/plperl.sgml7
-rw-r--r--src/pl/plperl/plperl.c4
2 files changed, 6 insertions, 5 deletions
diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml
index 02260d59a7c..94a375587fc 100644
--- a/doc/src/sgml/plperl.sgml
+++ b/doc/src/sgml/plperl.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.53 2006/05/26 17:34:16 adunstan Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.54 2006/05/29 13:51:23 adunstan Exp $ -->
<chapter id="plperl">
<title>PL/Perl - Perl Procedural Language</title>
@@ -660,8 +660,9 @@ $$ LANGUAGE plperl;
<para>
PL/Perl can be used to write trigger functions. In a trigger function,
the hash reference <varname>$_TD</varname> contains information about the
- current trigger event. The fields of the <varname>$_TD</varname> hash
- reference are:
+ current trigger event. <varname>$_TD</> is a global variable,
+ which gets a separate local value for each invocation of the trigger.
+ The fields of the <varname>$_TD</varname> hash reference are:
<variablelist>
<varlistentry>
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index b0ca84b1886..9b03834d408 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.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;