List:Internals« Previous MessageNext Message »
From:igor Date:June 23 2005 3:15pm
Subject:bk commit into 4.1 tree (igor:1.2311) BUG#10124
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of igor. When igor 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.2311 05/06/23 06:15:50 igor@stripped +6 -0
  func_str.result, func_str.test:
    Added a test case for bug #10124.
  sql_select.h, item_subselect.cc, sql_select.cc:
    Fixed bug #10124.
    The copy method of the store_key classes can return
    STORE_KEY_OK=0, STORE_KEY_FATAL=1, STORE_KEY_CONV=2 now.
  field.cc:
    Fixed bug #10124.
    When ussuing a warning the store methods return 2 instead of 1 now.

  mysql-test/r/func_str.result
    1.92 05/06/23 06:14:53 igor@stripped +11 -0
    Added a test case for bug #10124.

  mysql-test/t/func_str.test
    1.73 05/06/23 06:14:28 igor@stripped +14 -0
    Added a test case for bug #10124.

  sql/sql_select.h
    1.76 05/06/23 06:13:38 igor@stripped +16 -9
    Fixed bug #10124.
    The copy method of the store_key classes can return
    STORE_KEY_OK=0, STORE_KEY_FATAL=1, STORE_KEY_CONV=2 now.

  sql/item_subselect.cc
    1.137 05/06/23 06:12:58 igor@stripped +2 -2
    Fixed bug #10124.
    The copy method of the store_key classes can return
    STORE_KEY_OK=0, STORE_KEY_FATAL=1, STORE_KEY_CONV=2 now.

  sql/sql_select.cc
    1.414 05/06/23 06:12:12 igor@stripped +6 -2
    Fixed bug #10124.
    The copy method of the store_key classes can return
    STORE_KEY_OK=0, STORE_KEY_FATAL=1, STORE_KEY_CONV=2 now.

  sql/field.cc
    1.221 05/06/23 06:10:48 igor@stripped +24 -17
    Fixed bug #10124.
    When ussuing a warning the store methods return 2 instead of 1 now.

# 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:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-4.1-1

--- 1.220/sql/field.cc	Sun Jun  5 10:38:38 2005
+++ 1.221/sql/field.cc	Thu Jun 23 06:10:48 2005
@@ -2473,7 +2473,10 @@
   if (error ||
       (from+len != end && table->in_use->count_cuted_fields &&
        !test_if_int(from,len,end,cs)))
-    error= 1;
+  {
+    if (error != 1)
+      error= 2;
+  }
 #if SIZEOF_LONG > 4
   if (unsigned_flag)
   {
@@ -2501,10 +2504,7 @@
   }
 #endif
   if (error)
-  {
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
-    error= 1;
-  }
 #ifdef WORDS_BIGENDIAN
   if (table->db_low_byte_first)
   {
@@ -2770,8 +2770,11 @@
       (from+len != end && table->in_use->count_cuted_fields &&
        !test_if_int(from,len,end,cs)))
   {
-    set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
-    error= 1;
+    if (error != 1)
+    {
+      set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
+      error= 2;
+    }
   }
 #ifdef WORDS_BIGENDIAN
   if (table->db_low_byte_first)
@@ -2991,7 +2994,7 @@
   double nr= my_strntod(cs,(char*) from,len,&end,&error);
   if (error || ((uint) (end-from) != len &&
table->in_use->count_cuted_fields))
   {
-    error= 1;
+    error= 2;
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
   }
   Field_float::store(nr);
@@ -3277,7 +3280,7 @@
   double nr= my_strntod(cs,(char*) from, len, &end, &error);
   if (error || ((uint) (end-from) != len &&
table->in_use->count_cuted_fields))
   {
-    error= 1;
+    error= 2;
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
   }
   Field_double::store(nr);
@@ -3659,6 +3662,8 @@
       error= 1;
     }
   }
+  if (error > 1)
+    error= 2;
 
 #ifdef WORDS_BIGENDIAN
   if (table->db_low_byte_first)
@@ -3947,7 +3952,7 @@
   if (str_to_time(from, len, &ltime, &error))
   {
     tmp=0L;
-    error= 1;
+    error= 2;
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
                          from, len, MYSQL_TIMESTAMP_TIME, 1);
   }
@@ -3969,6 +3974,8 @@
                            from, len, MYSQL_TIMESTAMP_TIME, !error);
       error= 1;
     }
+    if (error > 1)
+      error= 2;
   }
   
   if (ltime.neg)
@@ -4298,7 +4305,7 @@
   if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR)
   {
     tmp=0;
-    error= 1;
+    error= 2;
   }
   else
     tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
@@ -4489,7 +4496,7 @@
   if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR)
   {
     tmp=0L;
-    error= 1;
+    error= 2;
   }
   else
     tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
@@ -4931,7 +4938,7 @@
     from= tmpstr.ptr();
     length=  tmpstr.length();
     if (conv_errors)
