Index: java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/SelectNode.java	(revision 612987)
+++ java/engine/org/apache/derby/impl/sql/compile/SelectNode.java	(working copy)
@@ -816,7 +816,8 @@
 		 * because the subquery transformations assume that any subquery operator 
 		 * negation has already occurred.
 		 */
-		normExpressions();
+		whereClause = normExpressions(whereClause);
+		havingClause = normExpressions(havingClause);
 
 		/**
 		 * This method determines if (1) the query is a LOJ, and (2) if the LOJ is a candidate for
@@ -1070,7 +1071,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	private void normExpressions()
+	private ValueNode normExpressions(ValueNode boolClause)
 				throws StandardException
 	{
 		/* For each expression tree:
@@ -1079,41 +1080,43 @@
 		 *	  top level expression. (putAndsOnTop())
 		 *	o Finish the job (changeToCNF())
 		 */
-		if (whereClause != null)
+		if (boolClause != null)
 		{
-			whereClause = whereClause.eliminateNots(false);
+			boolClause = boolClause.eliminateNots(false);
 			if (SanityManager.DEBUG)
 			{
-				if (!(whereClause.verifyEliminateNots()) )
+				if (!(boolClause.verifyEliminateNots()) )
 				{
-					whereClause.treePrint();
+					boolClause.treePrint();
 					SanityManager.THROWASSERT(
-						"whereClause in invalid form: " + whereClause); 
+						"boolClause in invalid form: " + boolClause); 
 				}
 			}
-			whereClause = whereClause.putAndsOnTop();
+			boolClause = boolClause.putAndsOnTop();
 			if (SanityManager.DEBUG)
 			{
-				if (! ((whereClause instanceof AndNode) &&
-					   (whereClause.verifyPutAndsOnTop())) )
+				if (! ((boolClause instanceof AndNode) &&
+					   (boolClause.verifyPutAndsOnTop())) )
 				{
-					whereClause.treePrint();
+					boolClause.treePrint();
 					SanityManager.THROWASSERT(
-						"whereClause in invalid form: " + whereClause); 
+						"boolClause in invalid form: " + boolClause); 
 				}
 			}
-			whereClause = whereClause.changeToCNF(true);
+			boolClause = boolClause.changeToCNF(true);
 			if (SanityManager.DEBUG)
 			{
-				if (! ((whereClause instanceof AndNode) &&
-					   (whereClause.verifyChangeToCNF())) )
+				if (! ((boolClause instanceof AndNode) &&
+					   (boolClause.verifyChangeToCNF())) )
 				{
-					whereClause.treePrint();
+					boolClause.treePrint();
 					SanityManager.THROWASSERT(
-						"whereClause in invalid form: " + whereClause); 
+						"boolClause in invalid form: " + boolClause); 
 				}
 			}
 		}
+
+		return boolClause;
 	}
 
 	/**
