List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:July 27 2005 6:40pm
Subject:bk commit into 4.1 tree (jimw:1.2353)
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 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.2353 05/07/27 09:40:05 jimw@stripped +1 -0
  Merge mysql.com:/home/jimw/my/mysql-4.1-11402
  into  mysql.com:/home/jimw/my/mysql-4.1-clean

  sql/item_func.cc
    1.253 05/07/27 09:40:02 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-4.1-clean/RESYNC

--- 1.252/sql/item_func.cc	2005-06-22 20:00:19 -07:00
+++ 1.253/sql/item_func.cc	2005-07-27 09:40:02 -07:00
@@ -39,73 +39,6 @@
 }
 
 
-static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
-			      const char *fname)
-{
-  my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
-	   c1.collation->name,c1.derivation_name(),
-	   c2.collation->name,c2.derivation_name(),
-	   fname);
-}
-
-static void my_coll_agg_error(DTCollation &c1,
-			       DTCollation &c2,
-			       DTCollation &c3,
-			       const char *fname)
-{
-  my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
-  	   c1.collation->name,c1.derivation_name(),
-	   c2.collation->name,c2.derivation_name(),
-	   c3.collation->name,c3.derivation_name(),
-	   fname);
-}
-
-
-static void my_coll_agg_error(Item** args, uint count, const char *fname)
-{
-  if (count == 2)
-    my_coll_agg_error(args[0]->collation, args[1]->collation, fname);
-  else if (count == 3)
-    my_coll_agg_error(args[0]->collation,
-		      args[1]->collation,
-		      args[2]->collation,
-		      fname);
-  else
-    my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname);
-}
-
-
-bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count,
-                                   uint flags)
-{
-  uint i;
-  c.set(av[0]->collation);
-  for (i= 1; i < count; i++)
-  {
-    if (c.aggregate(av[i]->collation, flags))
-    {
-      my_coll_agg_error(av, count, func_name());
-      return TRUE;
-    }
-  }
-  if ((flags & MY_COLL_DISALLOW_NONE) &&
-      c.derivation == DERIVATION_NONE)
-  {
-    my_coll_agg_error(av, count, func_name());
-    return TRUE;
-  }
-  return FALSE;
-}
-
-
-bool Item_func::agg_arg_collations_for_comparison(DTCollation &c,
-						  Item **av, uint count,
-                                                  uint flags)
-{
-  return (agg_arg_collations(c, av, count, flags | MY_COLL_DISALLOW_NONE));
-}
-
-
 /* return TRUE if item is a constant */
 
 bool
@@ -115,88 +48,6 @@
 }
 
 
-
-/* 
-  Collect arguments' character sets together.
-  We allow to apply automatic character set conversion in some cases.
-  The conditions when conversion is possible are:
-  - arguments A and B have different charsets
-  - A wins according to coercibility rules
-    (i.e. a column is stronger than a string constant,
-     an explicit COLLATE clause is stronger than a column)
-  - character set of A is either superset for character set of B,
-    or B is a string constant which can be converted into the
-    character set of A without data loss.
-    
-  If all of the above is true, then it's possible to convert
-  B into the character set of A, and then compare according
-  to the collation of A.
-  
-  For functions with more than two arguments:
-
-    collect(A,B,C) ::= collect(collect(A,B),C)
-*/
-
-bool Item_func::agg_arg_charsets(DTCollation &coll,
-                                 Item **args, uint nargs, uint flags)
-{
-  Item **arg, **last, *safe_args[2];
-  if (agg_arg_collations(coll, args, nargs, flags))
-    return TRUE;
-
-  /*
-    For better error reporting: save the first and the second argument.
-    We need this only if the the number of args is 3 or 2:
-    - for a longer argument list, "Illegal mix of collations"
-      doesn't display each argument's characteristics.
-    - if nargs is 1, then this error cannot happen.
-  */
-  if (nargs >=2 && nargs <= 3)
-  {
-    safe_args[0]= args[0];
-    safe_args[1]= args[1];
-  }
-
-  THD *thd= current_thd;
-  Item_arena *arena, backup;
-  bool res= FALSE;
-  /*
-    In case we're in statement prepare, create conversion item
-    in its memory: it will be reused on each execute.
-  */
-  arena= thd->change_arena_if_needed(&backup);
-
-  for (arg= args, last= args + nargs; arg < last; arg++)
-  {
-    Item* conv;
-    uint32 dummy_offset;
-    if (!String::needs_conversion(0, coll.collation,
-                                  (*arg)->collation.collation,
-                                  &dummy_offset))
-      continue;
-
-    if (!(conv= (*arg)->safe_charset_converter(coll.collation)))
-    {
-      if (nargs >=2 && nargs <= 3)
-      {
-        /* restore the original arguments for better error message */
-        args[0]= safe_args[0];
-        args[1]= safe_args[1];
-      }
-      my_coll_agg_error(args, nargs, func_name());
-      res= TRUE;
-      break; // we cannot return here, we need to restore "arena".
-    }
-    conv->fix_fields(thd, 0, &conv);
-    *arg= conv;
-  }
-  if (arena)
-    thd->restore_backup_item_arena(arena, &backup);
-  return res;
-}
-
-
-
 void Item_func::set_arguments(List<Item> &list)
 {
   allowed_arg_cols= 1;
@@ -3015,6 +2866,37 @@
 }
 
 
