From: Tom Lane Date: Fri, 6 Jan 2006 20:11:31 +0000 (+0000) Subject: Fix failure to apply domain constraints to a NULL constant that's added to X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=3efd7284a056c65070e7716e303de179310df533;p=users%2Fbernd%2Fpostgres.git Fix failure to apply domain constraints to a NULL constant that's added to an INSERT target list during rule rewriting. Per report from John Supplee. --- diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 735613bf6d..ea32fac547 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -18,6 +18,7 @@ #include "optimizer/tlist.h" #include "parser/parsetree.h" #include "parser/parse_clause.h" +#include "parser/parse_coerce.h" #include "rewrite/rewriteManip.h" #include "utils/lsyscache.h" @@ -904,7 +905,11 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context) else { /* Otherwise replace unmatched var with a null */ - return (Node *) makeNullConst(var->vartype); + /* need coerce_to_domain in case of NOT NULL domain constraint */ + return coerce_to_domain((Node *) makeNullConst(var->vartype), + InvalidOid, + var->vartype, + COERCE_IMPLICIT_CAST); } } else