Re: ALTER TEXT field to VARCHAR(1024) - Mailing list pgsql-general

From Tom Lane
Subject Re: ALTER TEXT field to VARCHAR(1024)
Date
Msg-id 17116.1411406545@sss.pgh.pa.us
Whole thread Raw
In response to Re: ALTER TEXT field to VARCHAR(1024)  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-general
David G Johnston <david.g.johnston@gmail.com> writes:
> In the end the two questions are:
> 1) does adding a length restriction cause a table rewrite?

Yes.  In principle the restriction could be checked with just a scan,
not a rewrite, but ALTER TABLE doesn't currently understand that --- and
in any case a scan would still be potentially a long time.

> 2) what level of locking occurs while the length check is resolving?

AccessExclusiveLock.  This would be necessary in any case for a data type
change.

            regards, tom lane


pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: ALTER TEXT field to VARCHAR(1024)
Next
From: Luke Coldiron
Date:
Subject: large table