Robert Haas <robertmhaas@gmail.com> writes:
> Right. If there were a DEFAULT on the new column that would of course
> be different, and you can also do thinks like CHECK (a != b) here.
> However, if the CHECK constraint does not reference any column other
> than the newly-added one, and if the new column will have the same
> value for every row either because there is no default or because the
> default is a constant,
... and if the CHECK expression is immutable ...
> then we can test the CHECK constraint just once
> against the value that all new rows will have instead of testing it
> once per row.
I'm not entirely sure that this case occurs often enough to be worth the
trouble. Although your formulation suggests that we could just execute
the expression once, rather than attempting to prove it true which is
what I think Jeff had in mind. That would expand the scope of usefulness
considerably.
regards, tom lane