Re: strange bug in plperl

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
Cc: pgsql-hackers(at)postgresql(dot)org, plperlng-devel(at)pgfoundry(dot)org
Subject: Re: strange bug in plperl
Date: 2004-07-05 15:37:04
Message-ID: 40E975A0.30302@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


OK, thanks. I see where the problem is. We'll fix the SRF code.

cheers

andrew

Darko Prenosil wrote:

>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 majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2004-07-05 16:13:57 Re: [Re] Re: PREPARE and transactions
Previous Message Darko Prenosil 2004-07-05 14:30:27 Re: strange bug in plperl