+Item_func_get_system_var::
+Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
+                       LEX_STRING *component_arg, const char *name_arg,
+                       size_t name_len_arg)
+  :var(var_arg), var_type(var_type_arg), component(*component_arg)
+{
+  /* set_name() will allocate the name */
+  set_name(name_arg, name_len_arg, system_charset_info);
+}
+
+
+bool
+Item_func_get_system_var::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
+{
+  Item *item;
+  DBUG_ENTER("Item_func_get_system_var::fix_fields");
+
+  /*
+    Evaluate the system variable and substitute the result (a basic constant)
+    instead of this item. If the variable can not be evaluated,
+    the error is reported in sys_var::item().
+  */
+  if (!(item= var->item(thd, var_type, &component)))
+    DBUG_RETURN(1);                             // Impossible
+  item->set_name(name, 0, system_charset_info); // don't allocate a new name
+  thd->change_item_tree(ref, item);
+
+  DBUG_RETURN(0);
+}
+
+
 longlong Item_func_inet_aton::val_int()
 {
   DBUG_ASSERT(fixed == 1);
@@ -3193,6 +3075,9 @@
 
   if (key == NO_SUCH_KEY)
     return 0;
+  
+  if (!table) 
+    goto err;
 
   for (keynr=0 ; keynr < table->keys ; keynr++)
   {
@@ -3356,22 +3241,21 @@
     0	error
     #	constant item
 */
-  
+
 
 Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
 		     LEX_STRING component)
 {
+  sys_var *var;
+  char buff[MAX_SYS_VAR_LENGTH*2+4+8], *pos;
+  LEX_STRING *base_name, *component_name;
+
   if (component.str == 0 &&
       !my_strcasecmp(system_charset_info, name.str, "VERSION"))
     return new Item_string("@@VERSION", server_version,
 			   (uint) strlen(server_version),
 			   system_charset_info, DERIVATION_SYSCONST);
 
-  Item *item;
-  sys_var *var;
-  char buff[MAX_SYS_VAR_LENGTH*2+4+8], *pos;
-  LEX_STRING *base_name, *component_name;
-
   if (component.str)
   {
     base_name= &component;
@@ -3393,9 +3277,8 @@
       return 0;
     }
   }
-  if (!(item=var->item(thd, var_type, component_name)))
-    return 0;					// Impossible
   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+
   buff[0]='@';
   buff[1]='@';
   pos=buff+2;
@@ -3416,28 +3299,8 @@
   memcpy(pos, base_name->str, base_name->length);
   pos+= base_name->length;
 
-  // set_name() will allocate the name
-  item->set_name(buff,(uint) (pos-buff), system_charset_info);
-  return item;
-}
-
-
-Item *get_system_var(THD *thd, enum_var_type var_type, const char *var_name,
-		     uint length, const char *item_name)
-{
-  Item *item;
-  sys_var *var;
-  LEX_STRING null_lex_string;
-
-  null_lex_string.str= 0;
-
-  var= find_sys_var(var_name, length);
-  DBUG_ASSERT(var != 0);
-  if (!(item=var->item(thd, var_type, &null_lex_string)))
-    return 0;						// Impossible
-  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
-  item->set_name(item_name, 0, system_charset_info);	// Will use original name
-  return item;
+  return new Item_func_get_system_var(var, var_type, component_name,
+                                      buff, pos - buff);
 }
 
 
Thread
bk commit into 4.1 tree (jimw:1.2353)Jim Winstead27 Jul