Re: ALTER TABLE x ALTER COLUMN y TYPE z

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-docs(at)postgresql(dot)org, "Robert Treat" <xzilla(at)users(dot)sourceforge(dot)net>
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
Date: 2006-03-22 20:14:44
Message-ID: 19259.1143058484@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> The user comment's recommended technique includes this line:
> ALTER TABLE tab DROP COLUMN temp_name;
> Would this cause a table rewrite? (Not a rhetorical question. I
> really don't know.)

No, it wouldn't. The UPDATE is the only part that modifies the table
contents.

However, the arguments Robert pointed to had to do with concurrent
access to the table, and somehow I am not seeing the use-case for ALTER
COLUMN TYPE on a table that's being actively used by other clients.
It seems unlikely that you could do that without needing to also update
your client software. I'd be a tad worried about stale-cached-plan
problems too, in current PG releases. Finally, since the first ALTER
will take an exclusive lock that won't be released until COMMIT, this
approach doesn't avoid the problem of holding exclusive lock for a long
time.

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Robert Treat 2006-03-22 21:50:20 Re: ALTER TABLE x ALTER COLUMN y TYPE z
Previous Message Kevin Grittner 2006-03-22 20:01:13 Re: ALTER TABLE x ALTER COLUMN y TYPE z