diff options
author | gkodinov/kgeorge@macbook.gmz <> | 2006-10-16 19:30:19 +0300 |
---|---|---|
committer | gkodinov/kgeorge@macbook.gmz <> | 2006-10-16 19:30:19 +0300 |
commit | 0e954d2c1a686c1aa8fccd929db7af116f5ba3de (patch) | |
tree | 37cf8dd7346a569ac56263dbbde7777b8a907c70 /sql/opt_range.h | |
parent | 2e2c5a20c0329ddf432435db25255a8fc047dbd2 (diff) | |
download | mariadb-git-0e954d2c1a686c1aa8fccd929db7af116f5ba3de.tar.gz |
Bug #22342: No results returned for query using max and group by
When using index for group by and range access the server isolates
a set of ranges based on the conditions over the key parts of the
index used. Then it uses only the ranges over the GROUP BY fields to
jump from one group to another. Since the GROUP BY fields may form a
prefix over the index, we may use only a prefix of the ranges produced
by the range optimizer.
Each range contains a notion on whether it includes its border values.
The problem is that when using a range prefix, the last range is open
because it assumes that there is a range on the next keypart. Thus when
we use a prefix range as it is, it excludes all border values.
The solution is when ignoring the suffix of the range conditions
(to jump over the GROUP BY prefix only) the server must change the
remaining intervals so they always contain their borders, e.g.
if the whole range was :
(1,-inf) <= (<group_by_col>,<min_max_arg_col>) < (1, 3) we must make
(1) <= (<group_by_col>) <= (1) because (a,b) < (c1,c2) means :
a < c1 OR (a = c1 AND b < c2).
Diffstat (limited to 'sql/opt_range.h')
-rw-r--r-- | sql/opt_range.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/opt_range.h b/sql/opt_range.h index 9474f2d469f..784dd648ad2 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -294,6 +294,7 @@ protected: friend class QUICK_SELECT_DESC; friend class QUICK_INDEX_MERGE_SELECT; friend class QUICK_ROR_INTERSECT_SELECT; + friend class QUICK_GROUP_MIN_MAX_SELECT; DYNAMIC_ARRAY ranges; /* ordered array of range ptrs */ QUICK_RANGE **cur_range; /* current element in ranges */ @@ -642,6 +643,7 @@ public: ~QUICK_GROUP_MIN_MAX_SELECT(); bool add_range(SEL_ARG *sel_range); void update_key_stat(); + void adjust_prefix_ranges(); bool alloc_buffers(); int init(); int reset(); |