summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <kaa@polly.(none)>2007-11-07 14:00:45 +0300
committerunknown <kaa@polly.(none)>2007-11-07 14:00:45 +0300
commitf6686659551be614c835ff5f3730e87f41e06d84 (patch)
tree0f20d286300d8c795aa921bb9a5e0403df81b975 /sql/sql_select.cc
parent6eced1b857b8df12079603cc18b716a92e69817f (diff)
downloadmariadb-git-f6686659551be614c835ff5f3730e87f41e06d84.tar.gz
Fix for bug #30666: Incorrect order when using range conditions on 2
tables or more The problem was that the optimizer used the join buffer in cases when the result set is ordered by filesort. This resulted in the ORDER BY clause being ignored, and the records being returned in the order determined by the order of matching records in the last table in join. Fixed by relaxing the condition in make_join_readinfo() to take filesort-ordered result sets into account, not only index-ordered ones. mysql-test/r/select.result: Added a test case for bug #30666. mysql-test/t/select.test: Added a test case for bug #30666. sql/sql_select.cc: Relaxed the condition to determine when the join buffer usage must be disabled. The condition is now true for cases when the result set is ordered by filesort, that is when 'join->order && !join->skip_sort_order' is true.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 3529de1c28a..24d1639edf1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6071,10 +6071,9 @@ make_join_readinfo(JOIN *join, ulonglong options)
ordered. If there is a temp table the ordering is done as a last
operation and doesn't prevent join cache usage.
*/
- if (!ordered_set && !join->need_tmp &&
- ((table == join->sort_by_table &&
- (!join->order || join->skip_sort_order)) ||
- (join->sort_by_table == (TABLE *) 1 && i != join->const_tables)))
+ if (!ordered_set && !join->need_tmp &&
+ (table == join->sort_by_table ||
+ (join->sort_by_table == (TABLE *) 1 && i != join->const_tables)))
ordered_set= 1;
switch (tab->type) {