From: Tom Lane <tgl@sss.pgh.pa.us>
To: digoal@126.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14059: BUG? function in select clause called more times when use offset
Date: Sat, 02 Apr 2016 10:49:26 -0400
Message-ID: <31248.1459608566@sss.pgh.pa.us> (raw)
In-Reply-To: <20160402114003.4804.46227@wrigleys.postgresql.org>
References: <20160402114003.4804.46227@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
digoal@126.com writes:
> postgres=# create or replace function f() returns void as $$
> declare
> begin
> raise notice 'called';
> end;
> $$ language plpgsql strict volatile;
> CREATE FUNCTION
> postgres=# select f(),* from ( values(1),(2),(3),(4),(5),(6) ) t(id) offset
> 3 limit 2;
> NOTICE: called
> NOTICE: called
> NOTICE: called
> NOTICE: called
> NOTICE: called
> f | id
> ---+----
> | 4
> | 5
> (2 rows)
> offset skip 3 tuple, but function f() called with 5 times, can we tuning
> this .
> or this is a bug?
No, it's not a bug. OFFSET only results in the skipped tuples not being
delivered to the client; it does not cause them not to be computed.
You could probably do something with a two-level select with the OFFSET
in the sub-select and the volatile function in the top level.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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, digoal@126.com
Subject: Re: BUG #14059: BUG? function in select clause called more times when use offset
In-Reply-To: <31248.1459608566@sss.pgh.pa.us>
References: <20160402114003.4804.46227@wrigleys.postgresql.org> <31248.1459608566@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