Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-04-24 20:12:54+04:00, evgen@stripped +4 -0
Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
When fields are inserted instead of * in the select list the wasn't marked for
check for 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 maintains the
cur_pos_in_select_list counter for the ONLY_FULL_GROUP_BY mode.
mysql-test/r/group_by.result@stripped, 2007-04-24 20:08:09+04:00, evgen@stripped +12 -0
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@stripped, 2007-04-24 20:07:48+04:00, evgen@stripped +14 -0
Added a test case for the bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
sql/sql_base.cc@stripped, 2007-04-24 20:11:58+04:00, evgen@stripped +5 -0
Bug#27874: Non-grouped columns are allowed by * in ONLY_FULL_GROUP_BY mode.
The setup_wild() and the insert_fields() functions now maintains the
cur_pos_in_select_list counter for the ONLY_FULL_GROUP_BY mode.
sql/table.cc@stripped, 2007-04-24 20:11:32+04:00, evgen@stripped +10 -1
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.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/27874-bug-5.0-opt-mysql
--- 1.376/sql/sql_base.cc 2007-04-03 15:55:14.000000000 +0400
+++ 1.377/sql/sql_base.cc 2007-04-24 20:11:58.000000000 +0400
@@ -4588,6 +4588,7 @@
*/
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 @@
}
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 @@
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,
--- 1.249/sql/table.cc 2007-04-13 10:14:38.000000000 +0400
+++ 1.250/sql/table.cc 2007-04-24 20:11:32.000000000 +0400
@@ -2670,7 +2670,16 @@
Item *Field_iterator_table::create_item(THD *thd)
{
- return new Item_field(thd, &thd->lex->current_select->context, *ptr);
+ Item_field *item= new Item_field(thd, &thd->lex->current_select->context,
+ *ptr);
+ if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
+ !thd->lex->in_sum_func &&
+ thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS)
+ {
+ thd->lex->current_select->non_agg_fields.push_back(item);
+ item->marker= thd->lex->current_select->cur_pos_in_select_list;
+ }
+ return item;
}
--- 1.76/mysql-test/r/group_by.result 2007-01-11 23:17:42.000000000 +0300
+++ 1.77/mysql-test/r/group_by.result 2007-04-24 20:08:09.000000000 +0400
@@ -1035,3 +1035,15 @@
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 = '';
--- 1.62/mysql-test/t/group_by.test 2007-01-11 23:17:43.000000000 +0300
+++ 1.63/mysql-test/t/group_by.test 2007-04-24 20:07:48.000000000 +0400
@@ -752,3 +752,17 @@
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 = '';
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2438) BUG#27874 | eugene | 24 Apr |