Andres Freund <and...@anarazel.de> writes: > On 2018-12-05 13:22:23 -0500, Tom Lane wrote: >> Not following what you have in mind here? My 0002 throws away the >> CoerceToDomain if there are *no* constraints, but I can't see any >> situation in which we'd likely be able to ignore a constraint, >> simple or not.
> Yea, simple probably means nonexistant for now. We could e.g. optimize > some NOT NULL checks away, but it's probably not worth it. Ah, yes, that is a case where we might have enough knowledge to prove the test redundant --- but considering that we explicitly discourage domain NOT NULL as bad style and not fully supported, I can't get excited about it. I suppose in some cases we might be able to use predtest.c to prove domain CHECK constraints redundant, but I bet that it's not worth the trouble. The bigger picture here is that people seem to like to use domains as simple type aliases, which will never have any constraints, but we're very dumb about that today. So the patch as presented seems like it has lots of potential applicability, as long as we fix the invalidation aspect. regards, tom lane