summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <tsmith@ramayana.hindu.god>2007-08-01 18:38:43 -0600
committerunknown <tsmith@ramayana.hindu.god>2007-08-01 18:38:43 -0600
commitcbbc8bb3c13d011dd7997666dfc70a54f9c4886d (patch)
treef40080b054973f8b95336e848a733334290d8664 /sql
parente399ae5ab75a1d95b74c1c11aff590644ecc9caa (diff)
parent6b745cf601761057d414f631924c6fae5be999b2 (diff)
downloadmariadb-git-cbbc8bb3c13d011dd7997666dfc70a54f9c4886d.tar.gz
Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into ramayana.hindu.god:/home/tsmith/m/bk/maint/41
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));