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 1pDXBl-0008C1-Qe for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Jan 2023 20:50:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pDXBk-0005D2-Kj for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Jan 2023 20:50:12 +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 1pDXBk-00058M-C9 for pgsql-bugs@lists.postgresql.org; Thu, 05 Jan 2023 20:50:12 +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 1pDXBh-0000is-RT for pgsql-bugs@lists.postgresql.org; Thu, 05 Jan 2023 20:50:11 +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 305Ko38Y2811898; Thu, 5 Jan 2023 15:50:05 -0500 From: Tom Lane To: xinwen@stu.scu.edu.cn cc: Andres Freund , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17737: An assert failed in execExprInterp.c In-reply-to: <17737-55a063e3e6c41b4f@postgresql.org> References: <17737-55a063e3e6c41b4f@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 05 Jan 2023 16:53:35 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2811896.1672951803.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 05 Jan 2023 15:50:03 -0500 Message-ID: <2811897.1672951803@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When executing the following query: > CREATE TABLE table0 ( column1 INT ) ; > INSERT INTO table0 VALUES ( 1 ), ( 1 ) ; > WITH RECURSIVE table3 ( column0 ) AS ( SELECT column1 FROM table0 UNION > SELECT column0 FROM table3 WHERE column0 < 1 ) SELECT 1 FROM table3 LEFT > JOIN table0 ON TRUE ; > I get a failed assertion with the following stacktrace: Yeah. The problem is that LookupTupleHashEntry is being handed a BufferHeapTuple slot, evidently direct from the scan of table0, but BuildTupleHashTableExt previously set up the comparison expression on the assumption that the input would be a MinimalTuple slot: /* build comparator for all columns */ /* XXX: should we support non-minimal tuples for the inputslot? */ hashtable->tab_eq_func =3D ExecBuildGroupingEqual(inputDesc, inputDesc= , &TTSOpsMinimalTuple, &= TTSOpsMinimalTuple, ... AFAICT this has been wrong since we introduced multiple slot types (I bisected it back to 15d8f8312, but of course that's just the messenger). I'm kind of baffled as to how it's escaped detection for this long; maybe the assertion is overly tight, and the case actually works in non-assert builds? If so I'd be inclined to just weaken CheckOpSlotCompatibility some more. Otherwise, we need to either improve execGrouping.c to cope with different input slot types, or fix nodeRecursiveunion.c to force the supplied slot to be a minimal one. That last option seems pretty hacky, and it may fail to cover some other case. regards, tom lane