--- 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_AGGREGATE_RESOLVED, + ER(ER_WARN_AGGREGATE_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 --- mysql-5.0.bk-orig/sql/share/errmsg.txt Fri Feb 23 16:36:00 2007 +++ mysql-5.0.bk/sql/share/errmsg.txt Thu Apr 12 22:40:36 2007 @@ -5633,4 +5633,6 @@ eng "String '%-.70s' is too long for %s (should be no longer than %d)" ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" - +ER_WARN_AGGREGATE_RESOLVED + eng "Aggregate function '%s' of SELECT #%d will be aggregated in SELECT #%d" + ger "Aggregate Funktion '%s' im SELECT-Befehl Nr. %d wird im SELECT-Befehl Nr. %d aggregiert"