List:Commits« Previous MessageNext Message »
From:Lars Thalmann Date:February 28 2007 9:32pm
Subject:bk commit into 5.1 tree (lars:1.2467)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of lthalmann. When lthalmann 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@stripped, 2007-02-28 22:32:44+01:00, lars@stripped +4 -0
  Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
  into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge
  MERGE: 1.2455.1.10

  sql/field.cc@stripped, 2007-02-28 22:32:37+01:00, lars@stripped +0 -0
    Auto merged
    MERGE: 1.372.1.2

  sql/log.cc@stripped, 2007-02-28 22:32:38+01:00, lars@stripped +0 -0
    Auto merged
    MERGE: 1.253.1.4

  sql/mysql_priv.h@stripped, 2007-02-28 22:32:38+01:00, lars@stripped +0 -0
    Auto merged
    MERGE: 1.470.1.16

  sql/sql_insert.cc@stripped, 2007-02-28 22:32:39+01:00, lars@stripped +0 -0
    Auto merged
    MERGE: 1.248.1.2

# 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:	lars
# Host:	dl145k.mysql.com
# Root:	/nfsdisk1/lars/MERGE/mysql-5.1-merge/RESYNC

--- 1.374/sql/field.cc	2007-02-28 22:32:52 +01:00
+++ 1.375/sql/field.cc	2007-02-28 22:32:52 +01:00
@@ -6297,9 +6297,9 @@ int Field_string::cmp(const char *a_ptr,
 
 void Field_string::sort_string(char *to,uint length)
 {
-  uint tmp= my_strnxfrm(field_charset,
-                        (uchar*) to, length,
-                        (uchar*) ptr, field_length);
+  IF_DBUG(uint tmp=) my_strnxfrm(field_charset,
+                                 (uchar*) to, length,
+                                 (uchar*) ptr, field_length);
   DBUG_ASSERT(tmp == length);
 }
 

--- 1.262/sql/log.cc	2007-02-28 22:32:52 +01:00
+++ 1.263/sql/log.cc	2007-02-28 22:32:52 +01:00
@@ -1735,7 +1735,7 @@ void setup_windows_event_source()
 
   /* Register EventMessageFile */
   dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ,
-                          (PBYTE) szPath, strlen(szPath)+1);
+                          (PBYTE) szPath, (DWORD) (strlen(szPath) + 1));
 
   /* Register supported event types */
   dwTypes= (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |

--- 1.476/sql/mysql_priv.h	2007-02-28 22:32:53 +01:00
+++ 1.477/sql/mysql_priv.h	2007-02-28 22:32:53 +01:00
@@ -918,6 +918,8 @@ int setup_order(THD *thd, Item **ref_poi
 int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
 		List<Item> &fields, List<Item> &all_fields, ORDER *order,
 		bool *hidden_group_fields);
+bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
+                   Item **ref_pointer_array);
 
 bool handle_select(THD *thd, LEX *lex, select_result *result,
                    ulong setup_tables_done_option);

--- 1.252/sql/sql_insert.cc	2007-02-28 22:32:53 +01:00
+++ 1.253/sql/sql_insert.cc	2007-02-28 22:32:53 +01:00
@@ -984,6 +984,8 @@ bool mysql_prepare_insert(THD *thd, TABL
   DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
 		       (ulong)table_list, (ulong)table,
 		       (int)insert_into_view));
+  /* INSERT should have a SELECT or VALUES clause */
+  DBUG_ASSERT (!select_insert || !values);
 
   /*
     For subqueries in VALUES() we should not see the table in which we are
@@ -1015,44 +1017,40 @@ bool mysql_prepare_insert(THD *thd, TABL
   if (mysql_prepare_insert_check_table(thd, table_list, fields, select_insert))
     DBUG_RETURN(TRUE);
 
-  /* Save the state of the current name resolution context. */
-  ctx_state.save_state(context, table_list);
-
-  /*
-    Perform name resolution only in the first table - 'table_list',
-    which is the table that is inserted into.
-  */
-  table_list->next_local= 0;
-  context->resolve_in_table_list_only(table_list);
 
   /* Prepare the fields in the statement. */
