Re: Doc: fix the rewrite condition when executing ALTER TABLE ADD COLUMN

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Doc: fix the rewrite condition when executing ALTER TABLE ADD COLUMN
Date: 2025-03-24 01:43:36
Message-ID: CACJufxGLcbFVS8xAC9OBPn0U_2YjKOiHLdmBrtds1j=5eA5MMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

https://git.postgresql.org/cgit/postgresql.git/commit/?id=11bd8318602fc2282a6201f714c15461dc2009c6

+ Adding a column with a volatile <literal>DEFAULT</literal>
+ (e.g., <function>clock_timestamp()</function>), a generated column
+ (e.g., <literal>GENERATED BY DEFAULT AS IDENTITY</literal>), a domain
+ data type with constraints will require the entire table and its
+ indexes to be rewritten, as will changing the type of an existing
+ column. As an exception, when changing the type of an existing column,
+ if the <literal>USING</literal> clause does not change the column
+ contents and the old type is either binary coercible to the new type
+ or an unconstrained domain over the new type, a table rewrite is not
+ needed.

In the current development branch,
virtual generated columns still do not support the domain.
you can not change the generation expression if it contains a check
constraint on it.
so virtual generated columns don't need rewriting.

IMHO, the committed doc description didn't mention this exception.
we need some text to cover this exception?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-03-24 02:21:43 RE: pg_recvlogical requires -d but not described on the documentation
Previous Message jian he 2025-03-24 01:27:30 Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints