=== modified file 'mysql-test/r/myisam_explain_non_select_all.result'
--- mysql-test/r/myisam_explain_non_select_all.result	2013-10-15 06:36:39 +0000
+++ mysql-test/r/myisam_explain_non_select_all.result	2014-03-16 16:49:10 +0000
@@ -1172,12 +1172,12 @@ INSERT INTO t1 (i) VALUES (10),(11),(12)
 #
 EXPLAIN DELETE   FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	8	Using where
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	5	Using where
 FLUSH STATUS;
 FLUSH TABLES;
 EXPLAIN EXTENDED DELETE   FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	8	100.00	Using where
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	5	100.00	Using where
 # Status of EXPLAIN EXTENDED query
 Variable_name	Value
 FLUSH STATUS;
@@ -1479,12 +1479,12 @@ INSERT INTO t2 (i) SELECT i FROM t1;
 #
 EXPLAIN DELETE   FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	Using where
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	Using where
 FLUSH STATUS;
 FLUSH TABLES;
 EXPLAIN EXTENDED DELETE   FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	100.00	Using where
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	100.00	Using where
 # Status of EXPLAIN EXTENDED query
 Variable_name	Value
 FLUSH STATUS;
@@ -1606,12 +1606,12 @@ INSERT INTO t2 (i) SELECT i FROM t1;
 #
 EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	Using where; Using buffer
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	Using where; Using buffer
 FLUSH STATUS;
 FLUSH TABLES;
 EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	100.00	Using where; Using buffer
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	100.00	Using where; Using buffer
 # Status of EXPLAIN EXTENDED query
 Variable_name	Value
 FLUSH STATUS;
@@ -1915,12 +1915,12 @@ INSERT INTO t2 (i) SELECT i FROM t1;
 #
 EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	Using where; Using buffer
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	Using where; Using buffer
 FLUSH STATUS;
 FLUSH TABLES;
 EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	8	100.00	Using where; Using buffer
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	5	100.00	Using where; Using buffer
 # Status of EXPLAIN EXTENDED query
 Variable_name	Value
 FLUSH STATUS;

=== modified file 'mysql-test/r/update.result'
--- mysql-test/r/update.result	2014-03-16 13:33:37 +0000
+++ mysql-test/r/update.result	2014-03-16 16:29:42 +0000
@@ -615,7 +615,7 @@ select A.a + 10 * B.a + 100 * C.a, 1234
 explain 
 update t1 set key1=key1+1 where key1 between 10 and 110 order by key1 limit 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	key1	key1	5	NULL	100	Using where; Using buffer
+1	SIMPLE	t1	range	key1	key1	5	NULL	2	Using where; Using buffer
 flush status;
 update t1 set key1=key1+1 where key1 between 10 and 110 order by key1 limit 2;
 show status like 'Handler_read%';

=== modified file 'sql/sql_select.cc'
--- sql/sql_select.cc	2014-03-05 22:20:10 +0000
+++ sql/sql_select.cc	2014-03-17 11:45:47 +0000
@@ -24732,7 +24732,8 @@ uint get_index_for_order(ORDER *order, T
     switch (test_if_order_by_key(order, table, select->quick->index,
                                  &used_key_parts)) {
     case 1: // desired order
-      *need_sort= FALSE;
+      *need_sort= FALSE; 
+      *scanned_limit= MY_MIN(limit, select->quick->records);
       return select->quick->index;
     case 0: // unacceptable order
       *need_sort= TRUE;
@@ -24745,7 +24746,7 @@ uint get_index_for_order(ORDER *order, T
         {
           select->set_quick(reverse_quick);
           *need_sort= FALSE;
-          *scanned_limit= select->quick->records;
+          *scanned_limit= MY_MIN(limit, select->quick->records);
           return select->quick->index;
         }
         else

