Bug fix: bad code was generated for when the first operand of a CASE
was NULL. (CVS 598)

FossilOrigin-Name: 4debc8db929fdc201759ba211acdeadc4e30e8af
diff --git a/src/expr.c b/src/expr.c
index 89508d2..25f0ebd 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.64 2002/05/26 20:54:33 drh Exp $
+** $Id: expr.c,v 1.65 2002/05/30 02:35:12 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -935,6 +935,7 @@
       int expr_end_label;
       int null_result_label;
       int jumpInst;
+      int nullBypassInst;
       int addr;
       int nExpr;
       int i;
@@ -947,7 +948,7 @@
       null_result_label = sqliteVdbeMakeLabel(v);
       if( pExpr->pLeft ){
         sqliteExprCode(pParse, pExpr->pLeft);
-        sqliteVdbeAddOp(v, OP_IsNull, -1, expr_end_label);
+        nullBypassInst = sqliteVdbeAddOp(v, OP_IsNull, -1, 0);
       }
       for(i=0; i<nExpr; i=i+2){
         sqliteExprCode(pParse, pExpr->pList->a[i].pExpr);
@@ -980,6 +981,7 @@
       if( pExpr->pLeft ){
         sqliteVdbeAddOp(v, OP_Pull, 1, 0);
         sqliteVdbeAddOp(v, OP_Pop, 1, 0);
+        sqliteVdbeChangeP2(v, nullBypassInst, sqliteVdbeCurrentAddr(v));
       }
     }
     break;
@@ -1164,8 +1166,7 @@
     }
     default: {
       sqliteExprCode(pParse, pExpr);
-      sqliteVdbeAddOp(v, OP_Not, 0, 0);
-      sqliteVdbeAddOp(v, OP_If, jumpIfNull, dest);
+      sqliteVdbeAddOp(v, OP_IfNot, jumpIfNull, dest);
       break;
     }
   }