Skip site navigation (1) Skip section navigation (2)

pgsql: Fix declaration of $_TD in "strict" trigger functions

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix declaration of $_TD in "strict" trigger functions
Date: 2011-05-19 04:08:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Fix declaration of $_TD in "strict" trigger functions

This was broken in commit ef19dc6d39dd2490ff61489da55d95d6941140bf by
the Bunce/Hunsaker/Dunstan team, which moved the declaration from
plperl_create_sub to plperl_call_perl_trigger_func.  This doesn't
actually work because the validator code would not find the variable
declared; and even if you manage to get past the validator, it still
doesn't work because get_sv("_TD", GV_ADD) doesn't have the expected
effect.  The only reason this got beyond testing is that it only fails
in strict mode.

We need to declare it as a global just like %_SHARED; it is simpler than
trying to actually do what the patch initially intended, and is said to
have the same performance benefit.

As a more serious issue, fix $_TD not being properly local()ized,
meaning nested trigger functions would clobber $_TD.

Alex Hunsaker, per test report from Greg Mullane



Modified Files
src/pl/plperl/expected/plperl_trigger.out |   29 +++++++++++++++++++++++++++++
src/pl/plperl/             |    2 +-
src/pl/plperl/plperl.c                    |    7 +++++--
src/pl/plperl/sql/plperl_trigger.sql      |   24 ++++++++++++++++++++++++
4 files changed, 59 insertions(+), 3 deletions(-)

pgsql-committers by date

Next:From: Robert HaasDate: 2011-05-19 16:12:17
Subject: pgsql: Fix race condition in CheckTargetForConflictsIn.
Previous:From: Heikki LinnakangasDate: 2011-05-19 02:50:03
Subject: pgsql: Replace strdup() with pstrdup(), to avoid leaking memory.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group