List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:April 6 2006 7:42pm
Subject:bk commit into 5.0 tree (sergefp:1.2146)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of psergey. When psergey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2146 06/04/06 21:42:03 sergefp@stripped +1 -0
  Remove redundant code in opt_sum_query()

  sql/opt_sum.cc
    1.51 06/04/06 21:42:00 sergefp@stripped +7 -20
    Remove redundant code in opt_sum_query()

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	sergefp
# Host:	pylon.mylan
# Root:	/home/psergey/mysql-5.0-bug18237-review

--- 1.50/sql/opt_sum.cc	2006-04-04 23:54:56 +04:00
+++ 1.51/sql/opt_sum.cc	2006-04-06 21:42:00 +04:00
@@ -123,8 +123,11 @@
       If the storage manager of 'tl' gives exact row count, compute the total
       number of rows. If there are no outer table dependencies, this count
       may be used as the real count.
+      Schema tables are filled after this function is invoked, so we can't
+      get row count 
     */
-    if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT)
+    if ((tl->table->file->table_flags() & HA_NOT_EXACT_COUNT) ||
+        tl->schema_table)
     {
       is_exact_count= FALSE;
       count= 1;                                 // ensure count != 0
@@ -149,31 +152,15 @@
       switch (item_sum->sum_func()) {
       case Item_sum::COUNT_FUNC:
         /*
-          If the expr in count(expr) can never be null we can change this
+          If the expr in COUNT(expr) can never be null we can change this
           to the number of rows in the tables if this number is exact and
           there are no outer joins.
         */
         if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null
&&
             !outer_tables && is_exact_count)
         {
-          longlong count= 1;
-          TABLE_LIST *table;
-          for (table= tables; table; table= table->next_leaf)
-          {
-            if (outer_tables || (table->table->file->table_flags() &
-                                 HA_NOT_EXACT_COUNT) || table->schema_table)
-            {
-              const_result= 0;			// Can't optimize left join
-              break;
-            }
-            tables->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
-            count*= table->table->file->records;
-          }
-          if (!table)
-          {
-            ((Item_sum_count*) item)->make_const(count);
-            recalc_const_item= 1;
-          }
+          ((Item_sum_count*) item)->make_const(count);
+          recalc_const_item= 1;
         }
         else
           const_result= 0;
Thread
bk commit into 5.0 tree (sergefp:1.2146)Sergey Petrunia6 Apr