From: marko@kobaz.net
To: pgsql-bugs@postgresql.org
Subject: BUG #6511: calling spi_exec_query from non-main package, results in: couldn't fetch $_TD
Date: Sat, 03 Mar 2012 19:19:48 +0000
Message-ID: <E1S3uUe-0005ER-RD@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6511
Logged by: Mark Murawski
Email address: marko@kobaz.net
PostgreSQL version: 9.1.3
Operating system: Linux - Debian Squeeze postgres 9.1 from backports
Description:
create table mytable ( id integer );
--
CREATE OR REPLACE FUNCTION mytrigger() RETURNS trigger AS $BODY$
return undef
$BODY$ LANGUAGE plperlu VOLATILE COST 100;
--
CREATE TRIGGER "insert" BEFORE INSERT ON mytable FOR EACH ROW EXECUTE
PROCEDURE mytrigger();
--
CREATE OR REPLACE FUNCTION myfunc() RETURNS text AS $BODY$
package foo;
sub foo {
main::spi_exec_query(q{INSERT INTO mytable VALUES (1) RETURNING id});
};
package main;
foo::foo();
return;
$BODY$ LANGUAGE plperlu VOLATILE COST 100;
--
pbx=# select * from myfunc();
ERROR: couldn't fetch $_TD at line 4.
CONTEXT: PL/Perl function "myfunc"
-- this works:
CREATE OR REPLACE FUNCTION myfunc() RETURNS text AS $BODY$
package foo;
sub foo {
package main;
spi_exec_query(q{INSERT INTO mytable VALUES (1) RETURNING id});
};
package main;
foo::foo();
return;
$BODY$ LANGUAGE plperlu VOLATILE COST 100;
select * from myfunc();
myfunc
--------
(1 row)
drop table mytable;
drop function mytrigger();
drop function myfunc();
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: marko@kobaz.net
Subject: Re: BUG #6511: calling spi_exec_query from non-main package, results in: couldn't fetch $_TD
In-Reply-To: <E1S3uUe-0005ER-RD@wrigleys.postgresql.org>
References: <E1S3uUe-0005ER-RD@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox