Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A42493405CD for ; Wed, 22 Feb 2012 14:53:37 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0HJl-0002Cr-5O for pgsql-bugs@postgresql.org; Wed, 22 Feb 2012 18:53:36 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0HJX-0002hs-Jm for pgsql-bugs@postgresql.org; Wed, 22 Feb 2012 18:53:20 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1S0HJX-0004pP-9Y for pgsql-bugs@postgresql.org; Wed, 22 Feb 2012 18:53:19 +0000 Date: Wed, 22 Feb 2012 18:53:19 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6483: Rows being evaluated, although being outside the LIMIT / OFFSET boundaries To: pgsql-bugs@postgresql.org From: kouber@saparev.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/166 X-Sequence-Number: 32509 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;