Re: Adding a stored generated column without long-lived locks

From: Alberto Piai <alberto(dot)piai(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Alberto Piai <alberto(dot)piai(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: Adding a stored generated column without long-lived locks
Date: 2026-08-24 20:03:16
Message-ID: DKXFEG915LK8.12HECZQW2OWQE@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Laurenz,

thanks for your feedback!

On Mon Aug 24, 2026 at 7:29 PM CEST, Laurenz Albe wrote:
> On Thu, 2026-08-06 at 14:36 +0200, Alberto Piai wrote:
>> PFA v7, implementing this version of the command:
>>
>> ... ALTER col ADD GENERATED USING CONSTRAINT constr_name STORED
>
> Great! I think this is pretty much good to go.
>
>> In particular, all the error messages now follow the guidelines for
>> error reporting. I tried to use a consistent error message everywhere,
>> adding details and hints where appropriate.
>
> Much better!
>
> I was wondering about this hint:
>
> Use this command on the root table/partition without ONLY.
>
> You can never turn a column of a partition into a generated column, right?
> How about
>
> Use the command on the partition root without specifying ONLY.

Since this is also taking care of classic inheritance, it seems strange
to only mention partitions. But I see that this way it's confusing (and
I do concede that partitioning might be the more widely used of the two)
so I switched it around to "on the root partition/table without
specifying ONLY". Does that make more sense?

> This detail message is longer than 80 characters:
>
> Converting a column to a stored generated column can only be done on the whole hierarchy at once.
>
> How about
>
> Converting only part of a partitioning/inheritance hierarchy is not supported.

Much better, fixed.

> There is one sentence in the documentation that sounds wrong to me:
>
> + <para>
> + After this command is run, <literal>column_name</literal> will be a stored
> + generated column with <literal>expr</literal> as its generation
> + expression.
> + </para>
>
> Shouldn't it be "after this command has been run"? Or perhaps "has completed"?

Thanks, changed to "has completed".

The attached v8 addresses the points above.

Kind regards,

Alberto

--
Alberto Piai
Sensational AG
Zürich, Switzerland

Attachment Content-Type Size
v8-0001-Support-changing-a-column-into-a-stored-generated.patch text/plain 71.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2026-08-24 20:03:56 Re: Randomize B-Tree page split location to avoid oscillating patterns
Previous Message Kevin Rocker 2026-08-24 20:00:57 Re: [PATCH] Fix vacuum_delay_point happening inside lock