diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 5 | ||||
-rw-r--r-- | sql/table.cc | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7ebdc90f8b3..6e6611d54d2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4588,6 +4588,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, */ arena= thd->activate_stmt_arena_if_needed(&backup); + thd->lex->current_select->cur_pos_in_select_list= 0; while (wild_num && (item= it++)) { if (item->type() == Item::FIELD_ITEM && @@ -4629,7 +4630,10 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, } wild_num--; } + else + thd->lex->current_select->cur_pos_in_select_list++; } + thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS; if (arena) { /* make * substituting permanent */ @@ -5134,6 +5138,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, item->walk(&Item::reset_query_id_processor, (byte *)(&thd->query_id)); } + thd->lex->current_select->cur_pos_in_select_list++; } /* In case of stored tables, all fields are considered as used, diff --git a/sql/table.cc b/sql/table.cc index 6d13514e782..fb2012a79d1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2670,7 +2670,16 @@ const char *Field_iterator_table::name() Item *Field_iterator_table::create_item(THD *thd) { - return new Item_field(thd, &thd->lex->current_select->context, *ptr); + SELECT_LEX *select= thd->lex->current_select; + + Item_field *item= new Item_field(thd, &select->context, *ptr); + if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && + !thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS) + { + select->non_agg_fields.push_back(item); + item->marker= select->cur_pos_in_select_list; + } + return item; } |