Move FOR PORTION OF checks out of analysis

Started by Paul Jungwirthabout 1 month ago5 messageshackers
Jump to latest
#1Paul Jungwirth
pj@illuminatedcomputing.com

Starting a dedicated thread for this, based on [1]/messages/by-id/626986.1776785090@sss.pgh.pa.us. To recap:

- FOR PORTION OF needs to reject FDWs in the planner/executor, not in
analysis, first to guarantee the status hasn't changed but also
because we need to check child partitions as well.
- We need to postpone checking for volatile functions too.

The first part is done by jian he's patch from that thread (with some
test revisions).

The second part is done by the second patch here.

There is no commitfest entry yet, so I'll make one from this thread.

[1]: /messages/by-id/626986.1776785090@sss.pgh.pa.us

Yours,

--
Paul ~{:-)
pj@illuminatedcomputing.com

Attachments:

v8-0001-Reject-child-partition-FDWs-in-FOR-PORTION-OF.patchtext/x-patch; charset=US-ASCII; name=v8-0001-Reject-child-partition-FDWs-in-FOR-PORTION-OF.patchDownload+75-19
v8-0002-Move-FOR-PORTION-OF-volatile-check-into-planner.patchtext/x-patch; charset=US-ASCII; name=v8-0002-Move-FOR-PORTION-OF-volatile-check-into-planner.patchDownload+11-4
#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Paul Jungwirth (#1)
Re: Move FOR PORTION OF checks out of analysis

On 2026-May-15, Paul A Jungwirth wrote:

Starting a dedicated thread for this, based on [1]. To recap:
[...]
There is no commitfest entry yet, so I'll make one from this thread.

Please note that this doesn't need a commitfest entry -- since it's a
bug introduced during PG19, it needs to be listed as an open item
instead, to make sure we get it fixed before releasing 19. Please add
it to the list here
https://wiki.postgresql.org/wiki/Open_Items

Thanks,

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Los trabajadores menos efectivos son sistematicamente llevados al lugar
donde pueden hacer el menor daño posible: gerencia." (El principio Dilbert)

#3Paul Jungwirth
pj@illuminatedcomputing.com
In reply to: Alvaro Herrera (#2)
Re: Move FOR PORTION OF checks out of analysis

On Fri, May 15, 2026 at 3:09 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:

Please note that this doesn't need a commitfest entry -- since it's a
bug introduced during PG19, it needs to be listed as an open item
instead, to make sure we get it fixed before releasing 19. Please add
it to the list here
https://wiki.postgresql.org/wiki/Open_Items

Ah, thanks for clarifying! I went through all the items I've been
tracking and found a few missing from Open Items, so I added them.

Yours,

--
Paul ~{:-)
pj@illuminatedcomputing.com

#4jian he
jian.universality@gmail.com
In reply to: Paul Jungwirth (#1)
Re: Move FOR PORTION OF checks out of analysis

On Sat, May 16, 2026 at 5:17 AM Paul A Jungwirth
<pj@illuminatedcomputing.com> wrote:

Starting a dedicated thread for this, based on [1]. To recap:

- FOR PORTION OF needs to reject FDWs in the planner/executor, not in
analysis, first to guarantee the status hasn't changed but also
because we need to check child partitions as well.
- We need to postpone checking for volatile functions too.

The first part is done by jian he's patch from that thread (with some
test revisions).

The second part is done by the second patch here.

+ if (contain_volatile_functions(parse->forPortionOf->targetRange))
+ ereport(ERROR,
+ (errmsg("FOR PORTION OF bounds cannot contain volatile functions")))

missing errcode, we can change it to

+        if (contain_volatile_functions(parse->forPortionOf->targetRange))
+            ereport(ERROR,
+                    errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                    errmsg("FOR PORTION OF bounds cannot contain
volatile functions"));
#5Paul Jungwirth
pj@illuminatedcomputing.com
In reply to: jian he (#4)
Re: Move FOR PORTION OF checks out of analysis

On Tue, Jun 9, 2026 at 1:11 AM jian he <jian.universality@gmail.com> wrote:

missing errcode, we can change it to

+        if (contain_volatile_functions(parse->forPortionOf->targetRange))
+            ereport(ERROR,
+                    errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                    errmsg("FOR PORTION OF bounds cannot contain
volatile functions"));

Thanks for the note! Here is v9 with that change.

Yours,

--
Paul ~{:-)
pj@illuminatedcomputing.com

Attachments:

v9-0002-Move-FOR-PORTION-OF-volatile-check-into-planner.patchtext/x-patch; charset=US-ASCII; name=v9-0002-Move-FOR-PORTION-OF-volatile-check-into-planner.patchDownload+12-4
v9-0001-Reject-child-partition-FDWs-in-FOR-PORTION-OF.patchtext/x-patch; charset=US-ASCII; name=v9-0001-Reject-child-partition-FDWs-in-FOR-PORTION-OF.patchDownload+75-19