> Why the rewrite doesn't reduce it? Or why parser does it?
Because ALTER DOMAIN can change what would be a valid value.
In the view case that makes sense, but I don't see how ALTER DOMAIN is relevant to my original example. You can't alter a domain between the time the query is parsed and executed, can you?
I also don't understand why prepared statements are different. The future values are not known to pass the domain check at the time the statement is prepared, and at the time it's executed, I'd think the value is known exactly to the extent that a literal (non-parameterized) value is known. That is, I'd expect the ability to run CoerceToDomain and fold to a constant to be identical in both cases -- either possible in both or impossible in both. Why the difference?