Re: [HACKERS] case bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Keith Parks <emkxp01(at)mtcc(dot)demon(dot)co(dot)uk>
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] case bug?
Date: 1999-09-18 23:31:27
Message-ID: 24631.937697487@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Keith Parks <emkxp01(at)mtcc(dot)demon(dot)co(dot)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,

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-09-18 23:38:33 Re: [HACKERS] v6.5.2 vacuum...?
Previous Message The Hermit Hacker 1999-09-18 23:30:23 Re: [HACKERS] v6.5.2 vacuum...?