--- mysql-5.0.bk-orig/sql/item_sum.cc Sat Apr 7 12:23:32 2007 +++ mysql-5.0.bk/sql/item_sum.cc Thu Apr 12 22:42:02 2007 @@ -274,6 +274,19 @@ sl && sl != aggr_sel && sl->master_unit()->item; sl= sl->master_unit()->outer_select() ) sl->master_unit()->item->with_sum_func= 1; + + /* Add note for explain extended */ + if (thd->lex->describe & DESCRIBE_EXTENDED) + { + String printed_name; + (*ref)->full_name_or_print(&printed_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_WARN_FIELD_RESOLVED, + ER(ER_WARN_FIELD_RESOLVED), + printed_name.ptr(), "", "", "", "", + thd->lex->current_select->select_number, + aggr_sel->select_number); + } } thd->lex->current_select->mark_as_dependent(aggr_sel); return FALSE; --- mysql-5.0.bk-orig/sql/item.h Sat Apr 7 12:23:32 2007 +++ mysql-5.0.bk/sql/item.h Thu Apr 12 22:43:33 2007 @@ -617,6 +617,13 @@ /* This is also used to create fields in CREATE ... SELECT: */ virtual Field *tmp_table_field(TABLE *t_arg) { return 0; } virtual const char *full_name() const { return name ? name : "???"; } + void full_name_or_print(String *result) + { + if (name) + result->set(name, (uint32) name_length, &my_charset_bin); + else + print(result); + } /* *result* family of methods is analog of *val* family (see above) but