===== sql/item.h 1.212 vs edited ===== --- 1.212/sql/item.h 2007-01-24 18:32:06 +03:00 +++ edited/sql/item.h 2007-01-24 18:00:57 +03:00 @@ -323,13 +323,13 @@ class Name_resolution_context_state { private: TABLE_LIST *save_table_list; - TABLE_LIST *save_first_name_resolution_table; TABLE_LIST *save_next_name_resolution_table; bool save_resolve_in_select_list; public: Name_resolution_context_state() {} /* Remove gcc warning */ TABLE_LIST *save_next_local; + TABLE_LIST *save_first_name_resolution_table; public: /* Save the state of a name resolution context. */ ===== sql/sql_base.cc 1.356 vs edited ===== --- 1.356/sql/sql_base.cc 2007-01-24 18:32:06 +03:00 +++ edited/sql/sql_base.cc 2007-01-23 11:57:50 +03:00 @@ -4478,7 +4478,8 @@ bool setup_tables(THD *thd, Name_resolut Investigate all cases when this my happen, initialize the name resolution context correctly in all those places, and remove the context reset below. */ - if (!context->table_list || !context->first_name_resolution_table) + if ((!context->table_list || !context->first_name_resolution_table) && + !select_insert) { /* Test whether the context is in a consistent state. */ DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list); ===== sql/sql_insert.cc 1.206 vs edited ===== --- 1.206/sql/sql_insert.cc 2007-01-24 18:32:06 +03:00 +++ edited/sql/sql_insert.cc 2007-01-23 12:01:14 +03:00 @@ -967,17 +967,9 @@ bool mysql_prepare_insert(THD *thd, TABL select_lex->no_wrap_view_item= TRUE; res= check_update_fields(thd, context->table_list, update_fields); 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 (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; - } + + DBUG_ASSERT(!select_insert); + if (!res) res= setup_fields(thd, 0, update_values, 1, 0, 0); } @@ -2325,12 +2317,13 @@ select_insert::prepare(List &value 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) + if (lex->select_lex.group_list.elements == 0 && + !lex->select_lex.with_sum_func) { 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; + next_name_resolution_table= ctx_state.save_first_name_resolution_table; } res= res || setup_fields(thd, 0, *info.update_values, 1, 0, 0);