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 1mGNbt-0005pj-Cy for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Aug 2021 15:36:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mGNbs-0006gC-8l for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Aug 2021 15:36:08 +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 1mGNbs-0006g4-23 for pgsql-bugs@lists.postgresql.org; Wed, 18 Aug 2021 15:36:08 +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 1mGNbn-0000Ub-1L for pgsql-bugs@lists.postgresql.org; Wed, 18 Aug 2021 15:36:07 +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 17IFa0MG1431891; Wed, 18 Aug 2021 11:36:01 -0400 From: Tom Lane To: 253540651@qq.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17152: ERROR: AddressSanitizer: SEGV on unknown address In-reply-to: <17152-c7f906cc1a88e61b@postgresql.org> References: <17152-c7f906cc1a88e61b@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 18 Aug 2021 02:56:00 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1431889.1629300960.1@sss.pgh.pa.us> Date: Wed, 18 Aug 2021 11:36:00 -0400 Message-ID: <1431890.1629300960@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: > [ unreadable example ] This can be boiled down to CREATE TEMP TABLE v0 ( v2 int ); INSERT INTO v0 VALUES (1); SELECT ( SELECT MODE ( ) WITHIN GROUP ( ORDER BY v2 ) FILTER ( WHERE MODE ( ) WITHIN GROUP ( ORDER BY v2 > 0 ) ) ) FROM v0; It seems fairly clear to me that this ought to be rejected as invalid, because we don't allow aggregates within the arguments of aggregates. That does happen without the sub-select: regression=# SELECT regression-# MODE ( ) WITHIN GROUP ( ORDER BY v2 ) regression-# FILTER ( WHERE MODE ( ) WITHIN GROUP ( ORDER BY v2 > 0 ) ) regression-# FROM v0; ERROR: aggregate functions are not allowed in FILTER LINE 3: FILTER ( WHERE MODE ( ) WITHIN GROUP ( ORDER BY v2 > 0 )... ^ So somehow the fact that outer references are involved is misleading that error check. I've not traced it further than that. regards, tom lane