diff options
author | Bernt M. Johnsen <bernt.johnsen@sun.com> | 2009-07-03 10:33:34 +0200 |
---|---|---|
committer | Bernt M. Johnsen <bernt.johnsen@sun.com> | 2009-07-03 10:33:34 +0200 |
commit | 61488d2abbaef189b45fa076a540d37088eceb7a (patch) | |
tree | 22e4c22626f415891259da6d4791d1fc4d7d571c | |
parent | 768f5b08fb3b46706b2e634134f33d0fa2776ab6 (diff) | |
parent | ae8950f1e831e267894e8363cd289a9ebb5d2311 (diff) | |
download | mariadb-git-61488d2abbaef189b45fa076a540d37088eceb7a.tar.gz |
automerge
-rw-r--r-- | mysql-test/r/partition.result | 9 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_sp.test | 3 | ||||
-rw-r--r-- | mysql-test/t/partition.test | 11 | ||||
-rw-r--r-- | sql/item.cc | 10 | ||||
-rw-r--r-- | sql/sql_partition.cc | 13 |
5 files changed, 42 insertions, 4 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 20853da1af0..8e3fbde1ea8 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -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 1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by 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 SET @@global.general_log= @old_general_log; diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test index ec6464fb095..9be630e9ae8 100644 --- a/mysql-test/suite/rpl/t/rpl_sp.test +++ b/mysql-test/suite/rpl/t/rpl_sp.test @@ -642,3 +642,6 @@ drop procedure ` mysqltestbug36570_p2`; drop function mysqltestbug36570_f1; --echo End of 5.0 tests --echo End of 5.1 tests + +# Cleanup +sync_slave_with_master; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 8535e1bc5c2..8b4af201af2 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1976,6 +1976,17 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; 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 SET @@global.general_log= @old_general_log; diff --git a/sql/item.cc b/sql/item.cc index 4c967200a3a..d380cafbee3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4406,16 +4406,22 @@ mark_non_agg_field: Fields from outer selects added to the aggregate function outer_fields list as its unknown at the moment whether it's 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) - cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; + select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; else { if (outer_fixed) thd->lex->in_sum_func->outer_fields.push_back(this); else if (thd->lex->in_sum_func->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; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 3713a10997d..4472b9be2cd 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -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 the object to zero to create NULL pointers and set alias 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)); @@ -925,6 +928,13 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, tables.table= table; tables.next_local= 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); dir_length= dirname_length(db_name_string); 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]; tables.db= db_name; - context= thd->lex->current_context(); table->map= 1; //To ensure correct calculation of const item table->get_fields_in_item_tree= TRUE; 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; 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; |