diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 763b9340b..febb08ade 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -576,6 +576,7 @@ impl BTreeCursor { } else { cell_idx }; + let cell = contents.cell_get( cell_idx, payload_overflow_threshold_max(contents.page_type(), self.usable_space() as u16), @@ -589,6 +590,7 @@ impl BTreeCursor { _rowid, }) => { let mem_page = self.read_page(_left_child_page as usize)?; + self.stack.retreat(); self.stack.push_backwards(mem_page); continue; } diff --git a/testing/orderby.test b/testing/orderby.test index b5b56cdd4..0a12e84d7 100755 --- a/testing/orderby.test +++ b/testing/orderby.test @@ -199,4 +199,9 @@ do_execsql_test orderby_desc_with_filter_id_le { 6665 6664 6663 -6662} \ No newline at end of file +6662} + +# regression test where backwards iteration used to hang indefinitely +do_execsql_test orderby_desc_subquery_count_regression { + select count(1) from (select * from users where id < 100 order by id desc) +} {99} \ No newline at end of file