Because that is exactly count of "tstset" function being called. Set returning functions are called recursively until SRF_RETURN_DONE is returned, and that in You case means until last row is fetched.
When You programming functions in "C", there is SRF_ISFIRST_CALL function that returns "true" if function is called for the first time, so You can write something like this: if (SRF_ISFIRST_CALL()) { //Code that executes only once } else { //Code that executes per row } I do not know how this works with plperl, and this could be a bug, because only "return [{i=>1,v=>"one"},{i=>2,v=>"two"}];" should be executed more than once (that is the way it is working in pl/psql). I'm sorry I can't help more, but do not know much about plperl :-( Hope some plperl guru will know more... Regards ! On Monday 05 July 2004 15:33, Andrew Dunstan wrote: > Can anyone suggest why I might be seeing this effect (each notice comes > out once per row plus once per function call) > > thanks > > andrew > > andrew=# create function tstset() returns setof tst language plperl as $$ > andrew$# elog(NOTICE,"tstset called"); > andrew$# return [{i=>1,v=>"one"},{i=>2,v=>"two"}]; > andrew$# $$; > CREATE FUNCTION > andrew=# select * from tstset(); > NOTICE: tstset called > NOTICE: tstset called > NOTICE: tstset called > i | v > ---+----- > 1 | one > 2 | two > (2 rows) > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly