Re: ALTER TABLE x ALTER COLUMN y TYPE z - Mailing list pgsql-docs

From Tom Lane
Subject Re: ALTER TABLE x ALTER COLUMN y TYPE z
Date
Msg-id 19259.1143058484@sss.pgh.pa.us
Whole thread Raw
In response to Re: ALTER TABLE x ALTER COLUMN y TYPE z  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: ALTER TABLE x ALTER COLUMN y TYPE z
List pgsql-docs
"Kevin Grittner" <Kevin.Grittner@wicourts.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

pgsql-docs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
Next
From: Robert Treat
Date:
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z