Re: FOR PORTION OF should reject GENERATED columns - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: FOR PORTION OF should reject GENERATED columns
Date
Msg-id cfacd312-f740-4b6a-ac8b-ce8e5c8a58d9@eisentraut.org
Whole thread
In response to Re: FOR PORTION OF should reject GENERATED columns  (Paul A Jungwirth <pj@illuminatedcomputing.com>)
Responses Re: FOR PORTION OF should reject GENERATED columns
List pgsql-hackers
On 11.06.26 22:57, Paul A Jungwirth wrote:
> On Fri, May 15, 2026 at 2:04 PM 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;
>> 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
> 
> This needed a rebase; attached.
> 
> Also I noticed it had some extra tests from the work to move FDW
> checks out of parse analysis. I've removed that from here and I'll
> make sure we have it in the right patch.

I don't understand why this proposed check is being done in the 
executor.  It seems to me that it should be done in the parser, in 
transformForPortionOfClause(), where you check other properties of the 
for-portion-of target column.  It is not possible to turn a normal 
column into a generated column, so once we have checked that the column 
exists and has the right type and is not generated, I don't think there 
is then any risk that that check becomes invalidated between parsing and 
execution.




pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Small patch to improve safety of utf8_to_unicode().
Next
From: Jakub Wartak
Date:
Subject: Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT