From: kouber@saparev.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6483: Rows being evaluated, although being outside the LIMIT / OFFSET boundaries
Date: Wed, 22 Feb 2012 18:53:19 +0000
Message-ID: <E1S0HJX-0004pP-9Y@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6483
Logged by: Kouber Saparev
Email address: kouber@saparev.com
PostgreSQL version: 9.1.2
Operating system: Debian
Description:
The rows of a SELECT statement are being evaluated, even when not shown in
the final result, when using an OFFSET > 0. Although I know that LIMIT is
imposed just before flushing the result set to the client, this behaviour
seems quite confusing, especially when using DML statements in the field
list of the SELECT itself.
CREATE TABLE xxx (id INT);
CREATE FUNCTION f(xxx) RETURNS VOID AS $$
BEGIN
-- imagine some DML statements here --
RAISE NOTICE '%', $1.id;
END;
$$ LANGUAGE PLPGSQL;
INSERT INTO xxx VALUES (1), (2), (3), (4), (5);
-- shows a notice for 1 and 2
SELECT x.id, f(x) FROM xxx as x LIMIT 2;
-- shows a notice for 1, 2, 3 and 4
SELECT x.id, f(x) FROM xxx as x LIMIT 2 OFFSET 2;
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: kouber@saparev.com
Subject: Re: BUG #6483: Rows being evaluated, although being outside the LIMIT / OFFSET boundaries
In-Reply-To: <E1S0HJX-0004pP-9Y@wrigleys.postgresql.org>
References: <E1S0HJX-0004pP-9Y@wrigleys.postgresql.org>
* 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