Skip site navigation (1) Skip section navigation (2)

Re: BUG #4125: Strange ALTER TABLE behavior

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vladimir Kanazir" <vladimir(at)vlajko(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4125: Strange ALTER TABLE behavior
Date: 2008-04-23 15:29:39
Message-ID: 11331.1208964579@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Vladimir Kanazir" <vladimir(at)vlajko(dot)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

In response to

Responses

pgsql-bugs by date

Next:From: Vladimir KanazirDate: 2008-04-23 15:49:37
Subject: Re: BUG #4125: Strange ALTER TABLE behavior
Previous:From: Vladimir KanazirDate: 2008-04-23 15:01:24
Subject: BUG #4125: Strange ALTER TABLE behavior

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group