summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-11-17 17:07:14 +0300
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-11-17 17:07:14 +0300
commit8cfa50e6771f1dbd6f265be44d9340a7d53084c2 (patch)
tree11ca9f752a8dc9c42ec294adef02023906f66bb1 /sql/opt_range.cc
parent58ee6c80ebd59fcb54ba61a196f7ae5e25e6b928 (diff)
downloadmariadb-git-8cfa50e6771f1dbd6f265be44d9340a7d53084c2.tar.gz
Bug #48472: Loose index scan inappropriately chosen for some
WHERE conditions check_group_min_max() checks if the loose index scan optimization is applicable for a given WHERE condition, that is if the MIN/MAX attribute participates only in range predicates comparing the corresponding field with constants. The problem was that it considered the whole predicate suitable for the loose index scan optimization as soon as it encountered a constant as a predicate argument. This is obviously wrong for cases when a constant is the first argument of a predicate which does not satisfy the above condition. Fixed check_group_min_max() so that all arguments of the input predicate are considered to decide if it passes the test, even though a constant has already been encountered. mysql-test/r/group_min_max.result: Added a test case for bug #48472. mysql-test/t/group_min_max.test: Added a test case for bug #48472. sql/opt_range.cc: Fixed check_group_min_max() so that all arguments of the input predicate are considered to decide if it passes the test, even though a constant has already been encountered.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 3236ccd2cf4..84519c091b9 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8244,7 +8244,11 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
}
else if (cur_arg->const_item())
{
- DBUG_RETURN(TRUE);
+ /*
+ For predicates of the form "const OP expr" we also have to check 'expr'
+ to make a decision.
+ */
+ continue;
}
else
DBUG_RETURN(FALSE);