Re: BUG #19412: Wrong query result with not null constraint

Artem Fadeev <a.fadeev@postgrespro.ru>

From: Artem Fadeev <a.fadeev@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Date: 2026-02-17T12:14:40Z
Lists: pgsql-bugs
On 2/17/26 14:19, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      19412
> Logged by:          Sergey Shinderuk
> Email address:      s.shinderuk@postgrespro.ru
> PostgreSQL version: 17.8
> Operating system:   Ubuntu 24.04
> Description:

git bisect shows the bug was introduced by commit 3af7040985b [0]

I suppose presence of UNION ALL subquery is important for the reproduction
because the commit uses RangeTblEntry->inh, which has the following remark
in the comment in src/include/nodes/parsenodes.h
        * inh is true for relation references that should be expanded to 
include
        * inheritance children, if the rel has any.  In the parser, this 
will
        * only be true for RTE_RELATION entries.  The planner also uses this
        * field to mark RTE_SUBQUERY entries that contain UNION ALL 
queries that
        * it has flattened into pulled-up subqueries (creating a 
structure much
        * like the effects of inheritance).


[0] 
https://github.com/postgres/postgres/commit/3af7040985b6df504a72cd307aad5d69ac5f5384

Regards,
Artem Fadeev.
https://postgrespro.com




Commits

  1. Fix computation of varnullingrels when translating appendrel Var

  2. Fix IS [NOT] NULL qual optimization for inheritance tables