From 21e343da35779c622a71fd798d740c4af1d1d915 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 29 May 2006 13:51:23 +0000 Subject: [PATCH] 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. --- doc/src/sgml/plperl.sgml | 7 ++++--- src/pl/plperl/plperl.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml index 02260d59a7..94a375587f 100644 --- a/doc/src/sgml/plperl.sgml +++ b/doc/src/sgml/plperl.sgml @@ -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: diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index b0ca84b188..9b03834d40 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; -- 2.40.0