Re: Behaviour adding a column with and without a default (prior to PG11) - Mailing list pgsql-general

From Tom Lane
Subject Re: Behaviour adding a column with and without a default (prior to PG11)
Date
Msg-id 27688.1569878350@sss.pgh.pa.us
Whole thread Raw
In response to Behaviour adding a column with and without a default (prior to PG11)  (Joe Horsnell <Joe@bambooloans.com>)
Responses Re: Behaviour adding a column with and without a default (prior toPG11)  (Joe Horsnell <Joe@bambooloans.com>)
Re: Behaviour adding a column with and without a default (prior toPG11)  (Joe Horsnell <Joe@bambooloans.com>)
List pgsql-general
Joe Horsnell <Joe@bambooloans.com> writes:
> The documentation (https://www.postgresql.org/docs/10/ddl-alter.html) clearly states that adding a column with a
defaultrequires updating all the rows in the table, to store the new column value (this is prior to PG11, obviously). 

> Obviously the desired effect of adding the column default without rewriting all the rows in the table can be achieved
byadding the nullable column first with no default, then changing the default, but out of curiosity; was there a
specifictechnical reason for the behaviour described above, or was it a conscious design choice? 

We read the SQL spec as requiring this behavior.

            regards, tom lane



pgsql-general by date:

Previous
From: Gerrit Fouche
Date:
Subject: Re: pg_upgrade (Checking for reg* data types)
Next
From: Joe Horsnell
Date:
Subject: Re: Behaviour adding a column with and without a default (prior toPG11)