mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
automerge
This commit is contained in:
@@ -1982,5 +1982,14 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
|
|||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by
|
1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# Bug #45807: crash accessing partitioned table and sql_mode
|
||||||
|
# contains ONLY_FULL_GROUP_BY
|
||||||
|
#
|
||||||
|
SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
|
||||||
|
CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
|
||||||
|
PARTITION BY HASH(id) PARTITIONS 2;
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET SESSION SQL_MODE=DEFAULT;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
SET @@global.general_log= @old_general_log;
|
SET @@global.general_log= @old_general_log;
|
||||||
|
@@ -642,3 +642,6 @@ drop procedure ` mysqltestbug36570_p2`;
|
|||||||
drop function mysqltestbug36570_f1;
|
drop function mysqltestbug36570_f1;
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
sync_slave_with_master;
|
||||||
|
@@ -1976,6 +1976,17 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
|
|||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug #45807: crash accessing partitioned table and sql_mode
|
||||||
|
--echo # contains ONLY_FULL_GROUP_BY
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
|
||||||
|
CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
|
||||||
|
PARTITION BY HASH(id) PARTITIONS 2;
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET SESSION SQL_MODE=DEFAULT;
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
|
||||||
SET @@global.general_log= @old_general_log;
|
SET @@global.general_log= @old_general_log;
|
||||||
|
10
sql/item.cc
10
sql/item.cc
@@ -4406,16 +4406,22 @@ mark_non_agg_field:
|
|||||||
Fields from outer selects added to the aggregate function
|
Fields from outer selects added to the aggregate function
|
||||||
outer_fields list as its unknown at the moment whether it's
|
outer_fields list as its unknown at the moment whether it's
|
||||||
aggregated or not.
|
aggregated or not.
|
||||||
|
We're using either the select lex of the cached table (if present)
|
||||||
|
or the field's resolution context. context->select_lex is
|
||||||
|
safe for use because it's either the SELECT we want to use
|
||||||
|
(the current level) or a stub added by non-SELECT queries.
|
||||||
*/
|
*/
|
||||||
|
SELECT_LEX *select_lex= cached_table ?
|
||||||
|
cached_table->select_lex : context->select_lex;
|
||||||
if (!thd->lex->in_sum_func)
|
if (!thd->lex->in_sum_func)
|
||||||
cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
|
select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (outer_fixed)
|
if (outer_fixed)
|
||||||
thd->lex->in_sum_func->outer_fields.push_back(this);
|
thd->lex->in_sum_func->outer_fields.push_back(this);
|
||||||
else if (thd->lex->in_sum_func->nest_level !=
|
else if (thd->lex->in_sum_func->nest_level !=
|
||||||
thd->lex->current_select->nest_level)
|
thd->lex->current_select->nest_level)
|
||||||
cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
|
select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -918,6 +918,9 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
|
|||||||
Set-up the TABLE_LIST object to be a list with a single table
|
Set-up the TABLE_LIST object to be a list with a single table
|
||||||
Set the object to zero to create NULL pointers and set alias
|
Set the object to zero to create NULL pointers and set alias
|
||||||
and real name to table name and get database name from file name.
|
and real name to table name and get database name from file name.
|
||||||
|
TODO: Consider generalizing or refactoring Lex::add_table_to_list() so
|
||||||
|
it can be used in all places where we create TABLE_LIST objects.
|
||||||
|
Also consider creating appropriate constructors for TABLE_LIST.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bzero((void*)&tables, sizeof(TABLE_LIST));
|
bzero((void*)&tables, sizeof(TABLE_LIST));
|
||||||
@@ -925,6 +928,13 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
|
|||||||
tables.table= table;
|
tables.table= table;
|
||||||
tables.next_local= 0;
|
tables.next_local= 0;
|
||||||
tables.next_name_resolution_table= 0;
|
tables.next_name_resolution_table= 0;
|
||||||
|
/*
|
||||||
|
Cache the table in Item_fields. All the tables can be cached except
|
||||||
|
the trigger pseudo table.
|
||||||
|
*/
|
||||||
|
tables.cacheable_table= TRUE;
|
||||||
|
context= thd->lex->current_context();
|
||||||
|
tables.select_lex= context->select_lex;
|
||||||
strmov(db_name_string, table->s->normalized_path.str);
|
strmov(db_name_string, table->s->normalized_path.str);
|
||||||
dir_length= dirname_length(db_name_string);
|
dir_length= dirname_length(db_name_string);
|
||||||
db_name_string[dir_length - 1]= 0;
|
db_name_string[dir_length - 1]= 0;
|
||||||
@@ -932,7 +942,6 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
|
|||||||
db_name= &db_name_string[home_dir_length];
|
db_name= &db_name_string[home_dir_length];
|
||||||
tables.db= db_name;
|
tables.db= db_name;
|
||||||
|
|
||||||
context= thd->lex->current_context();
|
|
||||||
table->map= 1; //To ensure correct calculation of const item
|
table->map= 1; //To ensure correct calculation of const item
|
||||||
table->get_fields_in_item_tree= TRUE;
|
table->get_fields_in_item_tree= TRUE;
|
||||||
save_table_list= context->table_list;
|
save_table_list= context->table_list;
|
||||||
@@ -965,7 +974,7 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
|
|||||||
save_use_only_table_context= thd->lex->use_only_table_context;
|
save_use_only_table_context= thd->lex->use_only_table_context;
|
||||||
thd->lex->use_only_table_context= TRUE;
|
thd->lex->use_only_table_context= TRUE;
|
||||||
|
|
||||||
error= func_expr->fix_fields(thd, (Item**)0);
|
error= func_expr->fix_fields(thd, (Item**)&func_expr);
|
||||||
|
|
||||||
thd->lex->use_only_table_context= save_use_only_table_context;
|
thd->lex->use_only_table_context= save_use_only_table_context;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user