-  if (values &&
-      !(res= check_insert_fields(thd, context->table_list, fields, *values,
-                                 !insert_into_view, &map) ||
-        setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) &&
-      duplic == DUP_UPDATE)
+  if (values)
   {
-    select_lex->no_wrap_view_item= TRUE;
-    res= check_update_fields(thd, context->table_list, update_fields, &map);
-    select_lex->no_wrap_view_item= FALSE;
+    /* if we have INSERT ... VALUES () we cannot have a GROUP BY clause */
+    DBUG_ASSERT (!select_lex->group_list.elements);
+
+    /* Save the state of the current name resolution context. */
+    ctx_state.save_state(context, table_list);
+
     /*
-      When we are not using GROUP BY we can refer to other tables in the
-      ON DUPLICATE KEY part.
-    */       
-    if (select_lex->group_list.elements == 0)
-    {
-      context->table_list->next_local=       ctx_state.save_next_local;
-      /* first_name_resolution_table was set by resolve_in_table_list_only() */
-      context->first_name_resolution_table->
-        next_name_resolution_table=          ctx_state.save_next_local;
+      Perform name resolution only in the first table - 'table_list',
+      which is the table that is inserted into.
+     */
+    table_list->next_local= 0;
+    context->resolve_in_table_list_only(table_list);
+
+    if (!(res= check_insert_fields(thd, context->table_list, fields, *values,
+                                 !insert_into_view, &map) ||
+          setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) 
+        && duplic == DUP_UPDATE)
+    {
+      select_lex->no_wrap_view_item= TRUE;
+      res= check_update_fields(thd, context->table_list, update_fields, &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);
   }
 
-  /* Restore the current context. */
-  ctx_state.restore_state(context, table_list);
-
   if (res)
     DBUG_RETURN(res);
 
@@ -2508,7 +2506,6 @@ select_insert::prepare(List<Item> &value
 
   if (info.handle_duplicates == DUP_UPDATE)
   {
-    /* Save the state of the current name resolution context. */
     Name_resolution_context *context= &lex->select_lex.context;
     Name_resolution_context_state ctx_state;
 
@@ -2524,18 +2521,40 @@ select_insert::prepare(List<Item> &value
                                     *info.update_fields, &map);
     lex->select_lex.no_wrap_view_item= FALSE;
     /*
-      When we are not using GROUP BY we can refer to other tables in the
-      ON DUPLICATE KEY part
-    */       
-    if (lex->select_lex.group_list.elements == 0)
-    {
-      context->table_list->next_local=       ctx_state.save_next_local;
-      /* first_name_resolution_table was set by resolve_in_table_list_only() */
-      context->first_name_resolution_table->
-        next_name_resolution_table=          ctx_state.save_next_local;
+      When we are not using GROUP BY and there are no ungrouped aggregate functions 
+      we can refer to other tables in the ON DUPLICATE KEY part.
+      We use next_name_resolution_table descructively, so check it first (views?)
+    */
+    DBUG_ASSERT (!table_list->next_name_resolution_table);
+    if (lex->select_lex.group_list.elements == 0 &&
+        !lex->select_lex.with_sum_func)
+      /*
+        We must make a single context out of the two separate name resolution contexts :
+        the INSERT table and the tables in the SELECT part of INSERT ... SELECT.
+        To do that we must concatenate the two lists
+      */  
+      table_list->next_name_resolution_table= 
+        ctx_state.get_first_name_resolution_table();
+
+    res= res || setup_fields(thd, 0, *info.update_values,
+                             MARK_COLUMNS_READ, 0, 0);
+    if (!res)
+    {
+      /*
+        Traverse the update values list and substitute fields from the
+        select for references (Item_ref objects) to them. This is done in
+        order to get correct values from those fields when the select
+        employs a temporary table.
+      */
+      List_iterator<Item> li(*info.update_values);
+      Item *item;
+
+      while ((item= li++))
+      {
+        item->transform(&Item::update_value_transformer,
+                        (byte*)lex->current_select);
+      }
     }
-    res= res || setup_fields(thd, 0, *info.update_values, MARK_COLUMNS_READ,
-                             0, 0);
 
     /* Restore the current context. */
     ctx_state.restore_state(context, table_list);
Thread
bk commit into 5.1 tree (lars:1.2467)Lars Thalmann28 Feb