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,