List:Commits« Previous MessageNext Message »
From:eugene Date:January 9 2007 11:12am
Subject:bk commit into 5.0 tree (evgen:1.2368)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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@stripped, 2007-01-09 13:12:35+03:00, evgen@stripped +12 -0
  Merge epotemkin@stripped:/home/bk/mysql-5.0-opt
  into  moonbone.local:/home/evgen/bk-trees/mysql-5.0-opt
  MERGE: 1.2344.2.6

  sql-common/client.c@stripped, 2007-01-09 13:12:23+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.104.1.3

  sql-common/my_time.c@stripped, 2007-01-09 13:12:23+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.25.1.7

  sql/filesort.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.109.1.3

  sql/handler.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.222.1.5

  sql/item_cmpfunc.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.224.1.4

  sql/item_subselect.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.142.1.3

  sql/item_timefunc.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.133.1.6

  sql/sql_class.h@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.310.1.7

  sql/sql_parse.cc@stripped, 2007-01-09 13:12:22+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.590.1.7

  sql/sql_select.cc@stripped, 2007-01-09 13:12:23+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.475.1.7

  sql/table.cc@stripped, 2007-01-09 13:12:23+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.237.1.5

  strings/decimal.c@stripped, 2007-01-09 13:12:23+03:00, evgen@stripped +0 -0
    Auto merged
    MERGE: 1.71.1.4

# 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:	evgen
# Host:	moonbone.local
# Root:	/home/evgen/bk-trees/mysql-5.0-opt/RESYNC

--- 1.111/sql/filesort.cc	2006-12-12 17:57:47 +03:00
+++ 1.112/sql/filesort.cc	2007-01-09 13:12:22 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB  
+/* Copyright (C) 2000-2006 MySQL AB  
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.224/sql/handler.cc	2006-12-12 17:57:47 +03:00
+++ 1.225/sql/handler.cc	2007-01-09 13:12:22 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2006 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.226/sql/item_cmpfunc.cc	2006-12-12 17:57:47 +03:00
+++ 1.227/sql/item_cmpfunc.cc	2007-01-09 13:12:22 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000-2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2006 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.135/sql/item_timefunc.cc	2006-12-12 17:57:47 +03:00
+++ 1.136/sql/item_timefunc.cc	2007-01-09 13:12:22 +03:00
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.312/sql/sql_class.h	2006-12-12 17:57:47 +03:00
+++ 1.313/sql/sql_class.h	2007-01-09 13:12:22 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2006 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.592/sql/sql_parse.cc	2006-12-12 17:57:47 +03:00
+++ 1.593/sql/sql_parse.cc	2007-01-09 13:12:22 +03:00
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -7039,6 +7038,7 @@
   bzero((char*) &create_info,sizeof(create_info));
   create_info.db_type=DB_TYPE_DEFAULT;
   create_info.default_table_charset= thd->variables.collation_database;
+  create_info.row_type= ROW_TYPE_NOT_USED;
   DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
 				&create_info, table_list,
 				fields, keys, 0, (ORDER*)0,
@@ -7055,6 +7055,7 @@
   bzero((char*) &create_info,sizeof(create_info));
   create_info.db_type=DB_TYPE_DEFAULT;
   create_info.default_table_charset= thd->variables.collation_database;
+  create_info.row_type= ROW_TYPE_NOT_USED;
   alter_info->clear();
   alter_info->flags= ALTER_DROP_INDEX;
   DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,

--- 1.477/sql/sql_select.cc	2006-12-12 17:57:48 +03:00
+++ 1.478/sql/sql_select.cc	2007-01-09 13:12:23 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000-2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2006 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -2306,8 +2305,18 @@
         substitution of a const table the key value happens to be null
         then we can state that there are no matches for this equi-join.
       */  
