List:Internals« Previous MessageNext Message »
From:konstantin Date:June 16 2005 5:43pm
Subject:bk commit into 5.0 tree (konstantin:1.1951) BUG#7015
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja 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.1951 05/06/16 19:43:13 konstantin@stripped +9 -0
  A cleanup that evolved while reviewing Bug#7015

  sql/item_uniq.h
    1.25 05/06/16 19:43:07 konstantin@stripped +2 -0
    Add missing func_name() implementations.

  sql/item_timefunc.h
    1.53 05/06/16 19:43:06 konstantin@stripped +3 -0
    Add missing functype() and func_name() implementations.

  sql/item_timefunc.cc
    1.86 05/06/16 19:43:06 konstantin@stripped +2 -2
    Use functype(), not func_name() for items rtti.

  sql/item_sum.h
    1.88 05/06/16 19:43:06 konstantin@stripped +11 -1
    Add comment for func_name()

  sql/item_strfunc.h
    1.92 05/06/16 19:43:06 konstantin@stripped +2 -0
    Add missing func_name and func_type

  sql/item_strfunc.cc
    1.233 05/06/16 19:43:06 konstantin@stripped +1 -1
    Use functype(), not func_name(), for Items rtti

  sql/item_func.h
    1.119 05/06/16 19:43:06 konstantin@stripped +25 -13
    Add a comment for Item_func::func_name()

  sql/item_func.cc
    1.221 05/06/16 19:43:06 konstantin@stripped +1 -1
    Use functype(), not func_name() for rtti.

  sql/item.h
    1.139 05/06/16 19:43:06 konstantin@stripped +12 -0
    Add a comment for Item::print

# 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:	konstantin
# Host:	dragonfly.local
# Root:	/opt/local/work/mysql-5.0-func_name_new

--- 1.138/sql/item.h	2005-06-15 17:58:54 +04:00
+++ 1.139/sql/item.h	2005-06-16 19:43:06 +04:00
@@ -468,6 +468,18 @@
   */
   virtual bool const_during_execution() const 
   { return (used_tables() & ~PARAM_TABLE_BIT) == 0; }
+  /*
+    This is an essential method for correct functioning of VIEWS.
+    To save a view in an .frm file we need its unequivocal
+    definition in SQL that takes into account sql_mode and
+    environmental settings.  Currently such definition is restored
+    by traversing through the parsed tree of a view and
+    print()'ing SQL syntax of every node to a String buffer. This
+    method is used to print the SQL definition of an item. The
+    second use of this method is for EXPLAIN EXTENDED, to print
+    the SQL of a query after all optimizations of the parsed tree
+    have been done.
+  */
   virtual void print(String *str_arg) { str_arg->append(full_name()); }
   void print_item_w_name(String *);
   virtual void update_used_tables() {}

--- 1.220/sql/item_func.cc	2005-06-15 18:01:35 +04:00
+++ 1.221/sql/item_func.cc	2005-06-16 19:43:06 +04:00
@@ -4111,7 +4111,7 @@
     return 1;					// Same item is same.
   /* Check if other type is also a get_user_var() object */
   if (item->type() != FUNC_ITEM ||
-      ((Item_func*) item)->func_name() != func_name())
+      ((Item_func*) item)->functype() != functype())
     return 0;
   Item_func_get_user_var *other=(Item_func_get_user_var*) item;
   return (name.length == other->name.length &&

--- 1.118/sql/item_func.h	2005-06-10 18:13:55 +04:00
+++ 1.119/sql/item_func.h	2005-06-16 19:43:06 +04:00
@@ -54,7 +54,8 @@
 		  SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
                   NOT_FUNC, NOT_ALL_FUNC,
                   NOW_FUNC, TRIG_COND_FUNC,
-                  GUSERVAR_FUNC};
+                  GUSERVAR_FUNC, COLLATE_FUNC,
+                  EXTRACT_FUNC, CHAR_TYPECAST_FUNC };
   enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
                        OPTIMIZE_EQUAL };
   enum Type type() const { return FUNC_ITEM; }
@@ -123,7 +124,17 @@
   virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
   virtual bool have_rev_func() const { return 0; }
   virtual Item *key_item() const { return args[0]; }
