Skip to content

Commit 21e343d

Browse files
committed
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.
1 parent b32000e commit 21e343d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/src/sgml/plperl.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.53 2006/05/26 17:34:16 adunstan Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.54 2006/05/29 13:51:23 adunstan Exp $ -->
22

33
<chapter id="plperl">
44
<title>PL/Perl - Perl Procedural Language</title>
@@ -660,8 +660,9 @@ $$ LANGUAGE plperl;
660660
<para>
661661
PL/Perl can be used to write trigger functions. In a trigger function,
662662
the hash reference <varname>$_TD</varname> contains information about the
663-
current trigger event. The fields of the <varname>$_TD</varname> hash
664-
reference are:
663+
current trigger event. <varname>$_TD</> is a global variable,
664+
which gets a separate local value for each invocation of the trigger.
665+
The fields of the <varname>$_TD</varname> hash reference are:
665666

666667
<variablelist>
667668
<varlistentry>

src/pl/plperl/plperl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.109 2006/05/26 17:34:16 adunstan Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.110 2006/05/29 13:51:23 adunstan Exp $
55
*
66
**********************************************************************/
77

@@ -771,7 +771,7 @@ plperl_create_sub(char *s, bool trusted)
771771
ENTER;
772772
SAVETMPS;
773773
PUSHMARK(SP);
774-
XPUSHs(sv_2mortal(newSVpv("my $_TD=$_[0]; shift;", 0)));
774+
XPUSHs(sv_2mortal(newSVpv("our $_TD; local $_TD=$_[0]; shift;", 0)));
775775
XPUSHs(sv_2mortal(newSVpv(s, 0)));
776776
PUTBACK;
777777

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy