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

improper call to spi_printtup ???

From: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
To: pgsql-hackers(at)postgresql(dot)org
Subject: improper call to spi_printtup ???
Date: 2004-06-28 17:54:21
Message-ID: 200406281954.21275.darko.prenosil@finteh.hr (view raw or flat)
Thread:
Lists: 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_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 !

Responses

pgsql-hackers by date

Next:From: Mike RylanderDate: 2004-06-28 18:40:10
Subject: Quick question regarding tablespaces
Previous:From: Gavin SherryDate: 2004-06-28 17:04:12
Subject: Re: Tablespace permissions issue

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