diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index b3b4c717f380abffd1eb09a3b331210586da90fc..2a35f5a807963aebafecdb6bfca9aba7d89cdd2a 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -313,6 +313,8 @@ class Item_exists_subselect :public Item_subselect
 };
 
 
+TABLE_LIST * const NO_JOIN_NEST=(TABLE_LIST*)0x1;
+
 /**
   Representation of IN subquery predicates of the form
   "left_expr IN (SELECT ...)".
@@ -351,12 +353,10 @@ class Item_in_subselect :public Item_exists_subselect
     all JOIN in UNION
   */
   Item *expr;
-public:
-  Item_in_optimizer *optimizer;
-protected:
   bool was_null;
   bool abort_on_null;
 public:
+  Item_in_optimizer *optimizer;
   /* Used to trigger on/off conditions that were pushed down to subselect */
   bool *pushed_cond_guards;
   
@@ -365,7 +365,7 @@ class Item_in_subselect :public Item_exists_subselect
   /*
     Used by subquery optimizations to keep track about in which clause this
     subquery predicate is located: 
-      (TABLE_LIST*) 1   - the predicate is an AND-part of the WHERE
+      NO_JOIN_NEST      - the predicate is an AND-part of the WHERE
       join nest pointer - the predicate is an AND-part of ON expression
                           of a join nest   
       NULL              - for all other locations
@@ -377,7 +377,7 @@ class Item_in_subselect :public Item_exists_subselect
      - pointer to join nest if the subquery predicate is in the ON expression
      - (TABLE_LIST*)1 if the predicate is in the WHERE.
   */
-  TABLE_LIST *expr_join_nest;
+  //TABLE_LIST *expr_join_nest;
   /*
     Types of left_expr and subquery's select list allow to perform subquery
     materialization. Currently, we set this to FALSE when it as well could
@@ -420,7 +420,7 @@ class Item_in_subselect :public Item_exists_subselect
   Item_in_subselect(Item * left_expr, st_select_lex *select_lex);
   Item_in_subselect()
     :Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
-    is_constant(FALSE), optimizer(0), abort_on_null(0),
+    is_constant(FALSE), abort_on_null(0), optimizer(0),
     pushed_cond_guards(NULL), exec_method(NOT_TRANSFORMED), upper_item(0)
   {}
   void cleanup();
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 5be334732f1b85eeef8b0dc8809c6d00431530b9..956a74f39484532285c05cfe265c84269cf00198 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -336,7 +336,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
       /* Register the subquery for further processing in flatten_subqueries() */
       select_lex->
         outer_select()->join->sj_subselects.append(thd->mem_root, in_subs);
-      in_subs->expr_join_nest= thd->thd_marker.emb_on_expr_nest;
     }
     else
     {
@@ -396,7 +395,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
           with jtbm strategy
         */
         if (in_subs->exec_method == Item_in_subselect::MATERIALIZATION &&
-            thd->thd_marker.emb_on_expr_nest == (TABLE_LIST*)0x1 &&
+            thd->thd_marker.emb_on_expr_nest == NO_JOIN_NEST &&
             optimizer_flag(thd, OPTIMIZER_SWITCH_SEMIJOIN))
         {
           in_subs->emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
@@ -560,7 +559,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
   Item *replace_me= item->optimizer;
   DBUG_ASSERT(replace_me==substitute);
 
-  Item **tree= (item->emb_on_expr_nest == (TABLE_LIST*)1)?
+  Item **tree= (item->emb_on_expr_nest == NO_JOIN_NEST)?
                  &join->conds : &(item->emb_on_expr_nest->on_expr);
   if (replace_where_subcondition(join, tree, replace_me, substitute, 
                                  do_fix_fields))
@@ -569,7 +568,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
    
   if (!thd->stmt_arena->is_conventional())
   {
-    tree= (item->emb_on_expr_nest == (TABLE_LIST*)1)?
+    tree= (item->emb_on_expr_nest == (TABLE_LIST*)NO_JOIN_NEST)?
            &join->select_lex->prep_where : 
            &(item->emb_on_expr_nest->prep_on_expr);
 
@@ -711,7 +710,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
     }
     if (remove_item)
     {
-      Item **tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
+      Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
                      &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
       Item *replace_me= *in_subq;
       /*
@@ -755,7 +754,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
 
     Item *substitute= (*in_subq)->substitution;
     bool do_fix_fields= !(*in_subq)->substitution->fixed;
-    Item **tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
+    Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
                    &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
 
     Item *replace_me= *in_subq;
@@ -776,7 +775,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
      
     if (!thd->stmt_arena->is_conventional())
     {
-      tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
+      tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
              &join->select_lex->prep_where : 
              &((*in_subq)->emb_on_expr_nest->prep_on_expr);
 
@@ -944,9 +943,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
     1. Find out where to put the predicate into.
      Note: for "t1 LEFT JOIN t2" this will be t2, a leaf.
   */
-  if ((void*)subq_pred->expr_join_nest != (void*)1)
+  if ((void*)subq_pred->emb_on_expr_nest != (void*)NO_JOIN_NEST)
   {
-    if (subq_pred->expr_join_nest->nested_join)
+    if (subq_pred->emb_on_expr_nest->nested_join)
     {
       /*
         We're dealing with
@@ -955,10 +954,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
 
         The sj-nest will be inserted into the brackets nest.
       */
-      emb_tbl_nest=  subq_pred->expr_join_nest;
+      emb_tbl_nest=  subq_pred->emb_on_expr_nest;
       emb_join_list= &emb_tbl_nest->nested_join->join_list;
     }
-    else if (!subq_pred->expr_join_nest->outer_join)
+    else if (!subq_pred->emb_on_expr_nest->outer_join)
     {
       /*
         We're dealing with
@@ -968,13 +967,13 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
         The sj-nest will be tblX's "sibling", i.e. another child of its
         parent. This is ok because tblX is joined as an inner join.
       */
-      emb_tbl_nest= subq_pred->expr_join_nest->embedding;
+      emb_tbl_nest= subq_pred->emb_on_expr_nest->embedding;
       if (emb_tbl_nest)
         emb_join_list= &emb_tbl_nest->nested_join->join_list;
     }
-    else if (!subq_pred->expr_join_nest->nested_join)
+    else if (!subq_pred->emb_on_expr_nest->nested_join)
     {
-      TABLE_LIST *outer_tbl= subq_pred->expr_join_nest;      
+      TABLE_LIST *outer_tbl= subq_pred->emb_on_expr_nest;
       TABLE_LIST *wrap_nest;
       /*
         We're dealing with
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index cd6d2f40dbac8ea5af24e89b597c776e42bfee2b..38e601acb0de2c459ce03dae6e463498a4bcb1a7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8188,7 +8188,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
       goto err_no_arena;
   }
 
-  thd->thd_marker.emb_on_expr_nest= (TABLE_LIST*)1;
+  thd->thd_marker.emb_on_expr_nest= NO_JOIN_NEST;
   if (*conds)
   {
     thd->where="where clause";