On Tue, 6 Oct 2026 at 04:28, shihao zhong <[email protected]> wrote:
>
> 2. With a join as the MERGE source, only Vars of the join RTE are
> marked nullable for NOT MATCHED BY SOURCE, not Vars of the tables
> under it.
>   create table mt (id int);
>   create table sa (id int not null);
>   create table sb (id int);
>   insert into mt values (1);
>   merge into mt using (sa join sb on sa.id = sb.id) on mt.id = sa.id
>     when not matched by source then delete
>     returning sa.id is null;
> 18 returns t, 19 returns f. 0002 marks them all.
>
> The marking comes from 259a0a99fe3, the fix for bug #18634, which is
> also in 17 and 18. It covers a source that is one table, but not a
> join. On 18 that does not give wrong values, but planning can fail
> with "wrong varnullingrels", the error from that bug. So I think 0002
> should be back-patched to 17.

Thanks for the report. Your analysis and fix look correct.

I've pushed and back-patched the patch, with some cosmetic
adjustments, and I expanded the tests to cover both cases (wrong
results and "wrong varnullingrels" error).

Regards,
Dean


Reply via email to