Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvgx5-0004Fe-EF for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Jun 2021 14:00:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lvgx4-0000ey-6e for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Jun 2021 14:00:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvgx3-0000ep-WF for pgsql-bugs@lists.postgresql.org; Tue, 22 Jun 2021 14:00:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvgwx-0004Uh-S3 for pgsql-bugs@lists.postgresql.org; Tue, 22 Jun 2021 14:00:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15ME0MWh1714547; Tue, 22 Jun 2021 10:00:22 -0400 From: Tom Lane To: David Rowley cc: Thomas Munro , ganeshmmahesh@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #17068: Incorrect ordering of a particular row. In-reply-to: References: <17068-18d0626f1d26394d@postgresql.org> Comments: In-reply-to David Rowley message dated "Wed, 23 Jun 2021 01:46:16 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1714545.1624370422.1@sss.pgh.pa.us> Date: Tue, 22 Jun 2021 10:00:22 -0400 Message-ID: <1714546.1624370422@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Wed, 23 Jun 2021 at 01:26, Thomas Munro wrote: >> If you change the SELECT list to output alias3::text, there's a >> different value there: > Yeah, if I change it to ORDER BY alias3.lastname, nullnamesb.id; > instead of ORDER BY alias3.*, nullnamesb.id; then the tie break using > btint4fastcmp() is called more often. It's also getting called with > the missing 4s which I mentioned upthread. > See the two outputs. That points me towards something weird going on > in record_cmp(). I believe Munro's point is that in some rows alias3.* is a NULL composite value, while in other rows it is a composite containing one NULL, and they don't sort the same. Presumably the former are from left-join extension while the latter come from actual table rows having NULL in that column. (I'd suspected something of the kind, but being caffeine-deprived I'd first added "alias3.* IS NULL" to the query, which of course fails to expose the difference. Thanks SQL.) In short, I see no bug here. It is kind of obscure though. regards, tom lane