diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 2cc734ce24f1fc6ddd14113f0c0764973a46f2f0..45b785e6a80fc8b2f7001ec606359596267c830b 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -10,7 +10,6 @@
 #
 ##############################################################################
 events_time_zone         : Test is not predictable as it depends on precise timing.
-table_elim              : sergeyp to reapply 2643.26.4 in Item_sum::update_used_tables
 lowercase_table3         : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX
 read_many_rows_innodb    : Bug#11748886 2010-11-15 mattiasj report already exists
 sum_distinct-big         : Bug#11764126 2010-11-15 mattiasj was not tested
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3e7cc24dfd860ad74838b72d674599abbb683d2d..c0d3b14b71b7e3712dcb14ad47dbf2d00327e14d 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1424,7 +1424,11 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
   cache->setup(args[0]);
   if (cache->cols() == 1)
   {
-    if ((used_tables_cache= args[0]->used_tables()))
+    /* 
+      Note: there can be cases when used_tables()==0 && !const_item(). See
+      Item_sum::update_used_tables for details.
+    */
+    if ((used_tables_cache= args[0]->used_tables()) || !args[0]->const_item())
       cache->set_used_tables(OUTER_REF_TABLE_BIT);
     else
       cache->set_used_tables(0);
@@ -1434,7 +1438,8 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
     uint n= cache->cols();
     for (uint i= 0; i < n; i++)
     {
-      if (args[0]->element_index(i)->used_tables())
+      Item *element=args[0]->element_index(i);
+      if (element->used_tables() || !element->const_item())
 	((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT);
       else
 	((Item_cache *)cache->element_index(i))->set_used_tables(0);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index d60eb1415b935b350917bfc4d71ca8a823341916..0b8ae2d1d54e1274066b3e422a6ae45c93a07735 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -550,11 +550,20 @@ void Item_sum::update_used_tables ()
       args[i]->update_used_tables();
       used_tables_cache|= args[i]->used_tables();
     }
-
-    used_tables_cache&= PSEUDO_TABLE_BITS;
-
-    /* the aggregate function is aggregated into its local context */
-    used_tables_cache |=  (1 << aggr_sel->join->table_count) - 1;
+    /*
+      MariaDB: don't run the following {
+      
+      used_tables_cache&= PSEUDO_TABLE_BITS;
+
+      // the aggregate function is aggregated into its local context
+      used_tables_cache |=  (1 << aggr_sel->join->table_count) - 1;
+      
+      } because if we do it, table elimination will assume that
+        - constructs like "COUNT(*)" use columns from all tables
+        - so, it is not possible to eliminate any table
+      our solution for COUNT(*) is that it has
+        item->used_tables() == 0 && !item->const_item()
+    */
   }
 }