Re: FOR PORTION OF should reject GENERATED columns

Paul A Jungwirth <pj@illuminatedcomputing.com>

From: Paul A Jungwirth <pj@illuminatedcomputing.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-15T21:04:21Z
Lists: pgsql-hackers

Attachments

On Wed, May 13, 2026 at 8:39 AM Paul A Jungwirth
<pj@illuminatedcomputing.com> wrote:
>
> On Tue, May 12, 2026 at 1:34 PM Nathan Bossart
> <nathandbossart(at)gmail(dot)com> wrote:
> >
> > FOR PORTION OF doesn't seem to work well with virtual generated columns,
> > either. The following example seg-faults on my machine:
> >
> > create table t (a int, b int4range generated always as (int4range(a, a + 1)) virtual);
> > insert into t values (1);
> > delete from t for portion of b from 1 to 2;
>
> I posted a fix for this yesterday, but I wanted to make a separate
> thread so the commitfest app could track it correctly. Here is the
> start of the conversation:
>
> https://www.postgresql.org/message-id/CA%2BrenyWqeWxSUoohRQ4htfSLCcDVsZ%3DXwVR7F8-e9GXeH_O13w%40mail.gmail.com

My first fix was doing this check in the analysis phase because I
thought it would be hard to separate from moving other validations
into the planner/executor[1], but doing it as a stand-alone patch was
easier than I thought. Here is v2.

[1] https://www.postgresql.org/message-id/626986.1776785090@sss.pgh.pa.us

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