| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | idrissaajalloh(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result |
| Date: | 2026-11-11 05:16:59 |
| Message-ID: | CAHewXNn4w+u2zY1LW_tgQ+6AydmuNDAg7xhxXSZYj-xrgq53-Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Tender Wang <tndrwang(at)gmail(dot)com> 于2026年11月11日周三 10:23写道:
>
> Hi,
>
> PG Bug reporting form <noreply(at)postgresql(dot)org> 于2026年11月11日周三 09:54写道:
> >
> > This occurs when self-join elimination is enabled for a primary-key
> > self-join with alias-specific calls to the same VOLATILE predicate.
> >
>
> After one relation is removed, SJE rewrites its Vars to reference the
> remaining relation.
> In this case, that turns
>
> is_odd_call(a.id)
> is_odd_call(b.id)
>
> into two structurally identical expressions referencing the same relation.
> fixup_selfjoin_quals() then treats the second expression as a
> duplicate and removes it.
> That is not valid for volatile expressions, since the two occurrences
> represent separately observable evaluations.
>
> The attached patch conservatively disables SJE when the query jointree
> contains volatile functions.
>
Checking in remove_useless_self_joins() seems too strict; it can skip
some self joins that have no volatile functions in quals.
I moved the check into remove_self_joins_one_group() as attached v2.
--
Thanks,
Tender Wang
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Skip-SJE-if-jointree-containing-VOLATILE-function.patch | text/plain | 3.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-11-11 05:25:46 | BUG #19863: Adding a partition hides a row in a DEFAULT subpartition with reordered columns |
| Previous Message | Manu | 2026-11-11 05:09:59 | Re: BUG #19602: Vuln46: citext split_part silently returns NULL for a zero field position instead of raising core sp |