MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Evgeny Potemkin Date:October 20 2009 7:32am
Subject:bzr commit into mysql-5.5.0-next-mr-bugfixing branch (epotemkin:2906)
Bug#41760
View as plain text  
#At file:///work/bzrroot/mysql-next-mr-bugfixing/ based on revid:guilhem@stripped

 2906 Evgeny Potemkin	2009-10-20 [merge]
      Auto-merged fix for the bug#41760.

    modified:
      mysql-test/r/delayed.result
      mysql-test/r/insert.result
      mysql-test/t/delayed.test
      mysql-test/t/insert.test
      sql/sql_insert.cc
=== modified file 'mysql-test/r/delayed.result'
--- a/mysql-test/r/delayed.result	2009-02-03 17:16:24 +0000
+++ b/mysql-test/r/delayed.result	2009-10-20 07:30:41 +0000
@@ -252,7 +252,7 @@ HEX(a)
 DROP TABLE t1;
 CREATE TABLE t1 (a INT);
 INSERT DELAYED INTO t1 SET b= b();
-ERROR 42S22: Unknown column 'b' in 'field list'
+ERROR 42000: FUNCTION test.b does not exist
 DROP TABLE t1;
 End of 5.0 tests
 DROP TABLE IF EXISTS t1,t2;

=== modified file 'mysql-test/r/insert.result'
--- a/mysql-test/r/insert.result	2009-07-10 23:12:13 +0000
+++ b/mysql-test/r/insert.result	2009-10-20 07:30:41 +0000
@@ -355,17 +355,17 @@ insert into t2 values (1,12), (2,24);
 insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
 ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
+ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
 select * from t1;
 f1	f2
 1	11
 2	22
-3	NULL
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
+ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
 select * from t1;
 f1	f2
 1	11
 2	22
-12	NULL
 drop view v1;
 drop table t1,t2;
 create table t1 (id int primary key auto_increment, data int, unique(data));

=== modified file 'mysql-test/t/delayed.test'
--- a/mysql-test/t/delayed.test	2009-02-03 17:16:24 +0000
+++ b/mysql-test/t/delayed.test	2009-10-20 07:30:41 +0000
@@ -247,7 +247,7 @@ DROP TABLE t1;
 # Bug #32676: insert delayed crash with wrong column and function specified
 #
 CREATE TABLE t1 (a INT);
---error  ER_BAD_FIELD_ERROR
+--error 1305
 INSERT DELAYED INTO t1 SET b= b();
 DROP TABLE t1;
 

=== modified file 'mysql-test/t/insert.test'
--- a/mysql-test/t/insert.test	2009-07-10 23:12:13 +0000
+++ b/mysql-test/t/insert.test	2009-10-20 07:30:41 +0000
@@ -235,8 +235,10 @@ insert into t1 values (1,11), (2,22);
 insert into t2 values (1,12), (2,24);
 --error 1393
 insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
+--error 1393
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
 select * from t1;
