diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 88d9360e422ea41ff4a31b735ea29d06189ee4db..a6da272d47c363eb7688640873a7bcb313cb88e5 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.110 2007/01/30 01:33:36 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.111 2007/02/22 22:49:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -731,7 +731,10 @@ ExecHashGetHashValue(HashJoinTable hashtable,
 		if (isNull)
 		{
 			if (hashtable->hashStrict[i] && !keep_nulls)
-				return false;	/* cannot match */
+			{
+				MemoryContextSwitchTo(oldContext);
+				return false;							/* cannot match */
+			}
 			/* else, leave hashkey unmodified, equivalent to hashcode 0 */
 		}
 		else