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

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

From: marko(at)kobaz(dot)net
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6511: calling spi_exec_query from non-main package,results in: couldn't fetch $_TD
Date: 2012-03-03 19:19:48
Message-ID: E1S3uUe-0005ER-RD@wrigleys.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
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:        

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();


Responses

pgsql-bugs by date

Next:From: stefano.baccianellaDate: 2012-03-04 00:47:58
Subject: BUG #6512: Bug with prepared statement and timestamp + interval
Previous:From: exclusionDate: 2012-03-03 18:44:37
Subject: BUG #6510: A simple prompt is displayed using wrong charset

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