summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-04-24 22:35:57 +0400
committerunknown <evgen@moonbone.local>2007-04-24 22:35:57 +0400
commit3ffdeef04da6268a1adb82018dcd5ea402fbefaa (patch)
treecb48f221092ebf6e3cb2393a5ceba97738367e97 /sql
parentb2bd69adbff07e16ffb561413acbd5e023d541c9 (diff)
downloadmariadb-git-3ffdeef04da6268a1adb82018dcd5ea402fbefaa.tar.gz
Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
When fields are inserted instead of * in the select list they were not marked for check for the ONLY_FULL_GROUP_BY mode. The Field_iterator_table::create_item() function now marks newly created items for check when in the ONLY_FULL_GROUP_BY mode. The setup_wild() and the insert_fields() functions now maintain the cur_pos_in_select_list counter for the ONLY_FULL_GROUP_BY mode. sql/sql_base.cc: Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode. The setup_wild() and the insert_fields() functions now maintain the cur_pos_in_select_list counter for the ONLY_FULL_GROUP_BY mode. sql/table.cc: Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode. The Field_iterator_table::create_item() function now marks newly created items for check when in the ONLY_FULL_GROUP_BY mode. mysql-test/r/group_by.result: Added a test case for the bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode. mysql-test/t/group_by.test: Added a test case for the bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_base.cc5
-rw-r--r--sql/table.cc11
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;
}