Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPcIH-0007N5-0G for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Apr 2013 17:25:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UPcIG-0007y3-EW for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Apr 2013 17:25:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPa3Q-0005EP-Ln for pgsql-bugs@postgresql.org; Tue, 09 Apr 2013 15:01:48 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPa3J-0005jx-0w for pgsql-bugs@postgresql.org; Tue, 09 Apr 2013 15:01:48 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPa3G-00038W-W7 for pgsql-bugs@postgresql.org; Tue, 09 Apr 2013 15:01:40 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UPa3B-0004K0-PJ for pgsql-bugs@postgresql.org; Tue, 09 Apr 2013 15:01:33 +0000 Date: Tue, 09 Apr 2013 15:01:33 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8049: Incorrect results when using ORDER BY and query planner options To: pgsql-bugs@postgresql.org From: th@atsc.nl X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8049 Logged by: Teun Hoogendoorn Email address: th@atsc.nl PostgreSQL version: 9.2.4 Operating system: CentOS 6.3 final 64bit Description:=20=20=20=20=20=20=20=20 Hi, I've got a strange problem with a query that produces more results than expected. I made a reproducible example to illustrate the problem. The following query should give only 1 result (instead of 2): ***************************************************************** CREATE TABLE _bug_header ( h_n integer, CONSTRAINT _bug_header_unique UNIQUE (h_n) ); CREATE TABLE _bug_line ( h_n integer, l_n integer ); INSERT INTO _bug_header VALUES(1); INSERT INTO _bug_line VALUES(NULL, 1); INSERT INTO _bug_line VALUES(NULL, 2); SET sort_mem TO 64; SET enable_seqscan TO 0; SET enable_hashjoin TO 0; SET enable_mergejoin TO 0; SET enable_sort TO 1; SET enable_indexscan TO 1; SELECT * FROM ( SELECT (COALESCE(h_n || '/', '') || l_n)::text AS fault FROM ( SELECT _bug_header.h_n, _bug_line.l_n FROM _bug_line LEFT OUTER JOIN _bug_header on (_bug_line.h_n =3D _bug_header.h_n) ) AS tmp ) AS tmp2 WHERE (lower(fault) =3D E'1')=09 ORDER BY=20 lower(fault) -- Removing the ORDER BY shows 1 (ok) record instead of 2 (wrong) OFFSET 0; ***************************************************************** Thanks, Teun Hoogendoorn --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs