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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: s(dot)shinderuk(at)postgrespro(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #19412: Wrong query result with not null constraint
Date: 2026-02-17 22:53:50
Message-ID: CAApHDvpXarz-D6tP-7y4ZrtnhXtdbRY0kQxRDQTVc3Z9DckYVw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 18 Feb 2026 at 00:31, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> create table a (id int, x_id int, y_id int);
> insert into a values (1, 1, 1), (1, 2, 2), (1, 3, 3);
> create table x (id int, nm text, constraint pk_x_id primary key (id));
> insert into x values (1, 'x1'), (2, 'x2'), (3, 'x3');
> create table y (id int, nm text, constraint pk_y_id primary key (id));
> insert into y values (1, 'y1'), (3, 'y3'), (4, 'y4');
>
> select a.id, z.id
> from a
> join x on x.id = a.x_id
> left join y on y.id = a.y_id
> join lateral(select x.id
> union all
> select y.id) z on z.id is not null;

Thanks for the reproducer.

I'd say that y.id Var in the lateral join should be getting marked as
nullable by the left join, but it's not being marked as nullable by
anything.

Tom, do you have any thoughts on the empty varnullingrels here?

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Matt Carter 2026-02-17 23:12:15 RE: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed
Previous Message Tom Lane 2026-02-17 21:55:04 Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.