"John Supplee" <john@supplee.com> writes:
> Tom Lane wrote:
>> Works for me:
> You need to modify your test case slightly.
OK, got it.  Patch for 8.1 is attached if you need it.  Thanks for the
test case.
            regards, tom lane
Index: rewriteManip.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v
retrieving revision 1.92.2.2
diff -c -r1.92.2.2 rewriteManip.c
*** rewriteManip.c    23 Nov 2005 17:21:22 -0000    1.92.2.2
--- rewriteManip.c    6 Jan 2006 19:41:30 -0000
***************
*** 18,23 ****
--- 18,24 ----
  #include "optimizer/clauses.h"
  #include "optimizer/tlist.h"
  #include "parser/parsetree.h"
+ #include "parser/parse_coerce.h"
  #include "parser/parse_relation.h"
  #include "rewrite/rewriteManip.h"
  #include "utils/lsyscache.h"
***************
*** 838,844 ****
          else
          {
              /* Otherwise replace unmatched var with a null */
!             return (Node *) makeNullConst(var->vartype);
          }
      }
      else
--- 839,851 ----
          else
          {
              /* Otherwise replace unmatched var with a null */
!             /* 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,
!                                     false,
!                                     false);
          }
      }
      else