Re: BUG #5872: Function call in SQL function executed only once

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rodolfo Campero" <rodolfo(dot)campero(at)anachronics(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5872: Function call in SQL function executed only once
Date: 2011-02-08 22:49:06
Message-ID: 10793.1297205346@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Rodolfo Campero" <rodolfo(dot)campero(at)anachronics(dot)com> writes:
> I stumbled upon a weird behavior of postgresql, I don't know if it's a bug
> or not, but I find it counterintuitive: when then last statement of a SQL
> function is a SELECT statement with calls another function, the call is
> executed only once, regardless of the number of rows returned by the FROM
> clause.

Yeah, it stops as soon as it's got the one row needed for the function
result. You might consider marking the function as returning SETOF if
you want the final select executed to completion.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2011-02-08 22:59:45 Re: BUG #5851: ROHS (read only hot standby) needs to be restarted manually in somecases.
Previous Message mark 2011-02-08 21:36:09 Re: BUG #5851: ROHS (read only hot standby) needs to be restarted manually in somecases.