| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
| Cc: | Kirill Reshke <reshkekirill(at)gmail(dot)com>, 798604270(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19942: SIGSEGV crash (and wrong results) in MERGE ... RETURNING WITH (OLD/NEW) with VIRTUAL generated colum |
| Date: | 2026-11-27 06:10:29 |
| Message-ID: | CAHewXNmiB_nuTzbnWMBWkLX0WH52LVOgrqr0yDbGDPC13b26-A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> 于2026年11月26日周四 22:43写道:
>
> Hmm, I was thinking that actually the problem with 17550c8a was that
> it didn't properly distinguish MERGE into a trigger-updatable view
> from MERGE into a regular table (or auto-updatable view, which is the
> same by the time the planner sees it). It's only for a
> trigger-updatable view that parse->mergeTargetRelation (the expanded
> view sub-query) needs to be marked as nullable by the join. For a
> regular table (or auto-updatable view), parse->mergeTargetRelation ==
> parse->resultRelation, and its attributes are read directly, not via
> the join, so it should not be marked nullable.
>
> So I was thinking of something more like the attached v2.
Thanks for the v2 patch. I traced the rewrite through
ApplyRetrieveRule(). For a trigger-updatable view,
the action quals still reference the expanded view subquery via
mergeTargetRelation, while the target Vars in RETURNING are redirected
to resultRelation.
That explains why the same nullable_relids set works for both. I’m
happy to go with v2.
One small wording suggestion for the comment: could we change “outer
side of the join” to “nullable side of the join”? I initially read
“outer side” as referring to the outer input.
--
Tender Wang
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nitin Motiani | 2026-11-27 07:16:43 | Re: BUG #19931: postgres_fdw: FOR UPDATE over a pushed-down join ignores a pseudoconstant qual |
| Previous Message | ZizhuanLiu X-MAN | 2026-11-27 05:17:48 | Re: BUG #17545: Incorrect selectivity for IS NOT DISTINCT FROM and NULLs |