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: Alex Hunsaker <badalex(at)gmail(dot)com>
To: marko(at)kobaz(dot)net
Cc: 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-07 04:08:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Sat, Mar 3, 2012 at 12:19,  <marko(at)kobaz(dot)net> wrote:
> The following bug has been logged on the website:
> Bug reference:      6511
> Logged by:          Mark Murawski
> Email address:      marko(at)kobaz(dot)net
> PostgreSQL version: 9.1.3
> Operating system:   Linux - Debian Squeeze postgres 9.1 from backports
> Description:
> package foo;
> sub foo {
>  main::spi_exec_query(q{INSERT INTO mytable VALUES (1) RETURNING id});
> };
> package main;
> foo::foo();
> return;
> --
> pbx=# select * from myfunc();
> ERROR:  couldn't fetch $_TD at line 4.
> CONTEXT:  PL/Perl function "myfunc"

[ 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!

Attachment: plperl_nested_pkg_trigger.patch
Description: text/x-patch (418 bytes)

In response to


pgsql-bugs by date

Next:From: Phil SorberDate: 2012-03-07 06:49:35
Subject: Re: Extension tracking temp table and causing update failure
Previous:From: Tom LaneDate: 2012-03-07 00:49:28
Subject: Re: BUG #6480: NLS text width problem

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