+--error 1393
 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
 select * from t1;
 drop view v1;

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2009-09-30 15:40:12 +0000
+++ b/sql/sql_insert.cc	2009-10-20 07:30:41 +0000
@@ -107,8 +107,8 @@ static bool check_view_insertability(THD
     1   Error
 */
 
-bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
-                              table_map *map)
+bool check_view_single_update(List<Item> &fields, List<Item> *values,
+                              TABLE_LIST *view, table_map *map)
 {
   /* it is join view => we need to find the table for update */
   List_iterator_fast<Item> it(fields);
@@ -119,6 +119,17 @@ bool check_view_single_update(List<Item>
   while ((item= it++))
     tables|= item->used_tables();
 
+  if (values)
+  {
+    it.init(*values);
+    while ((item= it++))
+      tables|= item->used_tables();
+  }
+
+  /* Convert to real table bits */
+  tables&= ~PSEUDO_TABLE_BITS;
+
+
   /* Check found map against provided map */
   if (*map)
   {
@@ -165,7 +176,9 @@ error:
 
 static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
                                List<Item> &fields, List<Item> &values,
-                               bool check_unique, table_map *map)
+                               bool check_unique,
+                               bool fields_and_values_from_different_maps,
+                               table_map *map)
 {
   TABLE *table= table_list->table;
 
@@ -238,7 +251,10 @@ static int check_insert_fields(THD *thd,
 
     if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
     {
-      if (check_view_single_update(fields, table_list, map))
+      if (check_view_single_update(fields,
+                                   fields_and_values_from_different_maps ?
+                                   (List<Item>*) 0 : &values,
+                                   table_list, map))
         return -1;
       table= table_list->table;
     }
@@ -298,7 +314,8 @@ static int check_insert_fields(THD *thd,
 */
 
 static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
-                               List<Item> &update_fields, table_map *map)
+                               List<Item> &update_fields,
+                               List<Item> &update_values, table_map *map)
 {
   TABLE *table= insert_table_list->table;
   my_bool timestamp_mark= 0;
@@ -318,7 +335,8 @@ static int check_update_fields(THD *thd,
     return -1;
 
   if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
-      check_view_single_update(update_fields, insert_table_list, map))
+      check_view_single_update(update_fields, &update_values,
+                               insert_table_list, map))
     return -1;
 
   if (table->timestamp_field)
@@ -1242,9 +1260,9 @@ bool mysql_prepare_insert(THD *thd, TABL
     table_list->next_local= 0;
     context->resolve_in_table_list_only(table_list);
 
-    res= check_insert_fields(thd, context->table_list, fields, *values,
-                             !insert_into_view, &map) ||
-      setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0);
+    res= (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0) ||
+          check_insert_fields(thd, context->table_list, fields, *values,
+                              !insert_into_view, 0, &map));
 
     if (!res && check_fields)
     {
@@ -1257,18 +1275,19 @@ bool mysql_prepare_insert(THD *thd, TABL
       thd->abort_on_warning= saved_abort_on_warning;
     }
 
+   if (!res)
+     res= setup_fields(thd, 0, update_values, MARK_COLUMNS_READ, 0, 0);
+
     if (!res && duplic == DUP_UPDATE)
     {
       select_lex->no_wrap_view_item= TRUE;
-      res= check_update_fields(thd, context->table_list, update_fields, &map);
+      res= check_update_fields(thd, context->table_list, update_fields,
+                               update_values, &map);
       select_lex->no_wrap_view_item= FALSE;
     }
 
     /* Restore the current context. */
     ctx_state.restore_state(context, table_list);
-
-    if (!res)
-      res= setup_fields(thd, 0, update_values, MARK_COLUMNS_READ, 0, 0);
   }
 
   if (res)
@@ -2931,9 +2950,9 @@ select_insert::prepare(List<Item> &value
     we are fixing fields from insert list.
   */
   lex->current_select= &lex->select_lex;
-  res= check_insert_fields(thd, table_list, *fields, values,
-                           !insert_into_view, &map) ||
-       setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0);
+  res= (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0) ||
+        check_insert_fields(thd, table_list, *fields, values,
+                            !insert_into_view, 1, &map));
 
   if (!res && fields->elements)
   {
@@ -2960,7 +2979,8 @@ select_insert::prepare(List<Item> &value
 
     lex->select_lex.no_wrap_view_item= TRUE;
     res= res || check_update_fields(thd, context->table_list,
-                                    *info.update_fields, &map);
+                                    *info.update_fields, *info.update_values,
+                                    &map);
     lex->select_lex.no_wrap_view_item= FALSE;
     /*
       When we are not using GROUP BY and there are no ungrouped aggregate functions 


Attachment: [text/bzr-bundle] bzr/epotemkin@mysql.com-20091020073238-kmwrtl2zl61v4zys.bundle
Thread
bzr commit into mysql-5.5.0-next-mr-bugfixing branch (epotemkin:2906)Bug#41760Evgeny Potemkin20 Oct