Re: BUG #17152: ERROR: AddressSanitizer: SEGV on iso-8859-1 address - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17152: ERROR: AddressSanitizer: SEGV on iso-8859-1 address
Date
Msg-id 1431890.1629300960@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17152: ERROR: AddressSanitizer: SEGV on iso-8859-1 address  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17152: ERROR: AddressSanitizer: SEGV on iso-8859-1 address  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> 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



pgsql-bugs by date:

Previous
From: Petr Hybler
Date:
Subject: PGSQL bug - "Column ??? is an identity column defined as GENERATED ALWAYS.",
Next
From: Tom Lane
Date:
Subject: Re: BUG #17151: A SEGV in optimizer