From 340134ac2fd5c70036d53ada2da3ca32cdaa1843 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 16 Jul 2008 12:31:50 +0300 Subject: Bug#37830 : ORDER BY ASC/DESC - no difference Range scan in descending order for c <= <= c type of ranges was ignoring the DESC flag. However some engines like InnoDB have the primary key parts as a suffix for every secondary key. When such primary key suffix is used for ordering ignoring the DESC is not valid. But we generally would like to do this because it's faster. Fixed by performing only reverse scan if the primary key is used. Removed some dead code in the process. mysql-test/r/innodb_mysql.result: Bug#37830 : test case mysql-test/t/innodb_mysql.test: Bug#37830 : test case sql/opt_range.cc: Bug#37830 : - preserve and use used_key_parts to distinguish when a primary key suffix is used - removed some dead code sql/opt_range.h: Bug#37830 : - preserve used_key_parts - dead code removed sql/sql_select.cc: Bug#37830 : Do only reverse order traversal if the primary key suffix is used. --- sql/opt_range.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sql/opt_range.h') diff --git a/sql/opt_range.h b/sql/opt_range.h index 3a737323eb7..8856223b371 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -667,12 +667,10 @@ public: int get_type() { return QS_TYPE_RANGE_DESC; } private: bool range_reads_after_key(QUICK_RANGE *range); -#ifdef NOT_USED - bool test_if_null_range(QUICK_RANGE *range, uint used_key_parts); -#endif int reset(void) { rev_it.rewind(); return QUICK_RANGE_SELECT::reset(); } List rev_ranges; List_iterator rev_it; + uint used_key_parts; }; -- cgit v1.2.1