improper call to spi_printtup ??? - Mailing list pgsql-hackers

From Darko Prenosil
Subject improper call to spi_printtup ???
Date
Msg-id 200406281954.21275.darko.prenosil@finteh.hr
Whole thread Raw
Responses Re: improper call to spi_printtup ???
List pgsql-hackers
I have set returning function written in 'c', declared as:

CREATE OR REPLACE FUNCTION check_view (text,text) RETURNS setof pg_attribute AS
'/usr/local/pgsql/lib/libplpq.so','check_view'LANGUAGE 'c' WITH (isstrict);
 

When I call this function from psql :SELECT attrelid,attnum FROM check_view('pg_catalog','pg_tables') ;
I have: attrelid | attnum----------+--------    16595 |      1     1259 |      1        0 |      0     1259 |     11
1259 |     22        0 |      0
 
That is expected result, or in other words it works fine.

Now when I try to use 'check_view0 function in some other pl/psql function:
CREATE OR REPLACE FUNCTION testfunc() RETURNS bool AS 'BEGIN    SELECT attrelid,attnum FROM
check_view(''pg_catalog'',''pg_tables'');    RETURN FALSE;END;' LANGUAGE 'plpgsql';
 
SELECT testfunc() ;

I have:(-403)ERROR:  improper call to spi_printtupCONTEXT:  PL/pgSQL function "testfunc" line 2 at SQL statement

Anyone knows what I'm doing wrong ? Is there some special issue when writing 
functions for pl/psql that I'm not aware ?

Thanks in advance !


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: Tablespace permissions issue
Next
From: Robert Treat
Date:
Subject: Re: lock timeout patch