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

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Álvaro Herrera <alvherre@alvh.no-ip.org>
To: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Cc: Robert Treat <rob@xzilla.net>, pgsql-hackers@lists.postgresql.org
Date: 2025-03-14T19:49:13Z
Lists: pgsql-hackers
Hello,

I have pushed this patch now, with some tiny changes.  (I am not a
believer of the semicolon added by commit d31e2a495b6f before the word
"and").

Also, I didn't think that changing a column type was sufficiently close
to the restrictions of column addition to belong in the same
enumeration, so the first phrase is now (note the "as will" bit at the
end):

    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.


Thank you!

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"It takes less than 2 seconds to get to 78% complete; that's a good sign.
A few seconds later it's at 90%, but it seems to have stuck there.  Did
somebody make percentages logarithmic while I wasn't looking?"
                http://smylers.hates-software.com/2005/09/08/1995c749.html



Commits

  1. doc: Improve explanations when a table rewrite is needed

  2. doc: Explain more thoroughly when a table rewrite is needed

  3. Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites.