MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:eugene Date:October 14 2005 10:42pm
Subject:bk commit into 4.1 tree (evgen:1.2479) BUG#13392
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of evgen. When evgen 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.2479 05/10/15 02:42:02 evgen@stripped +3 -0
  Fix bug#13392 Wrong VALUES() behaviour in INSERT SELECT with ON DUPLICATE
  
  VALUES() can only refer to table insert going to. 
  But Item_insert_value::fix_fields() were passing to it's arg full table list,
  This results in finding second column which shouldn't be found, and
  failing with error about ambiguous field.
  
  Item_insert_value::fix_fields() now passes only first table of full table
  list.

  mysql-test/t/insert_select.test
    1.23 05/10/15 02:40:46 evgen@stripped +12 -0
    Test case for #13392 Wrong VALUES() behaviour in INSERT SELECT with ON DUPLICATE

  mysql-test/r/insert_select.result
    1.29 05/10/15 02:40:05 evgen@stripped +8 -0
    Test case for #13392 Wrong VALUES() behaviour in INSERT SELECT with ON DUPLICATE

  sql/item.cc
    1.227 05/10/15 02:39:37 evgen@stripped +7 -0
    Fix bug#13392 Wrong VALUES() behaviour in INSERT SELECT with ON DUPLICATE

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/13392-bug-4.1-mysql

--- 1.226/sql/item.cc	2005-10-13 19:48:56 +04:00
+++ 1.227/sql/item.cc	2005-10-15 02:39:37 +04:00
@@ -2796,8 +2796,14 @@
 				   Item **items)
 {
   DBUG_ASSERT(fixed == 0);
+  st_table_list *orig_next_table= table_list->next;
+  table_list->next= 0;
   if (!arg->fixed && arg->fix_fields(thd, table_list, &arg))
+  {
+    table_list->next= orig_next_table;
     return 1;
+  }
+  table_list->next= orig_next_table;
 
   if (arg->type() == REF_ITEM)
   {
@@ -2809,6 +2815,7 @@
     arg= ref->ref[0];
   }
   Item_field *field_arg= (Item_field *)arg;
+
   if (field_arg->field->table->insert_values)
   {
     Field *def_field= (Field*) sql_alloc(field_arg->field->size_of());

--- 1.28/mysql-test/r/insert_select.result	2005-09-10 02:29:28 +04:00
+++ 1.29/mysql-test/r/insert_select.result	2005-10-15 02:40:05 +04:00
@@ -678,3 +678,11 @@
 2001
 2002
 drop table t1;
+create table t1(x int, y int);
+create table t2(x int, z int);
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
+ERROR 42S22: Unknown column 'z' in 'field list'
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
+ERROR 42S02: Unknown table 't2' in field list
+drop table t1,t2;

--- 1.22/mysql-test/t/insert_select.test	2005-09-10 02:27:33 +04:00
+++ 1.23/mysql-test/t/insert_select.test	2005-10-15 02:40:46 +04:00
@@ -214,4 +214,16 @@
 select * from t1;
 drop table t1;
 
+#
+# Bug #13392 values() fails with 'ambiguous' or returns NULL 
+#            with ON DUPLICATE and SELECT
+create table t1(x int, y int);
+create table t2(x int, z int);
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
+--error 1054
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
+--error 1109
+insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
+drop table t1,t2; 
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (evgen:1.2479) BUG#13392eugene15 Oct