To: Keith Parks cc: hackers@postgreSQL.org Subject: Re: [HACKERS] case bug? In-reply-to: Your message of Sat, 18 Sep 1999 15:37:17 -0400 <20727.937683437@sss.pgh.pa.us> Date: Sat, 18 Sep 1999 19:31:27 -0400 Message-ID: <24631.937697487@sss.pgh.pa.us> From: Tom Lane Sender: owner-pgsql-hackers@postgreSQL.org Precedence: bulk X-UIDL: f1c99b4f76b4122de93ad6f2400077a0 Status: U Keith Parks 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, ************