Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOJtC-0000MI-TO for pgsql-bugs@arkaria.postgresql.org; Wed, 08 May 2019 10:33:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hOJtA-0007Z5-2A for pgsql-bugs@arkaria.postgresql.org; Wed, 08 May 2019 10:33:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOJt9-0007XG-Pz for pgsql-bugs@lists.postgresql.org; Wed, 08 May 2019 10:33:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOJt5-0003G9-Nl for pgsql-bugs@lists.postgresql.org; Wed, 08 May 2019 10:33:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x48AXIeY018172; Wed, 8 May 2019 06:33:18 -0400 From: Tom Lane To: suresh.arsenal29@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15795: ERROR: could not find pathkey item to sort In-reply-to: <15795-fadb56c8e44ee73c@postgresql.org> References: <15795-fadb56c8e44ee73c@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 08 May 2019 06:51:32 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18170.1557311598.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 May 2019 06:33:18 -0400 Message-ID: <18171.1557311598@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > Here is query: > SELECT DISTINCT A._id0 as _id0, A._actual_type_name0 as _actual_type_n= ame0 > FROM ( ( SELECT DISTINCT _id as _id0, _actual_type_name as > _actual_type_name0, name as name0 FROM hello_world.person ) union all= ( = > SELECT DISTINCT _id as _id0, _actual_type_name as _actual_type_name0, = name > as name0 FROM hello_world.person)) as A WHERE ( A.name0 =3D A.name0 = ); It's politer to provide a self-contained test case, rather than expect us to reverse-engineer details that might be critical. For the archives, though, this isn't hard to reproduce: regression=3D# create table person(_id int, _actual_type_name text, name t= ext); CREATE TABLE regression=3D# SELECT DISTINCT A._id0 as _id0, A._actual_type_name0 as _= actual_type_name0 FROM ( ( SELECT DISTINCT _id as _id0, _actual_type_name as _actual_type_name0, name as name0 FROM person ) union all ( = SELECT DISTINCT _id as _id0, _actual_type_name as _actual_type_name0, na= me as name0 FROM person)) as A WHERE ( A.name0 =3D A.name0 ); ERROR: could not find pathkey item to sort Curiously, this only fails for me in 9.6 and 10, not earlier or later branches. regards, tom lane