summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2013-02-01 00:09:36 +0200
committerunknown <timour@askmonty.org>2013-02-01 00:09:36 +0200
commit768b62fe2f745284c99ab454c67a9b9035e802fd (patch)
tree16b03ae2d55e88d0c99bde8a6a1dfa0464d683f5 /sql/opt_range.cc
parent7f208d3c356e559d3be15f161df8a0adbfa2dd1c (diff)
downloadmariadb-git-768b62fe2f745284c99ab454c67a9b9035e802fd.tar.gz
Fix bug MDEV-641
Analysis: Range analysis discoveres that the query can be executed via loose index scan for GROUP BY. Later, GROUP BY analysis fails to confirm that the GROUP operation can be computed via an index because there is no logic to handle duplicate field references in the GROUP clause. As a result the optimizer produces an inconsistent plan. It constructs a temporary table, but on the other hand the group fields are not set to point there. Solution: Make loose scan analysis work in sync with order by analysis. In the case of duplicate columns loose scan will not be applicable. This limitation will be lifted in 10.0 by removing duplicate columns.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 14c2eeddb9f..89495e57e93 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -9481,6 +9481,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
else
goto next_index;
}
+ /*
+ This function is called on the precondition that the index is covering.
+ Therefore if the GROUP BY list contains more elements than the index,
+ these are duplicates. The GROUP BY list cannot be a prefix of the index.
+ */
+ if (cur_part == end_part && tmp_group)
+ goto next_index;
}
/*
Check (GA2) if this is a DISTINCT query.