Re: BUG #4125: Strange ALTER TABLE behavior - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4125: Strange ALTER TABLE behavior
Date
Msg-id 11331.1208964579@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4125: Strange ALTER TABLE behavior  ("Vladimir Kanazir" <vladimir@vlajko.com>)
Responses Re: BUG #4125: Strange ALTER TABLE behavior
List pgsql-bugs
"Vladimir Kanazir" <vladimir@vlajko.com> writes:
> If I execute this query:
> alter table history add incoming_id bigint default 0;

> the table will be locked until operation finishes (checked by executing the
> select query on the same table via another connection).

Indeed, because it has to physically fill the value zero into every
table row.

> But, if I do this:
> alter table history add incoming_id bigint;
> alter table history alter incoming_id set default 0;
> update history set incoming_id=0;
> the table will be locked only during alter table execution, which is very
> short time.

But this exposes the state where incoming_id isn't zero to other
transactions.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Vladimir Kanazir"
Date:
Subject: BUG #4125: Strange ALTER TABLE behavior
Next
From: "spol@mail.ru"
Date:
Subject: HELP pls