Re: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b - Mailing list pgsql-bugs

From David Rowley
Subject Re: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b
Date
Msg-id CAApHDvqWH9Dm-ezcwFOax6qyqqS9T_EsDa96Do8Fj-1zdXJRhw@mail.gmail.com
Whole thread Raw
In response to Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b  ("Birler, Altan" <altan.birler@tum.de>)
Responses Re: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b
List pgsql-bugs
On Sun, 30 Nov 2025 at 02:17, Birler, Altan <altan.birler@tum.de> wrote:
> PostgreSQL stand-alone backend 19devel
> backend> Segmentation fault (core dumped)
> ```
>
> I have tried to minimize the query and I still get an error with the following smaller query:
> ```
> SELECT 1 FROM (VALUES (NULL),(NULL)) AS t(key) GROUP BY key HAVING COUNT(key) = ANY (ARRAY[2]);
> ```

Thanks for the detailed report.

Looks like I didn't take into account the fact that context->root can
be NULL in some cases. In this case, when called via
estimate_expression_value().

I believe the attached is the correct fix.

David

Attachment

pgsql-bugs by date:

Previous
From: "Birler, Altan"
Date:
Subject: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b
Next
From: David Rowley
Date:
Subject: Re: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b