List:Internals« Previous MessageNext Message »
From:sinisa Date:May 4 2004 8:04pm
Subject:bk commit into 4.1 tree (Sinisa:1.1807)
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of Sinisa. When Sinisa 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1807 04/05/04 23:04:05 Sinisa@stripped +3 -0
  Fix for a multi table updates when one of the tables is not updated
  but used in a nested query.

  sql/sql_update.cc
    1.122 04/05/04 23:03:59 Sinisa@stripped +6 -5
    Fix for a multi table updates when one of the tables is not updated
    but used in a nested query.

  mysql-test/t/multi_update.test
    1.36 04/05/04 23:03:59 Sinisa@stripped +4 -0
    Fix for a multi table updates when one of the tables is not updated
    but used in a nested query.

  mysql-test/r/multi_update.result
    1.35 04/05/04 23:03:59 Sinisa@stripped +1 -0
    Fix for a multi table updates when one of the tables is not updated
    but used in a nested query.

# 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:	Sinisa
# Host:	sinisa.nasamreza.org
# Root:	/mnt/work/mysql-4.1

--- 1.121/sql/sql_update.cc	Sat Apr 10 01:14:29 2004
+++ 1.122/sql/sql_update.cc	Tue May  4 23:03:59 2004
@@ -578,7 +578,7 @@
 int multi_update::prepare(List<Item> &not_used_values,
 			  SELECT_LEX_UNIT *lex_unit)
 {
-  TABLE_LIST *table_ref;
+  TABLE_LIST *table_ref, *tables;
   SQL_LIST update;
   table_map tables_to_update= 0;
   Item_field *item;
@@ -604,8 +604,9 @@
     We have to check values after setup_tables to get used_keys right in
     reference tables
   */
+  tables= thd->lex->select_lex.get_table_list();
 
-  if (setup_fields(thd, 0, all_tables, *values, 1, 0, 0))
+  if (setup_fields(thd, 0, tables, *values, 1, 0, 0))
     DBUG_RETURN(1);
 
   /*
@@ -615,7 +616,7 @@
   */
 
   update.empty();
-  for (table_ref= all_tables;  table_ref; table_ref=table_ref->next)
+  for (table_ref= tables;  table_ref; table_ref=table_ref->next)
   {
     TABLE *table=table_ref->table;
     if (tables_to_update & table->map)
@@ -684,10 +685,10 @@
     which will cause an error when reading a row.
     (This issue is mostly relevent for MyISAM tables)
   */
-  for (table_ref= all_tables;  table_ref; table_ref=table_ref->next)
+  for (table_ref= tables;  table_ref; table_ref=table_ref->next)
   {
     TABLE *table=table_ref->table;
-    if (!(tables_to_update & table->map) && 
+    if (!(tables_to_update & table->map) || !table->no_keyread && 
 	find_real_table_in_list(update_tables, table_ref->db,
 				table_ref->real_name))
       table->no_cache= 1;			// Disable row cache

--- 1.34/mysql-test/r/multi_update.result	Thu Apr  8 00:16:11 2004
+++ 1.35/mysql-test/r/multi_update.result	Tue May  4 23:03:59 2004
@@ -324,6 +324,7 @@
 7	7
 8	8
 9	9
+update t1,t2 set t1.b=t2.b, t1.a=t2.a where t1.a=t2.a and not exists (select * from t2 where t2.a > 10);
 drop table t1,t2;
 CREATE TABLE t3 (  KEY1 varchar(50) NOT NULL default '',  PARAM_CORR_DISTANCE_RUSH double default NULL,  PARAM_CORR_DISTANCE_GEM double default NULL,  PARAM_AVG_TARE double default NULL,  PARAM_AVG_NB_DAYS double default NULL,  PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL,  PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL,  PARAM_SCENARIO_COSTS varchar(50) default NULL,  PARAM_DEFAULT_WAGON_COST double default NULL,  tmp int(11) default NULL,  PRIMARY KEY  (KEY1)) ENGINE=MyISAM;
 INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);

--- 1.35/mysql-test/t/multi_update.test	Thu Apr  8 00:16:11 2004
+++ 1.36/mysql-test/t/multi_update.test	Tue May  4 23:03:59 2004
@@ -260,6 +260,10 @@
 select * from t1;
 select * from t2;
 
+# test for non-updating table which is also used in sub-select
+
+update t1,t2 set t1.b=t2.b, t1.a=t2.a where t1.a=t2.a and not exists (select * from t2 where t2.a > 10);
+
 drop table t1,t2;
 CREATE TABLE t3 (  KEY1 varchar(50) NOT NULL default '',  PARAM_CORR_DISTANCE_RUSH double default NULL,  PARAM_CORR_DISTANCE_GEM double default NULL,  PARAM_AVG_TARE double default NULL,  PARAM_AVG_NB_DAYS double default NULL,  PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL,  PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL,  PARAM_SCENARIO_COSTS varchar(50) default NULL,  PARAM_DEFAULT_WAGON_COST double default NULL,  tmp int(11) default NULL,  PRIMARY KEY  (KEY1)) ENGINE=MyISAM;
 INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);
Thread
bk commit into 4.1 tree (Sinisa:1.1807)sinisa4 May