David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)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