summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-07-31 11:00:19 +0500
committerunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-07-31 11:00:19 +0500
commit19d550953776a26fa267984996c73548f4853700 (patch)
tree031ef9120c51a8fe759f41f8e337d8a990bf116a /sql
parent7b1192473cf4da53f962678e2736d270d3a91bb4 (diff)
parent86ae84360fcefd17455aa192d168549ffebbf332 (diff)
downloadmariadb-git-19d550953776a26fa267984996c73548f4853700.tar.gz
Merge mysql.com:/home/hf/work/029717/my41-29717
into mysql.com:/home/hf/work/29717/my41-29717 sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_select.h9
2 files changed, 12 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index afbffc499ad..61690f09980 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -777,6 +777,7 @@ JOIN::optimize()
order=0; // The output has only one row
simple_order=1;
select_distinct= 0; // No need in distinct for 1 row
+ group_optimized_away= 1;
}
calc_group_buffer(this, group_list);
@@ -6896,7 +6897,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (!join->first_record || end_of_records ||
(idx=test_if_group_changed(join->group_fields)) >= 0)
{
- if (join->first_record || (end_of_records && !join->group))
+ if (join->first_record ||
+ (end_of_records && !join->group && !join->group_optimized_away))
{
if (join->procedure)
join->procedure->end_group();
diff --git a/sql/sql_select.h b/sql/sql_select.h
index c61ef4fb92b..6227d6d2cc5 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -180,6 +180,14 @@ class JOIN :public Sql_alloc
ROLLUP rollup; // Used with rollup
bool select_distinct; // Set if SELECT DISTINCT
+ /*
+ If we have the GROUP BY statement in the query,
+ but the group_list was emptied by optimizer, this
+ flag is TRUE.
+ It happens when fields in the GROUP BY are from
+ constant table
+ */
+ bool group_optimized_away;
/*
simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
@@ -276,6 +284,7 @@ class JOIN :public Sql_alloc
ref_pointer_array_size= 0;
zero_result_cause= 0;
optimized= 0;
+ group_optimized_away= 0;
fields_list= fields_arg;
bzero((char*) &keyuse,sizeof(keyuse));