-      error= 1;
+      error= 2;
   }
 
   /* 
@@ -4955,7 +4962,7 @@
     from+= field_charset->cset->scan(field_charset, from, end,
 				     MY_SEQ_SPACES);
     if (from != end)
-      error= 1;
+      error= 2;
   }
   if (error)
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
@@ -5210,12 +5217,12 @@
     from= tmpstr.ptr();
     length=  tmpstr.length();
     if (conv_errors)
-      error= 1;
+      error= 2;
   }
   if (length > field_length)
   {
     length=field_length;
-    error= 1;
+    error= 2;
   }
   if (error)
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
@@ -5568,7 +5575,7 @@
       from= tmpstr.ptr();
       length=  tmpstr.length();
       if (conv_errors)
-        error= 1;
+        error= 2;
     }
     
     copy_length= max_data_length();
@@ -5583,7 +5590,7 @@
                                                       copy_length,
                                                       &well_formed_error);
     if (copy_length < length)
-      error= 1;
+      error= 2;
     Field_blob::store_length(copy_length);
     if (was_conversion || table->copy_blobs || copy_length <= MAX_FIELD_WIDTH)
     {						// Must make a copy

--- 1.413/sql/sql_select.cc	Mon Jun 20 06:13:23 2005
+++ 1.414/sql/sql_select.cc	Thu Jun 23 06:12:12 2005
@@ -8223,11 +8223,15 @@
   enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;
   for (store_key **copy=ref->key_copy ; *copy ; copy++)
-    if ((*copy)->copy())
+  {
+    int res;
+    if ((res= (*copy)->copy()))
     {
       thd->count_cuted_fields= save_count_cuted_fields;
-      return 1;					// Something went wrong
+      if ((res= res & 1))
+        return res;                               // Something went wrong
     }
+  }
   thd->count_cuted_fields= save_count_cuted_fields;
   return 0;
 }

--- 1.75/sql/sql_select.h	Wed May  4 06:05:53 2005
+++ 1.76/sql/sql_select.h	Thu Jun 23 06:13:38 2005
@@ -356,6 +356,7 @@
   char *null_ptr;
   char err;
  public:
+  enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
   store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
     :null_ptr(null),err(0)
   {
@@ -371,7 +372,7 @@
     }
   }
   virtual ~store_key() {}			/* Not actually needed */
-  virtual bool copy()=0;
+  virtual enum store_key_result copy()=0;
   virtual const char *name() const=0;
 };
 
@@ -392,10 +393,10 @@
       copy_field.set(to_field,from_field,0);
     }
   }
-  bool copy()
+  enum store_key_result copy()
   {
     copy_field.do_copy(&copy_field);
-    return err != 0;
+    return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
   }
   const char *name() const { return field_name; }
 };
@@ -412,9 +413,11 @@
 	       null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
 	       &err : NullS, length), item(item_arg)
   {}
-  bool copy()
+  enum store_key_result copy()
   {
-    return item->save_in_field(to_field, 1) || err != 0;
+    int res= item->save_in_field(to_field, 1);
+    return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res); 
+	                 
   }
   const char *name() const { return "func"; }
 };
@@ -432,15 +435,19 @@
 		    &err : NullS, length, item_arg), inited(0)
   {
   }
-  bool copy()
+  enum store_key_result copy()
   {
+    int res;
     if (!inited)
     {
       inited=1;
-      if (item->save_in_field(to_field, 1))
-	err= 1;
+      if ((res= item->save_in_field(to_field, 1)))
+      {       
+        if (!err)
+          err= res;
+      }
     }
-    return err != 0;
+    return (err > 2 ?  STORE_KEY_FATAL : (store_key_result) err);
   }
   const char *name() const { return "const"; }
 };

--- 1.136/sql/item_subselect.cc	Sun Jun  5 10:38:40 2005
+++ 1.137/sql/item_subselect.cc	Thu Jun 23 06:12:58 2005
@@ -1361,7 +1361,7 @@
   TABLE *table= tab->table;
   for (store_key **copy=tab->ref.key_copy ; *copy ; copy++)
   {
-    if (tab->ref.key_err= (*copy)->copy())
+    if ((tab->ref.key_err= (*copy)->copy()) & 1)
     {
       table->status= STATUS_NOT_FOUND;
       DBUG_RETURN(1);
@@ -1414,7 +1414,7 @@
 
   for (store_key **copy=tab->ref.key_copy ; *copy ; copy++)
   {
-    if (tab->ref.key_err= (*copy)->copy())
+    if ((tab->ref.key_err= (*copy)->copy()) & 1)
     {
       table->status= STATUS_NOT_FOUND;
       DBUG_RETURN(1);

--- 1.91/mysql-test/r/func_str.result	Wed Jun  1 09:48:22 2005
+++ 1.92/mysql-test/r/func_str.result	Thu Jun 23 06:14:53 2005
@@ -789,3 +789,14 @@
 select field(NULL,1,2,NULL), field(NULL,1,2,0);
 field(NULL,1,2,NULL)	field(NULL,1,2,0)
 0	0
+CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
+CREATE TABLE t2 (num int primary key);
+INSERT INTO t1 VALUES ('notnumber');
+INSERT INTO t2 VALUES (0), (1);
+SELECT * FROM t1, t2 WHERE num=str;
+str	num
+notnumber	0
+SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
+str	num
+notnumber	0
+DROP TABLE t1,t2;

--- 1.72/mysql-test/t/func_str.test	Wed Jun  1 09:48:22 2005
+++ 1.73/mysql-test/t/func_str.test	Thu Jun 23 06:14:28 2005
@@ -527,3 +527,17 @@
 #
 select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
 select field(NULL,1,2,NULL), field(NULL,1,2,0);
+
+#
+# Bug #10124: access by integer index with a string key that is not a number  
+#
+
+CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
+CREATE TABLE t2 (num int primary key);
+INSERT INTO t1 VALUES ('notnumber');
+INSERT INTO t2 VALUES (0), (1); 
+
+SELECT * FROM t1, t2 WHERE num=str;
+SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
+
+DROP TABLE t1,t2;
Thread
bk commit into 4.1 tree (igor:1.2311) BUG#10124igor23 Jun