summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2009-11-03 09:22:01 +0100
committerMattias Jonsson <mattias.jonsson@sun.com>2009-11-03 09:22:01 +0100
commitb35feb1ed0aa934ea244163ecea54b5e45157138 (patch)
tree5caa9e3f10f8eb59e55a71c26719cf2f46a79f3b /sql/sql_partition.cc
parent64badb5f269850d0111aec29788aff7e181c195d (diff)
downloadmariadb-git-b35feb1ed0aa934ea244163ecea54b5e45157138.tar.gz
Bug#46923: select count(*) from partitioned table fails with
ONLY_FULL_GROUP_BY Problem was that during checking and preparation of the partitioining function as a side effect in fix_fields the full_group_by_flag was changed. Solution was to set it back to its original value after calling fix_fields. Updated patch, to also exclude allow_sum_func from being affected of fix_fields, as requested by reviewer. mysql-test/r/partition.result: Bug#46923: select count(*) from partitioned table fails with ONLY_FULL_GROUP_BY Updated result file mysql-test/t/partition.test: Bug#46923: select count(*) from partitioned table fails with ONLY_FULL_GROUP_BY Extended test case to cover this bug sql/sql_partition.cc: Bug#46923: select count(*) from partitioned table fails with ONLY_FULL_GROUP_BY Resetting full_group_by_flag and allow_sum_func back to their original values, not conflicting with the sql_mode 'ONLY_FULL_GROUP_BY'
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 08ff2daacb9..bd66c48b852 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -905,6 +905,8 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
char* db_name;
char db_name_string[FN_REFLEN];
bool save_use_only_table_context;
+ uint8 saved_full_group_by_flag;
+ nesting_map saved_allow_sum_func;
DBUG_ENTER("fix_fields_part_func");
if (part_info->fixed)
@@ -974,9 +976,19 @@ 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;
thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
+ saved_full_group_by_flag= thd->lex->current_select->full_group_by_flag;
+ saved_allow_sum_func= thd->lex->allow_sum_func;
+ thd->lex->allow_sum_func= 0;
error= func_expr->fix_fields(thd, (Item**)&func_expr);
+ /*
+ Restore full_group_by_flag and allow_sum_func,
+ fix_fields should not affect mysql_select later, see Bug#46923.
+ */
+ thd->lex->current_select->full_group_by_flag= saved_full_group_by_flag;
+ thd->lex->allow_sum_func= saved_allow_sum_func;
+
thd->lex->use_only_table_context= save_use_only_table_context;
context->table_list= save_table_list;