-  virtual const char *func_name() const { return "?"; }
+  /*
+    This method is used for debug purposes to print the name of an
+    item to the debug log. The second use of this method is as
+    a helper function of print(), where it is applicable.
+    To suit both goals it should return a meaningful,
+    distinguishable and sintactically correct string.  This method
+    should not be used for runtime type identification, use enum
+    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
+    instead.
+  */
+  virtual const char *func_name() const= 0;
   virtual bool const_item() const { return const_item_cache; }
   inline Item **arguments() const { return args; }
   void set_arguments(List<Item> &list);
@@ -306,6 +317,7 @@
   enum Item_result result_type () const { return DECIMAL_RESULT; }
   enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
   void fix_length_and_dec() {};
+  const char *func_name() const { return "decimal_typecast"; }
 };
 
 
@@ -506,7 +518,7 @@
 
 class Item_func_acos :public Item_dec_func
 {
- public:
+public:
   Item_func_acos(Item *a) :Item_dec_func(a) {}
   double val_real();
   const char *func_name() const { return "acos"; }
@@ -514,7 +526,7 @@
 
 class Item_func_asin :public Item_dec_func
 {
- public:
+public:
   Item_func_asin(Item *a) :Item_dec_func(a) {}
   double val_real();
   const char *func_name() const { return "asin"; }
@@ -522,7 +534,7 @@
 
 class Item_func_atan :public Item_dec_func
 {
- public:
+public:
   Item_func_atan(Item *a) :Item_dec_func(a) {}
   Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {}
   double val_real();
@@ -531,7 +543,7 @@
 
 class Item_func_cos :public Item_dec_func
 {
- public:
+public:
   Item_func_cos(Item *a) :Item_dec_func(a) {}
   double val_real();
   const char *func_name() const { return "cos"; }
@@ -539,7 +551,7 @@
 
 class Item_func_sin :public Item_dec_func
 {
- public:
+public:
   Item_func_sin(Item *a) :Item_dec_func(a) {}
   double val_real();
   const char *func_name() const { return "sin"; }
@@ -547,7 +559,7 @@
 
 class Item_func_tan :public Item_dec_func
 {
- public:
+public:
   Item_func_tan(Item *a) :Item_dec_func(a) {}
   double val_real();
   const char *func_name() const { return "tan"; }
@@ -634,7 +646,7 @@
 {
   char *name;
   double mul,add;
- public:
+public:
   Item_func_units(char *name_arg,Item *a,double mul_arg,double add_arg)
     :Item_real_func(a),name(name_arg),mul(mul_arg),add(add_arg) {}
   double val_real();
@@ -853,7 +865,7 @@
 class Item_func_benchmark :public Item_int_func
 {
   ulong loop_count;
- public:
+public:
   Item_func_benchmark(ulong loop_count_arg,Item *expr)
     :Item_int_func(expr), loop_count(loop_count_arg)
   {}
@@ -868,7 +880,7 @@
 
 class Item_udf_func :public Item_func
 {
- protected:
+protected:
   udf_handler udf;
 
 public:
@@ -1046,7 +1058,7 @@
 class Item_func_release_lock :public Item_int_func
 {
   String value;
- public:
+public:
   Item_func_release_lock(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "release_lock"; }
@@ -1058,7 +1070,7 @@
 class Item_master_pos_wait :public Item_int_func
 {
   String value;
- public:
+public:
   Item_master_pos_wait(Item *a,Item *b) :Item_int_func(a,b) {}
   Item_master_pos_wait(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
   longlong val_int();

--- 1.232/sql/item_strfunc.cc	2005-06-08 14:49:01 +04:00
+++ 1.233/sql/item_strfunc.cc	2005-06-16 19:43:06 +04:00
@@ -2297,7 +2297,7 @@
     return 0;
   Item_func *item_func=(Item_func*) item;
   if (arg_count != item_func->arg_count ||
-      func_name() != item_func->func_name())
+      functype() != item_func->functype())
     return 0;
   Item_func_set_collation *item_func_sc=(Item_func_set_collation*) item;
   if (collation.collation != item_func_sc->collation.collation)

--- 1.91/sql/item_strfunc.h	2005-06-06 15:49:23 +04:00
+++ 1.92/sql/item_strfunc.h	2005-06-16 19:43:06 +04:00
@@ -573,6 +573,7 @@
     max_length=args[0]->max_length;
   }
   void print(String *str);
+  const char *func_name() const { return "cast_as_binary"; }
 };
 
 
@@ -648,6 +649,7 @@
   void fix_length_and_dec();
   bool eq(const Item *item, bool binary_cmp) const;
   const char *func_name() const { return "collate"; }
+  enum Functype func_type() const { return COLLATE_FUNC; }
   void print(String *str);
   Item_field *filed_for_view_update()
   {

--- 1.87/sql/item_sum.h	2005-05-10 14:33:41 +04:00
+++ 1.88/sql/item_sum.h	2005-06-16 19:43:06 +04:00
@@ -81,7 +81,17 @@
   virtual void update_field()=0;
   virtual bool keep_field_type(void) const { return 0; }
   virtual void fix_length_and_dec() { maybe_null=1; null_value=1; }
-  virtual const char *func_name() const { return "?"; }
+  /*
+    This method is used for debug purposes to print the name of an
+    item to the debug log. The second use of this method is as
+    a helper function of print(), where it is applicable.
+    To suit both goals it should return a meaningful,
+    distinguishable and sintactically correct string.  This method
+    should not be used for runtime type identification, use enum
+    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
+    instead.
+  */
+  virtual const char *func_name() const= 0;
   virtual Item *result_item(Field *field)
     { return new Item_field(field);}
   table_map used_tables() const { return ~(table_map) 0; } /* Not used */

--- 1.85/sql/item_timefunc.cc	2005-06-06 22:21:25 +04:00
+++ 1.86/sql/item_timefunc.cc	2005-06-16 19:43:06 +04:00
@@ -2158,7 +2158,7 @@
   if (this == item)
     return 1;
   if (item->type() != FUNC_ITEM ||
-      func_name() != ((Item_func*)item)->func_name())
+      functype() != ((Item_func*)item)->functype())
     return 0;
 
   Item_extract* ie= (Item_extract*)item;
@@ -2176,7 +2176,7 @@
   if (this == item)
     return 1;
   if (item->type() != FUNC_ITEM ||
-      func_name() != ((Item_func*)item)->func_name())
+      functype() != ((Item_func*)item)->functype())
     return 0;
 
   Item_char_typecast *cast= (Item_char_typecast*)item;

--- 1.52/sql/item_timefunc.h	2005-05-09 13:26:47 +04:00
+++ 1.53/sql/item_timefunc.h	2005-06-16 19:43:06 +04:00
@@ -637,6 +637,7 @@
   Item_extract(interval_type type_arg, Item *a)
     :Item_int_func(a), int_type(type_arg) {}
   longlong val_int();
+  enum Functype functype() const { return EXTRACT_FUNC; }
   const char *func_name() const { return "extract"; }
   void fix_length_and_dec();
   bool eq(const Item *item, bool binary_cmp) const;
@@ -689,6 +690,7 @@
 public:
   Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
     :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
+  enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
   bool eq(const Item *item, bool binary_cmp) const;
   const char *func_name() const { return "cast_as_char"; }
   const char* cast_type() const { return "char"; };
@@ -790,6 +792,7 @@
     return (new Field_string(max_length, maybe_null, name, t_arg, &my_charset_bin));
   }
   void print(String *str);
+  const char *func_name() const { return "add_time"; }
 };
 
 class Item_func_timediff :public Item_str_func

--- 1.24/sql/item_uniq.h	2005-05-26 21:54:25 +04:00
+++ 1.25/sql/item_uniq.h	2005-06-16 19:43:07 +04:00
@@ -30,6 +30,7 @@
   double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
   void fix_length_and_dec() { decimals=0; max_length=6; }
   void print(String *str) { str->append("0.0", 3); }
+  const char *func_name() const { return "unique_users"; }
 };
 
 
@@ -58,4 +59,5 @@
   }
   void print(String *str) { str->append("0.0", 3); }
   Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
+  const char *func_name() const { return "sum_unique_users"; }
 };
Thread
bk commit into 5.0 tree (konstantin:1.1951) BUG#7015konstantin16 Jun