| From: | Matheus Alcantara <matheusssilv97(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint |
| Date: | 2026-01-16 16:07:25 |
| Message-ID: | bbdc8dfd-3f23-46bb-ab23-255b9e6c06ee@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 16/01/26 08:31, jian he wrote:
> On Thu, Jan 15, 2026 at 11:29 PM Matheus Alcantara
> <matheusssilv97(at)gmail(dot)com> wrote:
>>
>> + /*
>> + * Find everything that depends on the column (constraints, indexes, etc),
>> + * and record enough information to let us recreate the objects after
>> + * rewrite.
>> + */
>> + RememberAllDependentForRebuilding(tab, AT_SetExpression, rel, attnum, colName);
>> +
>> Perhaps this comments should be updated since we are now collecting
>> these dependencies for virtual generated columns too that it not require
>> a table rewrite.
>>
>> ---
>
> I guess we can change it as:
>
> /*
> * Find everything that depends on the column (constraints, indexes, etc),
> * and record enough information to let us recreate the objects.
> */
> RememberAllDependentForRebuilding(tab, AT_SetExpression, rel,
> attnum, colName);
>
It looks good.
>>
>> I think that it would be good to update the SET EXPRESSION AS
>> documentation on doc/src/sgml/ref/alter_table.sgml to mention that for
>> virtual columns the table is not rewritten but a full table scan may
>> still be needed if the column has check constraints.
>>
>
> In doc/src/sgml/ref/alter_table.sgml, I intended to change it as follows:
>
> <varlistentry id="sql-altertable-desc-set-expression">
> <term><literal>SET EXPRESSION AS</literal></term>
> <listitem>
> <para>
> This form replaces the expression of a generated column. Existing data
> in a stored generated column is rewritten and all the future changes
> will apply the new generation expression.
> + Virtual generated columns do not require a table rewrite.
> + However if the column is part of a <literal>CHECK</literal> constraint
> + expression, the constraint will be rebuilt, requiring a table scan to
> + ensure that existing rows meet the constraint.
> </para>
Sounds good.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-01-16 16:14:54 | Re: [PATCH] pl: fix can not build free-thread for plpython extension like 3.14t |
| Previous Message | Fujii Masao | 2026-01-16 15:51:49 | Re: [PATCH] remove incorrect comment in pg_resetwal.c |