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

Re: BUG #6511: calling spi_exec_query from non-main package, results in: couldn't fetch $_TD

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alex Hunsaker <badalex(at)gmail(dot)com>
Cc: marko(at)kobaz(dot)net, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6511: calling spi_exec_query from non-main package, results in: couldn't fetch $_TD
Date: 2012-03-15 22:13:51
Message-ID: 20120315221351.GB20113@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugs
On Tue, Mar 06, 2012 at 09:08:25PM -0700, Alex Hunsaker wrote:
> [ Calling a plperl trigger function from a plperl function ]
> 
> Yeah, there were some optimization done for 9.1 to try and make calls
> a bit faster. The problem is we are fetching "_TD" not "main::_TD",
> which means we try to find and use $_TD from whatever the current
> package is. This should only happen from a nested plperl to plperl
> trigger where the outer call was in a different package, otherwise the
> package is always main.
> 
> The attached fixes it for me, It would be great if you could confirm that.
> 
> Thanks for the report!

So, should this be applied?

---------------------------------------------------------------------------


> *** a/src/pl/plperl/plperl.c
> --- b/src/pl/plperl/plperl.c
> ***************
> *** 2062,2068 **** plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo,
>   	ENTER;
>   	SAVETMPS;
>   
> ! 	TDsv = get_sv("_TD", 0);
>   	if (!TDsv)
>   		elog(ERROR, "couldn't fetch $_TD");
>   
> --- 2062,2068 ----
>   	ENTER;
>   	SAVETMPS;
>   
> ! 	TDsv = get_sv("main::_TD", 0);
>   	if (!TDsv)
>   		elog(ERROR, "couldn't fetch $_TD");
>   

> 
> -- 
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs


-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2012-03-16 01:55:34
Subject: Re: BUG #6533: postgre server crashes by create function (create table as)
Previous:From: Bruce MomjianDate: 2012-03-15 22:08:50
Subject: Re: BUG #6532: pg_upgrade fails on Python stored procedures

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