List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:December 1 2005 9:07pm
Subject:bk commit into 5.0 tree (jimw:1.2039)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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.2039 05/12/01 12:07:25 jimw@stripped +3 -0
  Merge mysql.com:/home/jimw/my/mysql-4.1-12612
  into  mysql.com:/home/jimw/my/mysql-5.0-clean

  sql/item_cmpfunc.cc
    1.187 05/12/01 12:07:22 jimw@stripped +0 -0
    SCCS merged

  mysql-test/t/func_equal.test
    1.8 05/12/01 12:05:48 jimw@stripped +0 -0
    Auto merged

  mysql-test/r/func_equal.result
    1.9 05/12/01 12:05:48 jimw@stripped +0 -0
    Auto merged

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-clean/RESYNC

--- 1.186/sql/item_cmpfunc.cc	2005-11-25 18:51:39 -08:00
+++ 1.187/sql/item_cmpfunc.cc	2005-12-01 12:07:22 -08:00
@@ -25,6 +25,8 @@
 #include <m_ctype.h>
 #include "sql_select.h"
 
+static bool convert_constant_item(THD *thd, Field *field, Item **item);
+
 static Item_result item_store_type(Item_result a,Item_result b)
 {
   if (a == STRING_RESULT || b == STRING_RESULT)
@@ -45,14 +47,37 @@
     type[0]= item_store_type(type[0], items[i]->result_type());
 }
 
-static void agg_cmp_type(Item_result *type, Item **items, uint nitems)
+
+static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
 {
   uint i;
+  Field *field= NULL;
+  bool all_constant= TRUE;
+
+  /* If the first argument is a FIELD_ITEM, pull out the field. */
+  if (items[0]->type() == Item::FIELD_ITEM)
+    field=((Item_field *)items[0])->field;
+  /* But if it can't be compared as a longlong, we don't really care. */
+  if (field && !field->can_be_compared_as_longlong())
+    field= NULL;
+
   type[0]= items[0]->result_type();
-  for (i=1 ; i < nitems ; i++)
+  for (i= 1; i < nitems; i++)
+  {
     type[0]= item_cmp_type(type[0], items[i]->result_type());
+    if (field && !convert_constant_item(thd, field, &items[i]))
+      all_constant= FALSE;
+  }
+
+  /*
+    If we had a field that can be compared as a longlong, and all constant
+    items, then the aggregate result will be an INT_RESULT.
+  */
+  if (field && all_constant)
+    type[0]= INT_RESULT;
 }
 
+
 static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
                               const char *fname)
 {
@@ -1051,32 +1076,11 @@
   */
   if (!args[0] || !args[1] || !args[2])
     return;
-  agg_cmp_type(&cmp_type, args, 3);
+  agg_cmp_type(thd, &cmp_type, args, 3);
+
   if (cmp_type == STRING_RESULT &&
       agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV))
     return;
-
-  /*
-    Make a special ease of compare with date/time and longlong fields.
-    They are compared as integers, so for const item this time-consuming
-    conversion can be done only once, not for every single comparison
-  */
-  if (args[0]->type() == FIELD_ITEM)
-  {
-    Field *field=((Item_field*) args[0])->field;
-    if (!thd->is_context_analysis_only() &&
-        field->can_be_compared_as_longlong())
-    {
-      /*
-        The following can't be recoded with || as convert_constant_item
-        changes the argument
-      */
-      if (convert_constant_item(thd, field,&args[1]))
-	cmp_type=INT_RESULT;			// Works for all types.
-      if (convert_constant_item(thd, field,&args[2]))
-	cmp_type=INT_RESULT;			// Works for all types.
-    }
-  }
 }
 
 
@@ -1722,6 +1726,7 @@
 {
   Item **agg;
   uint nagg;
+  THD *thd= current_thd;
   
   if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
     return;
@@ -1753,7 +1758,7 @@
     for (nagg= 0; nagg < ncases/2 ; nagg++)
       agg[nagg+1]= args[nagg*2];
     nagg++;
-    agg_cmp_type(&cmp_type, agg, nagg);
+    agg_cmp_type(thd, &cmp_type, agg, nagg);
     if ((cmp_type == STRING_RESULT) &&
         agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV))
       return;
@@ -2346,7 +2351,7 @@
   uint const_itm= 1;
   THD *thd= current_thd;
   
-  agg_cmp_type(&cmp_type, args, arg_count);
+  agg_cmp_type(thd, &cmp_type, args, arg_count);
 
   if (cmp_type == STRING_RESULT &&
       agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV))

--- 1.8/mysql-test/r/func_equal.result	2005-02-08 14:49:32 -08:00
+++ 1.9/mysql-test/r/func_equal.result	2005-12-01 12:05:48 -08:00
@@ -33,3 +33,12 @@
 select * from t1 where id <=> value or value<=>id;
 id	value
 drop table t1,t2;
+create table t1 (a bigint unsigned);
+insert into t1 values (4828532208463511553);
+select * from t1 where a = '4828532208463511553';
+a
+4828532208463511553
+select * from t1 where a in ('4828532208463511553');
+a
+4828532208463511553
+drop table t1;

--- 1.7/mysql-test/t/func_equal.test	2005-07-28 06:12:33 -07:00
+++ 1.8/mysql-test/t/func_equal.test	2005-12-01 12:05:48 -08:00
@@ -34,4 +34,13 @@
 select * from t1 where id <=> value or value<=>id;
 drop table t1,t2;
 
+#
+# Bug #12612: quoted bigint unsigned value and the use of "in" in where clause
+#
+create table t1 (a bigint unsigned);
+insert into t1 values (4828532208463511553);
+select * from t1 where a = '4828532208463511553';
+select * from t1 where a in ('4828532208463511553');
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 5.0 tree (jimw:1.2039)Jim Winstead1 Dec