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_printtup
CONTEXT: 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 !
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match