-      if ((keyuse= s->keyuse) && *s->on_expr_ref)
+      if ((keyuse= s->keyuse) && *s->on_expr_ref && !s->embedding_map)
       {
+        /* 
+          When performing an outer join operation if there are no matching rows
+          for the single row of the outer table all the inner tables are to be
+          null complemented and thus considered as constant tables.
+          Here we apply this consideration to the case of outer join operations 
+          with a single inner table only because the case with nested tables
+          would require a more thorough analysis.
+          TODO. Apply single row substitution to null complemented inner tables
+          for nested outer join operations. 
+	*/              
         while (keyuse->table == table)
         {
           if (!(keyuse->val->used_tables() & ~join->const_table_map) &&
@@ -8433,6 +8442,46 @@
   return cond;					// Point at next and level
 }
 
+/* 
+  Check if equality can be used in removing components of GROUP BY/DISTINCT
+  
+  SYNOPSIS
+    test_if_equality_guarantees_uniqueness()
+      l          the left comparison argument (a field if any)
+      r          the right comparison argument (a const of any)
+  
+  DESCRIPTION    
+    Checks if an equality predicate can be used to take away 
+    DISTINCT/GROUP BY because it is known to be true for exactly one 
+    distinct value (e.g. <expr> == <const>).
+    Arguments must be of the same type because e.g. 
+    <string_field> = <int_const> may match more than 1 distinct value from 
+    the column. 
+    We must take into consideration and the optimization done for various 
+    string constants when compared to dates etc (see Item_int_with_ref) as
+    well as the collation of the arguments.
+  
+  RETURN VALUE  
+    TRUE    can be used
+    FALSE   cannot be used
+*/
+static bool
+test_if_equality_guarantees_uniqueness(Item *l, Item *r)
+{
+  return r->const_item() &&
+    /* elements must be of the same result type */
+    (r->result_type() == l->result_type() ||
+    /* or dates compared to longs */
+     (((l->type() == Item::FIELD_ITEM &&
+        ((Item_field *)l)->field->can_be_compared_as_longlong()) ||
+       (l->type() == Item::FUNC_ITEM &&
+        ((Item_func *)l)->result_as_longlong())) &&
+      r->result_type() == INT_RESULT))
+    /* and must have the same collation if compared as strings */
+    && (l->result_type() != STRING_RESULT ||
+        l->collation.collation == r->collation.collation);
+}
+
 /*
   Return 1 if the item is a const value in all the WHERE clause
 */
@@ -8469,7 +8518,7 @@
     Item *right_item= ((Item_func*) cond)->arguments()[1];
     if (left_item->eq(comp_item,1))
     {
-      if (right_item->const_item())
+      if (test_if_equality_guarantees_uniqueness (left_item, right_item))
       {
 	if (*const_item)
 	  return right_item->eq(*const_item, 1);
@@ -8479,7 +8528,7 @@
     }
     else if (right_item->eq(comp_item,1))
     {
-      if (left_item->const_item())
+      if (test_if_equality_guarantees_uniqueness (right_item, left_item))
       {
 	if (*const_item)
 	  return left_item->eq(*const_item, 1);

--- 1.239/sql/table.cc	2006-12-12 17:57:48 +03:00
+++ 1.240/sql/table.cc	2007-01-09 13:12:23 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2006 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.145/sql/item_subselect.cc	2006-12-15 23:06:18 +03:00
+++ 1.146/sql/item_subselect.cc	2007-01-09 13:12:22 +03:00
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.106/sql-common/client.c	2006-12-12 17:57:48 +03:00
+++ 1.107/sql-common/client.c	2007-01-09 13:12:23 +03:00
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.27/sql-common/my_time.c	2006-12-12 17:57:48 +03:00
+++ 1.28/sql-common/my_time.c	2007-01-09 13:12:23 +03:00
@@ -1,9 +1,8 @@
-/* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2004-2006 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ the Free Software Foundation; version 2 of the License.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 1.73/strings/decimal.c	2006-12-12 17:57:48 +03:00
+++ 1.74/strings/decimal.c	2007-01-09 13:12:23 +03:00
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -138,6 +137,12 @@
   900000000, 990000000, 999000000,
   999900000, 999990000, 999999000,
   999999900, 999999990 };
+static double scaler10[]= {
+  1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90
+};
+static double scaler1[]= {
+  1.0, 10.0, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9
+};
 
 #ifdef HAVE_purify
 #define sanity(d) DBUG_ASSERT((d)->len > 0)
@@ -946,15 +951,27 @@
 
 int decimal2double(decimal_t *from, double *to)
 {
-  double x=0, t=DIG_BASE;
-  int intg, frac;
-  dec1 *buf=from->buf;
-
-  for (intg=from->intg; intg > 0; intg-=DIG_PER_DEC1)
-    x=x*DIG_BASE + *buf++;
-  for (frac=from->frac; frac > 0; frac-=DIG_PER_DEC1, t*=DIG_BASE)
-    x+=*buf++/t;
-  *to=from->sign ? -x : x;
+  double result= 0.0;
+  int i, exp= 0;
+  dec1 *buf= from->buf;
+
+  for (i= from->intg; i > 0;  i-= DIG_PER_DEC1)
+    result= result * DIG_BASE + *buf++;
+
+  for (i= from->frac; i > 0; i-= DIG_PER_DEC1) {
+    result= result * DIG_BASE + *buf++;
+    exp+= DIG_PER_DEC1;
+  }
+
+  DBUG_PRINT("info", ("interm.: %f %d %f", result, exp,
+             scaler10[exp / 10] * scaler1[exp % 10]));
+
+  result/= scaler10[exp / 10] * scaler1[exp % 10];
+
+  *to= from->sign ? -result : result;
+
+  DBUG_PRINT("info", ("result: %f (%lx)", *to, *(ulong *)to));
+
   return E_DEC_OK;
 }
 
Thread
bk commit into 5.0 tree (evgen:1.2368)eugene9 Jan