Re: BUG #2144: Domain NOT NULL constraints ignored in rules - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2144: Domain NOT NULL constraints ignored in rules
Date
Msg-id 22378.1136578471@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #2144: Domain NOT NULL constraints ignored in rules  ("John Supplee" <john@supplee.com>)
Responses Re: BUG #2144: Domain NOT NULL constraints ignored in rules
List pgsql-bugs
"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

pgsql-bugs by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: BUG #2150: PL/Python function delcared STABLE gets run repeatedly
Next
From: Michael Meskes
Date:
Subject: Re: BUG #2146: ECPG, cursros and conditional compilations...