pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joe Horsnell <Joe@bambooloans.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Behaviour adding a column with and without a default (prior to PG11)
Date: Mon, 30 Sep 2019 17:19:10 -0400
Message-ID: <27688.1569878350@sss.pgh.pa.us> (raw)
In-Reply-To: <88D6C2B1-1346-45A5-AC08-37C52D75DD83@bambooloans.com>
References: <88D6C2B1-1346-45A5-AC08-37C52D75DD83@bambooloans.com>

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 default requires 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 by adding the nullable column first with no default, then changing the default, but out of curiosity; was there a specific technical 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





view thread (4+ messages)  latest in thread

Message-ID: <27688.1569878350@sss.pgh.pa.us>
Permalink:  ../27688.1569878350@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27688.1569878350@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Joe@bambooloans.com
  Subject: Re: Behaviour adding a column with and without a default (prior to PG11)
  In-Reply-To: <27688.1569878350@sss.pgh.pa.us>
  References: <88D6C2B1-1346-45A5-AC08-37C52D75DD83@bambooloans.com> <27688.1569878350@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox