Re: Segmentation fault in var_is_nonnullable when running query with COUNT() on 42473b3b

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: "Birler, Altan" <altan.birler@tum.de>
Cc: "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2025-11-29T19:43:46Z
Lists: pgsql-bugs

Attachments

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