summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorholyfoot/hf@hfmain.(none) <>2007-07-31 11:53:56 +0500
committerholyfoot/hf@hfmain.(none) <>2007-07-31 11:53:56 +0500
commitde8f84adfde3b81d1ea259a77c5271e767b874b1 (patch)
treefca3a73ba28f2ea41672cf48fc470d8bec0b93c6 /sql
parent120866c2737f55227d706b54959f50f83c387932 (diff)
parent0c63efcaf5e4a8a4cd1dbe4dd6796db9167f0318 (diff)
downloadmariadb-git-de8f84adfde3b81d1ea259a77c5271e767b874b1.tar.gz
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into mysql.com:/home/hf/work/29717/my50-29717
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 d82a0fdcf41..9b3fc4394e8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1121,6 +1121,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);
@@ -11461,7 +11462,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 4f9f6e9ed48..dbd555c16f8 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -282,6 +282,14 @@ public:
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
@@ -390,6 +398,7 @@ public:
zero_result_cause= 0;
optimized= 0;
cond_equal= 0;
+ group_optimized_away= 0;
all_fields= fields_arg;
fields_list= fields_arg;