Commit b77a85ef authored by evgen@moonbone.local's avatar evgen@moonbone.local

Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt

into  moonbone.local:/mnt/gentoo64/work/27874-bug-5.0-opt-mysql
parents 58320dfe 5cd1f992
......@@ -1035,3 +1035,15 @@ HAVING SUM(t1_inner.b)+t1_outer.b > 5);
ERROR 42000: 'test.t1_outer.b' isn't in GROUP BY
DROP TABLE t1;
SET SQL_MODE = '';
SET SQL_MODE = 'ONLY_FULL_GROUP_BY';
create table t1(f1 int, f2 int);
select * from t1 group by f1;
ERROR 42000: 'test.t1.f2' isn't in GROUP BY
select * from t1 group by f2;
ERROR 42000: 'test.t1.f1' isn't in GROUP BY
select * from t1 group by f1, f2;
f1 f2
select t1.f1,t.* from t1, t1 t group by 1;
ERROR 42000: 'test.t.f1' isn't in GROUP BY
drop table t1;
SET SQL_MODE = '';
......@@ -752,3 +752,17 @@ SELECT b FROM t1 AS t1_outer GROUP BY a HAVING t1_outer.a IN
HAVING SUM(t1_inner.b)+t1_outer.b > 5);
DROP TABLE t1;
SET SQL_MODE = '';
#
# Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
#
SET SQL_MODE = 'ONLY_FULL_GROUP_BY';
create table t1(f1 int, f2 int);
--error 1055
select * from t1 group by f1;
--error 1055
select * from t1 group by f2;
select * from t1 group by f1, f2;
--error 1055
select t1.f1,t.* from t1, t1 t group by 1;
drop table t1;
SET SQL_MODE = '';
......@@ -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,
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment