Whilst working on the change I proposed to make domain types enforce
their constraints inside the typinput/typreceive routines, I realized
that there's a fairly serious flaw in the design of typreceive routines:
we don't pass them a typmod so they cannot enforce type-specific typmod
restrictions. This means for example that COPY FROM BINARY could insert
a more-than-four-character string into a char(4) column.
The correct solution of course is to include a typmod value in the
arguments passed to typreceive routines, and to adjust the receive
routines of those datatypes that use typmod to enforce the same
restrictions as the corresponding typinput routines do.
I think this is a "must fix" for 8.1.
regards, tom lane