| From: | "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
|---|---|
| To: | "Nitin Motiani" <nitinmotiani(at)google(dot)com>, <tharakan(at)gmail(dot)com>, <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
| Cc: | <etsuro(dot)fujita(at)gmail(dot)com>, "Richard Guo" <guofenglinux(at)gmail(dot)com> |
| Subject: | Re: BUG #19931: postgres_fdw: FOR UPDATE over a pushed-down join ignores a pseudoconstant qual |
| Date: | 2026-11-24 16:33:07 |
| Message-ID: | DN3L3G6M8UFK.2G7DONFHXEYT2@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Mon Nov 23, 2026 at 8:40 AM -03, Nitin Motiani wrote:
> On Mon, Nov 23, 2026 at 2:10 PM PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
>>
>> It returns the wrong rows on master (9b5d4e33317) through REL_17_STABLE.
>> REL_16_STABLE and older return no rows: 6f80a8d9c13, back-patched to
>> them, stopped FDWs from replacing a join that has pseudoconstant quals,
>> and 9e9931d2bf4, on master only, allowed it again.
>>
>
> Thanks for the report. I was able to reproduce this bug. The fix seems
> small so I'm attaching a patch. It fixes this issue by passing
> fdw_restrictinfo of the join path to the final path which can then use
> it to gate on the clauses like now() is null.
>
> Please take a look.
>
Thanks for the patch!
I've reviewed and tested it, and I think it's the right fix. Since
9e9931d2bf4, create_scan_plan() gets the gating quals for a join rel
from fdw_restrictinfo. The final path keeps the join rel as its parent,
so it has to carry that list too.
I tested a few variants on top of the reported query: FOR UPDATE with an
ORDER BY that's pushed down, a 3-way join, and FOR SHARE OF. All of them
returned wrong rows on master and are correct with the fix, so the patch
looks good to me. It also applies cleanly on REL_17_STABLE and
REL_18_STABLE.
A small comment: I think that the changes on add_foreign_final_paths()
can be simplified into:
+ ForeignPath *fpath;
+
+ if (IsA(path, ProjectionPath))
+ fpath = (ForeignPath *) ((ProjectionPath *) path)->subpath;
+ else
+ fpath = (ForeignPath *) path;
And then use fpath->fdw_restrictinfo on create_foreign_upper_path().
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-11-24 17:24:31 | Re: BUG #19911: Window aggregate over ROWS n FOLLOWING: "unexpected end of tuplestore" after spill |
| Previous Message | Pavan | 2026-11-24 15:52:12 | Re: BUG #19919: Internal Invalidation Error During Savepoint DDL After Dropping a Domain Constraint |