Re: [HACKERS] case bug? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] case bug?
Date
Msg-id 24631.937697487@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] case bug?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Keith Parks <emkxp01@mtcc.demon.co.uk> writes:
>> Then I tried inserting a NULL into the table, which the
>> case statement then treated as 0 and not null.

> This is a bug: the test expressions i < 0 etc are actually returning
> NULL, but ExecEvalCase is failing to check for a NULL condition result.
> It should treat a NULL as false, I expect, just as WHERE does.

Fixed --- here is the patch for REL6_5.
        regards, tom lane


*** src/backend/executor/execQual.c.orig    Sat Jun 12 15:22:40 1999
--- src/backend/executor/execQual.c    Sat Sep 18 19:28:46 1999
***************
*** 1128,1136 ****          /*          * if we have a true test, then we return the result, since the
!          * case statement is satisfied.          */
!         if (DatumGetInt32(const_value) != 0)         {             const_value = ExecEvalExpr((Node *)
wclause->result,                                       econtext,
 
--- 1128,1137 ----          /*          * if we have a true test, then we return the result, since the
!          * case statement is satisfied.  A NULL result from the test is
!          * not considered true.          */
!         if (DatumGetInt32(const_value) != 0 && ! *isNull)         {             const_value = ExecEvalExpr((Node *)
wclause->result,                                       econtext,
 


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] v6.5.2 vacuum...?
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] v6.5.2 vacuum...?