Fix failure to apply domain constraints to a NULL constant that's added to
authorTom Lane <[email protected]>
Fri, 6 Jan 2006 20:11:36 +0000 (20:11 +0000)
committerTom Lane <[email protected]>
Fri, 6 Jan 2006 20:11:36 +0000 (20:11 +0000)
an INSERT target list during rule rewriting.  Per report from John Supplee.

src/backend/rewrite/rewriteManip.c

index 96a59648252a80e93648cad07f55028aea6db435..c6998f17c3488daf749ffa4421dfe1df2516fcd2 100644 (file)
@@ -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"
 
@@ -815,7 +816,10 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
                                else
                                {
                                        /* Otherwise replace unmatched var with a null */
-                                       return (Node *) makeNullConst(var->vartype);
+                                       /* need coerce_type_constraints in case of NOT NULL domain constraint */
+                                       return coerce_type_constraints((Node *) makeNullConst(var->vartype),
+                                                                                                  var->vartype,
+                                                                                                  COERCE_IMPLICIT_CAST);
                                }
                        }
                        else