List:Internals« Previous MessageNext Message »
From:Sergey Petrunia Date:April 18 2005 3:21am
Subject:bk commit into 4.1 tree (sergefp:1.2195) BUG#9103
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of psergey. When psergey 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.2195 05/04/18 05:21:44 sergefp@stripped +5 -0
  Fix for BUG#9103: 
  Don't produce data truncation warnings from within cp_buffer_from_ref(). This function
  is only used to make index search tuples and data truncation that occurs here has no
  relation with truncated values being saved into tables.

  sql/sql_select.h
    1.74 05/04/18 05:21:41 sergefp@stripped +1 -1
    cp_buffer_from_ref now has THD* parameter

  sql/sql_select.cc
    1.395 05/04/18 05:21:41 sergefp@stripped +13 -6
    Fix for BUG#9103: 
    Don't produce data truncation warnings from within cp_buffer_from_ref(). This function
    is only used to make index search tuples and data truncation that occurs here has no
    relation with truncated values being saved into tables.

  sql/opt_range.cc
    1.134 05/04/18 05:21:41 sergefp@stripped +1 -1
    cp_buffer_from_ref now has THD* parameter

  mysql-test/t/update.test
    1.19 05/04/18 05:21:41 sergefp@stripped +12 -0
    Testcase for BUG#9103

  mysql-test/r/update.result
    1.22 05/04/18 05:21:40 sergefp@stripped +14 -0
    Testcase for BUG#9103

# 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:	sergefp
# Host:	newbox.mylan
# Root:	/home/psergey/mysql-4.1-bug9103

--- 1.133/sql/opt_range.cc	2005-04-17 02:05:06 +04:00
+++ 1.134/sql/opt_range.cc	2005-04-18 05:21:41 +04:00
@@ -2574,7 +2574,7 @@
 
   if (!quick)
     return 0;			/* no ranges found */
-  if (cp_buffer_from_ref(ref))
+  if (cp_buffer_from_ref(thd, ref))
   {
     if (thd->is_fatal_error)
       goto err;					// out of memory

--- 1.394/sql/sql_select.cc	2005-04-07 17:47:36 +04:00
+++ 1.395/sql/sql_select.cc	2005-04-18 05:21:41 +04:00
@@ -6185,7 +6185,7 @@
   TABLE *table= tab->table;
   if (table->status & STATUS_GARBAGE)		// If first read
   {
-    if (cp_buffer_from_ref(&tab->ref))
+    if (cp_buffer_from_ref(tab->join->thd, &tab->ref))
       error=HA_ERR_KEY_NOT_FOUND;
     else
     {
@@ -6248,7 +6248,7 @@
 
   if (!table->file->inited)
     table->file->ha_index_init(tab->ref.key);
-  if (cp_buffer_from_ref(&tab->ref))
+  if (cp_buffer_from_ref(tab->join->thd, &tab->ref))
     return -1;
   if ((error=table->file->index_read(table->record[0],
 				     tab->ref.key_buff,
@@ -6275,7 +6275,7 @@
 
   if (!table->file->inited)
     table->file->ha_index_init(tab->ref.key);
-  if (cp_buffer_from_ref(&tab->ref))
+  if (cp_buffer_from_ref(tab->join->thd, &tab->ref))
     return -1;
   if ((error=table->file->index_read_last(table->record[0],
 					  tab->ref.key_buff,
@@ -6449,7 +6449,7 @@
   if (!table->file->inited)
     table->file->ha_index_init(tab->ref.key);
 #if NOT_USED_YET
-  if (cp_buffer_from_ref(&tab->ref))       // as ft-key doesn't use store_key's
+  if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) // as ft-key doesn't
use store_key's
     return -1;                             // see also FT_SELECT::init()
 #endif
   table->file->ft_init();
@@ -8168,7 +8168,8 @@
   {
     memcpy(tab->ref.key_buff2, tab->ref.key_buff, tab->ref.key_length);
   }
-  if ((tab->ref.key_err=cp_buffer_from_ref(&tab->ref)) || diff)
+  if ((tab->ref.key_err= cp_buffer_from_ref(tab->join->thd, &tab->ref))
|| 
+      diff)
     return 1;
   return memcmp(tab->ref.key_buff2, tab->ref.key_buff, tab->ref.key_length)
     != 0;
@@ -8176,11 +8177,17 @@
 
 
 bool
-cp_buffer_from_ref(TABLE_REF *ref)
+cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
 {
+  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())
+    {
+      thd->count_cuted_fields= save_count_cuted_fields;
       return 1;					// Something went wrong
+    }
+  thd->count_cuted_fields= save_count_cuted_fields;
   return 0;
 }
 

--- 1.73/sql/sql_select.h	2005-04-05 02:42:20 +04:00
+++ 1.74/sql/sql_select.h	2005-04-18 05:21:41 +04:00
@@ -445,7 +445,7 @@
   const char *name() const { return "const"; }
 };
 
-bool cp_buffer_from_ref(TABLE_REF *ref);
+bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref);
 bool error_if_full_join(JOIN *join);
 int report_error(TABLE *table, int error);
 int safe_index_read(JOIN_TAB *tab);

--- 1.21/mysql-test/r/update.result	2005-03-17 09:59:24 +03:00
+++ 1.22/mysql-test/r/update.result	2005-04-18 05:21:40 +04:00
@@ -226,3 +226,17 @@
 a	b
 0	2
 drop table t1;
+create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam;
+create table t2 (a int, b varchar(10)) engine=myisam;
+insert into t1 values ( 1, 'abcd1e');
+insert into t1 values ( 2, 'abcd2e');
+insert into t2 values ( 1, 'abcd1e');
+insert into t2 values ( 2, 'abcd2e');
+analyze table t1,t2;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+test.t2	analyze	status	OK
+update t1, t2 set t1.a = t2.a where t2.b = t1.b;
+show warnings;
+Level	Code	Message
+drop table t1, t2;

--- 1.18/mysql-test/t/update.test	2005-03-17 09:59:24 +03:00
+++ 1.19/mysql-test/t/update.test	2005-04-18 05:21:41 +04:00
@@ -189,3 +189,15 @@
 update t1 set b = b + 1 where a = 0;
 select * from t1;
 drop table t1;
+
+# BUG#9103 "Erroneous data truncation warnings on multi-table updates"
+create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam;
+create table t2 (a int, b varchar(10)) engine=myisam;
+insert into t1 values ( 1, 'abcd1e');
+insert into t1 values ( 2, 'abcd2e');
+insert into t2 values ( 1, 'abcd1e');
+insert into t2 values ( 2, 'abcd2e');
+analyze table t1,t2;
+update t1, t2 set t1.a = t2.a where t2.b = t1.b;
+show warnings;
+drop table t1, t2;
Thread
bk commit into 4.1 tree (sergefp:1.2195) BUG#9103Sergey Petrunia18 Apr