On Mon, 2006-01-30 at 20:45 -0500, Tom Lane wrote:
> You only fixed the bind-parameter case, though, no? The problem is
> still rampant in the PLs.
Right: the bug report was specific to the bind parameter case. Domain
constraints should also be checked before returning values of a domain
type from all of the procedural languages, and before casting a value to
a domain type in PL/PgSQL.
This can be done by adding constraint checks to each PL individually,
like this patch for PL/PgSQL's return value:
http://archives.postgresql.org/pgsql-patches/2006-01/msg00107.php
(The patch hasn't been applied because there is some additional
infrastructure needed to get good performance.)
We could do similar work for each PL. That actually wouldn't be too bad:
adding the necessary domain constraint information (plus sinval support)
to the typcache would allow most of the code to be shared. Or we could
refactor the code more cleanly, as Tom suggests -- it's not clear to me
quite how to do that without accepting a performance hit, though...
-Neil