From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rodolfo Campero <rodolfo.campero@anachronics.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5872: Function call in SQL function executed only once
Date: Tue, 08 Feb 2011 17:49:06 -0500
Message-ID: <10793.1297205346@sss.pgh.pa.us> (raw)
In-Reply-To: <201102082000.p18K0cWN037750@wwwmaster.postgresql.org>
References: <201102082000.p18K0cWN037750@wwwmaster.postgresql.org>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rodolfo.campero@anachronics.com
Subject: Re: BUG #5872: Function call in SQL function executed only once
In-Reply-To: <10793.1297205346@sss.pgh.pa.us>
References: <201102082000.p18K0cWN037750@wwwmaster.postgresql.org> <10793.1297205346@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox