Re: BUG #5872: Function call in SQL function executed only once - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5872: Function call in SQL function executed only once
Date
Msg-id 10793.1297205346@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5872: Function call in SQL function executed only once  ("Rodolfo Campero" <rodolfo.campero@anachronics.com>)
List pgsql-bugs
"Rodolfo Campero" <rodolfo.campero@anachronics.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

pgsql-bugs by date:

Previous
From: "Rodolfo Campero"
Date:
Subject: BUG #5872: Function call in SQL function executed only once
Next
From: Fujii Masao
Date:
Subject: Re: BUG #5851: ROHS (read only hot standby) needs to be restarted manually in somecases.